diff options
| author | Laurent Bercot <ska-skaware@skarnet.org> | 2026-04-20 23:00:13 +0000 |
|---|---|---|
| committer | Laurent Bercot <ska-skaware@skarnet.org> | 2026-04-20 23:00:13 +0000 |
| commit | bfffc7a8685d914873eaa1fc918f660b1fee4d8e (patch) | |
| tree | 2ac67a8d01ce66755a1a88ccceeff209a24eae5c | |
| parent | b802dc3f5c30d378a9d25b6acdef09780b591acf (diff) | |
| download | s6-rc-bfffc7a8685d914873eaa1fc918f660b1fee4d8e.tar.gz | |
Prepare for 0.6.1.0; set RC_NAME in oneshots
| -rw-r--r-- | NEWS | 2 | ||||
| -rw-r--r-- | doc/index.html | 4 | ||||
| -rw-r--r-- | doc/s6-rc-oneshot-run.html | 8 | ||||
| -rw-r--r-- | doc/s6-rc.html | 5 | ||||
| -rw-r--r-- | doc/upgrade.html | 2 | ||||
| -rw-r--r-- | package/info | 2 | ||||
| -rw-r--r-- | src/s6-rc/s6-rc-oneshot-run.c | 69 |
7 files changed, 56 insertions, 36 deletions
@@ -1,6 +1,6 @@ Changelog for s6-rc. -In 0.6.0.1 +In 0.6.1.0 ---------- - Bugfixes. diff --git a/doc/index.html b/doc/index.html index f80ecda..fb7e119 100644 --- a/doc/index.html +++ b/doc/index.html @@ -69,8 +69,8 @@ requirement if you link against the shared version of the skalibs library. </li> <ul> <li> The current released version of s6-rc is -<a href="s6-rc-0.6.0.1.tar.gz">0.6.0.1</a>. -You can access its checksum <a href="s6-rc-0.6.0.1.tar.gz.sha256">here</a>. </li> +<a href="s6-rc-0.6.1.0.tar.gz">0.6.1.0</a>. +You can access its checksum <a href="s6-rc-0.6.1.0.tar.gz.sha256">here</a>. </li> <li> Alternatively, you can checkout a copy of the <a href="//git.skarnet.org/cgi-bin/cgit.cgi/s6-rc/">s6-rc git repository</a>: diff --git a/doc/s6-rc-oneshot-run.html b/doc/s6-rc-oneshot-run.html index 5e641bd..ee454ae 100644 --- a/doc/s6-rc-oneshot-run.html +++ b/doc/s6-rc-oneshot-run.html @@ -31,7 +31,7 @@ in internal scripts created by <a href="s6-rc.html">s6-rc</a> execution. </p> -<h2> Interface </h2> +<h2 id="interface"> Interface </h2> <pre> s6-rc-oneshot-run [ -l <em>live</em> ] [ -b ] up|down <em>n</em> @@ -42,9 +42,11 @@ in internal scripts created by of the <em>n</em>th oneshot service defined in the current compiled service database (i.e. the compiled linked from the live directory). </li> + <li> <tt>up</tt> or <tt>down</tt> are run with the <tt>RC_NAME</tt> +environment variable set to the name of the service. </li> </ul> -<h2> Options </h2> +<h2 id="options"> Options </h2> <ul> <li> <tt>-l <em>live</em></tt> : use the live directory in @@ -57,7 +59,7 @@ By default, s6-rc-oneshot-run fails with an error message if the database is currently in use. </li> </ul> -<h2> Exit codes </h2> +<h2 id="exitcodes"> Exit codes </h2> <ul> <li> 3: invalid service number </li> diff --git a/doc/s6-rc.html b/doc/s6-rc.html index 62c33ca..a7eb9d9 100644 --- a/doc/s6-rc.html +++ b/doc/s6-rc.html @@ -370,6 +370,11 @@ tree, instead of children of the s6-rc process. </p> <p> + The <em>up</em> and <em>down</em> scripts are run with the <tt>RC_NAME</tt> +environment variable set to the name of the service. +</p> + +<p> Transitions should be ideally transactional, or at the very least idempotent. If a transition fails, it should leave the machine in the same state as diff --git a/doc/upgrade.html b/doc/upgrade.html index 64cbe1d..0e75dbe 100644 --- a/doc/upgrade.html +++ b/doc/upgrade.html @@ -31,7 +31,7 @@ minor and bugfix version changes. <h1> What has changed in s6-rc </h1> -<h2> in 0.6.0.1 </h2> +<h2> in 0.6.1.0 </h2> <ul> <li> <a href="//skarnet.org/software/skalibs/">skalibs</a> diff --git a/package/info b/package/info index 95936cb..1932ad2 100644 --- a/package/info +++ b/package/info @@ -1,4 +1,4 @@ package=s6-rc -version=0.6.0.1 +version=0.6.1.0 category=admin package_macro_name=S6RC diff --git a/src/s6-rc/s6-rc-oneshot-run.c b/src/s6-rc/s6-rc-oneshot-run.c index 87a0399..dbaa38d 100644 --- a/src/s6-rc/s6-rc-oneshot-run.c +++ b/src/s6-rc/s6-rc-oneshot-run.c @@ -5,11 +5,11 @@ #include <stdint.h> #include <unistd.h> +#include <skalibs/uint64.h> #include <skalibs/types.h> -#include <skalibs/sgetopt.h> #include <skalibs/strerr.h> #include <skalibs/djbunix.h> -#include <skalibs/exec.h> +#include <skalibs/envexec.h> #include <s6-rc/config.h> #include <s6-rc/s6rc.h> @@ -17,44 +17,52 @@ #define USAGE "s6-rc-oneshot-run [ -l live ] [ -b ] up|down servicenumber" #define dieusage() strerr_dieusage(100, USAGE) +enum golb_e +{ + GOLB_UP = 0x01, + GOLB_BLOCK = 0x02, +} ; + +enum gola_e +{ + GOLA_LIVEDIR, + GOLA_N +} ; + int main (int argc, char const *const *argv) { - char const *live = S6RC_LIVEDIR ; + static gol_bool const rgolb[] = + { + { .so = 0, .lo = "no-block", .clear = GOLB_BLOCK, .set = 0 }, + { .so = 'b', .lo = "block", .clear = 0, .set = GOLB_BLOCK }, + } ; + static gol_arg const rgola[] = + { + { .so = 'l', .lo = "livedir", .i = GOLA_LIVEDIR }, + } ; + uint64_t wgolb = 0 ; + char const *wgola[GOLA_N] = { [GOLA_LIVEDIR] = S6RC_LIVEDIR } ; unsigned int number ; - int up ; - int blocking = 0 ; PROG = "s6-rc-oneshot-run" ; - { - subgetopt l = SUBGETOPT_ZERO ; - for (;;) - { - int opt = subgetopt_r(argc, argv, "l:b", &l) ; - if (opt == -1) break ; - switch (opt) - { - case 'l' : live = l.arg ; break ; - case 'b' : blocking = 1 ; break ; - default : dieusage() ; - } - } - argc -= l.ind ; argv += l.ind ; - } + number = GOL_main(argc, argv, rgolb, rgola, &wgolb, wgola) ; + argc -= number ; argv += number ; if (argc < 2) dieusage() ; - if (!strcasecmp(argv[0], "up")) up = 1 ; - else if (!strcasecmp(argv[0], "down")) up = 0 ; + + if (!strcasecmp(argv[0], "up")) wgolb |= GOLB_UP ; + else if (!strcasecmp(argv[0], "down")) wgolb &= ~GOLB_UP ; else dieusage() ; if (!uint0_scan(argv[1], &number)) dieusage() ; { - size_t livelen = strlen(live) ; + size_t livelen = strlen(wgola[GOLA_LIVEDIR]) ; int fdcompiled, compiledlock ; s6rc_db_t db ; char compiled[livelen + 10] ; - memcpy(compiled, live, livelen) ; + memcpy(compiled, wgola[GOLA_LIVEDIR], livelen) ; memcpy(compiled + livelen, "/compiled", 10) ; - if (!s6rc_lock(0, 0, 0, compiled, 1, &compiledlock, blocking)) + if (!s6rc_lock(0, 0, 0, compiled, 1, &compiledlock, !!(wgolb & GOLB_BLOCK))) strerr_diefu2sys(111, "take lock on ", compiled) ; fdcompiled = open_readb(compiled) ; if (fdcompiled < 0) @@ -98,13 +106,18 @@ int main (int argc, char const *const *argv) /* Run the script */ { - unsigned int sargc = db.services[number].x.oneshot.argc[up] ; - char const *const *sargv = db.argvs + db.services[number].x.oneshot.argv[up] ; + s6rc_service_t const *sv = db.services + number ; + unsigned int namelen = strlen(db.string + sv->name) ; + unsigned int sargc = sv->x.oneshot.argc[!!(wgolb & GOLB_UP)] ; + char const *const *sargv = db.argvs + sv->x.oneshot.argv[!!(wgolb & GOLB_UP)] ; char const *newargv[sargc + 1] ; char const **p = newargv ; + char modif[namelen + 9] ; + memcpy(modif, "RC_NAME=", 8) ; + memcpy(modif + 8, db.string + sv->name, namelen + 1) ; while (sargc--) *p++ = *sargv++ ; *p = 0 ; - xexec0(newargv) ; + xmexec0_n(newargv, modif, namelen + 9, 1) ; } } } |
