From bfffc7a8685d914873eaa1fc918f660b1fee4d8e Mon Sep 17 00:00:00 2001
From: Laurent Bercot
Date: Mon, 20 Apr 2026 23:00:13 +0000
Subject: Prepare for 0.6.1.0; set RC_NAME in oneshots
---
NEWS | 2 +-
doc/index.html | 4 +--
doc/s6-rc-oneshot-run.html | 8 +++--
doc/s6-rc.html | 5 ++++
doc/upgrade.html | 2 +-
package/info | 2 +-
src/s6-rc/s6-rc-oneshot-run.c | 69 +++++++++++++++++++++++++------------------
7 files changed, 56 insertions(+), 36 deletions(-)
diff --git a/NEWS b/NEWS
index 7728a88..b06a16f 100644
--- a/NEWS
+++ b/NEWS
@@ -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.
- The current released version of s6-rc is
-0.6.0.1.
-You can access its checksum here.
+0.6.1.0.
+You can access its checksum here.
- Alternatively, you can checkout a copy of the
s6-rc
git repository:
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
s6-rc execution.
- Interface
+ Interface
s6-rc-oneshot-run [ -l live ] [ -b ] up|down n
@@ -42,9 +42,11 @@ in internal scripts created by
of the nth oneshot service defined
in the current compiled service database (i.e. the compiled linked from the
live directory).
+ up or down are run with the RC_NAME
+environment variable set to the name of the service.
- Options
+ Options
- -l live : 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.
- Exit codes
+ Exit codes
- 3: invalid service number
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
@@ -369,6 +369,11 @@ the up or down scripts as scions of the s6 supervision
tree, instead of children of the s6-rc process.
+
+ The up and down scripts are run with the RC_NAME
+environment variable set to the name of the service.
+
+
Transitions should be ideally transactional, or at the very least
idempotent. If a
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.
What has changed in s6-rc
- in 0.6.0.1
+ in 0.6.1.0
- skalibs
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
#include
+#include
#include
-#include
#include
#include
-#include
+#include
#include
#include
@@ -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) ;
}
}
}
--
cgit v1.3.1