aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/overview.html15
-rw-r--r--doc/s6.html14
-rw-r--r--doc/s6_live.html35
-rw-r--r--src/libs6f/s6f_report_state_change.c8
-rw-r--r--src/s6-frontend/live.c1
-rw-r--r--src/s6-frontend/live_start_everything.c22
-rw-r--r--src/s6-frontend/s6-frontend-internal.h4
-rw-r--r--src/s6-frontend/s6-frontend.c26
-rw-r--r--src/s6-frontend/system_boot.c2
9 files changed, 110 insertions, 17 deletions
diff --git a/doc/overview.html b/doc/overview.html
index cd9f338..84a81e1 100644
--- a/doc/overview.html
+++ b/doc/overview.html
@@ -265,8 +265,9 @@ the kind of commands that can be worked with.
<tbody>
<tr>
<td> <tt>rc-service foobar start</tt> </td>
- <td> <tt>s6 live start foobar</tt> </td>
- <td> Starts a service in the live database. </td>
+ <td> <tt>s6 live start foobar</tt> or <tt>s6 start foobar</tt> </td>
+ <td> Starts a service in the live database. <tt>s6 start foobar</tt>
+is a shortcut. </td>
</tr>
<tr>
<td> <tt>rc-service foobar status</tt> </td>
@@ -282,13 +283,15 @@ in which case it will give detailed information on its supervised instance. </td
</tr>
<tr>
<td> <tt>rc-update add foobar</tt> </td>
- <td> <tt>s6 set enable foobar</tt> </td>
- <td> Enable service <tt>foobar</tt> in the <tt>current</tt> offline working set. </td>
+ <td> <tt>s6 set enable foobar</tt> or <tt>s6 enable foobar</tt> </td>
+ <td> Enable service <tt>foobar</tt> in the <tt>current</tt> offline working set.
+<tt>s6 enable foobar</tt> is a shortcut. </td>
</tr>
<tr>
<td> <tt>rc-update del foobar</tt> </td>
- <td> <tt>s6 set disable foobar</tt> </td>
- <td> Disable service <tt>foobar</tt> in the <tt>current</tt> offline working set. </td>
+ <td> <tt>s6 set disable foobar</tt> or <tt>s6 disable foobar</tt> </td>
+ <td> Disable service <tt>foobar</tt> in the <tt>current</tt> offline working set.
+<tt>s6 disable foobar</tt> is a shortcut. </td>
</tr>
<tr>
<td> <tt>rc-update show</tt> </td>
diff --git a/doc/s6.html b/doc/s6.html
index a5454c3..0f6fc39 100644
--- a/doc/s6.html
+++ b/doc/s6.html
@@ -220,6 +220,20 @@ to shut the system down.
The details are available <a href="s6_system.html">here</a>.
</p>
+<h3 id="shortcuts"> shortcuts </h3>
+
+<p>
+ Some common subcommands have shortcuts, for ease of typing.
+</p>
+
+<ul>
+ <li> <tt>s6 enable</tt> is a shortcut for <a href="s6_set.html#enable"><tt>s6 set enable</tt></a>. </li>
+ <li> <tt>s6 disable</tt> is a shortcut for <a href="s6_set.html#disable"><tt>s6 set disable</tt></a>. </li>
+ <li> <tt>s6 start</tt> is a shortcut for <a href="s6_live.html#start"><tt>s6 live start</tt></a>. </li>
+ <li> <tt>s6 stop</tt> is a shortcut for <a href="s6_live.html#stop"><tt>s6 live stop</tt></a>. </li>
+ <li> <tt>s6 kill</tt> is a shortcut for <a href="s6_process.html#kill"><tt>s6 process kill</tt></a>. </li>
+</ul>
+
<h2 id="notes"> Notes </h2>
<ul>
diff --git a/doc/s6_live.html b/doc/s6_live.html
index 0af54c5..d770f80 100644
--- a/doc/s6_live.html
+++ b/doc/s6_live.html
@@ -206,6 +206,41 @@ The default is <tt>default</tt>, possibly overridden by the
<a href="//skarnet.org/software/s6-frontend/">s6-frontend</a>. </dd>
</dl>
+<h3 id="reset"> reset </h3>
+
+<h4> Interface </h4>
+
+<pre>
+ s6 live reset [ -n ] [ -t <em>timeout</em> ] [ -D <em>bundle</em> ]
+</pre>
+
+<ul>
+ <li> <tt>s6 live reset</tt> brings up all the services in the default bundle
+<em>and</em> brings down all the services that are <em>not</em> in it. In
+other words, it resets the machine state to what it was right after
+booting. </li>
+</ul>
+
+<h4> Options </h4>
+
+<dl>
+<dt> <tt>-n</tt>, <tt>--dry-run</tt> </dt>
+<dd> Only print what would be done; do not actually change service states. </dd>
+
+<dt> <tt>-t <em>timeout</em></tt>, <tt>--timeout=<em>timeout</em></tt> </dt>
+<dd> If the whole change still hasn't completed after <em>timeout</em>
+milliseconds, stop waiting and don't attempt to perform the remaining
+transitions. By default, <em>timeout</em> is 0, meaning infinite: the
+command can wait forever. </dd>
+
+<dt> <tt>-D <em>bundle</em></tt>, <tt>--default-bundle=<em>bundle</em></tt> </dt>
+<dd> Align to the bundle of services named <em>bundle</em> instead.
+The default is <tt>default</tt>, possibly overridden by the
+<tt>--with-default-bundle</tt> build-time configure option in
+<a href="//skarnet.org/software/s6-rc/">s6-rc</a> or
+<a href="//skarnet.org/software/s6-frontend/">s6-frontend</a>. </dd>
+</dl>
+
<h3 id="stop-everything"> stop-everything </h3>
<h4> Interface </h4>
diff --git a/src/libs6f/s6f_report_state_change.c b/src/libs6f/s6f_report_state_change.c
index 9cb718b..6a34724 100644
--- a/src/libs6f/s6f_report_state_change.c
+++ b/src/libs6f/s6f_report_state_change.c
@@ -1,7 +1,5 @@
/* ISC license. */
-#include <string.h>
-
#include <skalibs/prog.h>
#include <skalibs/strerr.h>
#include <skalibs/djbunix.h>
@@ -12,7 +10,9 @@
void s6f_report_state_change (uint32_t n, unsigned char const *oldstate, unsigned char const *newstate, char const *compiled, int h)
{
- if (!memcmp(oldstate, newstate, n))
+ unsigned int i = 0 ;
+ for (; i < n ; i++) if ((oldstate[i] & 0x01) != (newstate[i] & 0x01)) break ;
+ if (i >= n)
{
if (buffer_puts(buffer_1, PROG) < 0
|| buffer_puts(buffer_1, ": info: ") < 0
@@ -51,7 +51,7 @@ void s6f_report_state_change (uint32_t n, unsigned char const *oldstate, unsigne
strerr_diefu1sys(111, "write to stdout") ;
for (uint32_t i = 0 ; i < n ; i++)
{
- if ((oldstate[i] & 1) != (newstate[i] & 1))
+ if ((oldstate[i] & 0x01) != (newstate[i] & 0x01))
{
if (buffer_puts(buffer_1, db.string + db.services[i].name) < 0
|| buffer_put(buffer_1, "\n", 1) < 1)
diff --git a/src/s6-frontend/live.c b/src/s6-frontend/live.c
index 13571b1..c1942b1 100644
--- a/src/s6-frontend/live.c
+++ b/src/s6-frontend/live.c
@@ -17,6 +17,7 @@ void live (char const *const *argv)
{
{ .s = "help", .f = &live_help },
{ .s = "install", .f = &live_install },
+ { .s = "reset", .f = &live_reset },
{ .s = "restart", .f = &live_restart },
{ .s = "start", .f = &live_start },
{ .s = "start-everything", .f = &live_start_everything },
diff --git a/src/s6-frontend/live_start_everything.c b/src/s6-frontend/live_start_everything.c
index 2f971e9..a8cf0c2 100644
--- a/src/s6-frontend/live_start_everything.c
+++ b/src/s6-frontend/live_start_everything.c
@@ -20,10 +20,10 @@ enum gola_e
GOLA_N
} ;
-void exec_live_start_everything (unsigned int timeout, int dryrun, char const *defbundle)
+void exec_live_start_everything (unsigned int timeout, char const *defbundle, unsigned int options)
{
unsigned int m = 0 ;
- char const *argv[13] ;
+ char const *argv[14] ;
char fmtv[UINT_FMT] ;
char fmtt[UINT_FMT] ;
@@ -40,7 +40,8 @@ void exec_live_start_everything (unsigned int timeout, int dryrun, char const *d
argv[m++] = "-t" ;
argv[m++] = fmtt ;
}
- if (dryrun) argv[m++] = "-n1" ;
+ if (options & 1) argv[m++] = "-n1" ;
+ if (options & 2) argv[m++] = "-p" ;
argv[m++] = "-l" ;
argv[m++] = g->dirs.live ;
argv[m++] = "-b" ;
@@ -51,7 +52,8 @@ void exec_live_start_everything (unsigned int timeout, int dryrun, char const *d
main_exec(argv) ;
}
-void live_start_everything (char const *const *argv)
+static void live_start_default (char const *const *argv, int prune) gccattr_noreturn ;
+static void live_start_default (char const *const *argv, int prune)
{
static gol_bool const rgolb[] =
{
@@ -73,5 +75,15 @@ void live_start_everything (char const *const *argv)
if (!uint0_scan(wgola[GOLA_TIMEOUT], &timeout))
strerr_dief1x(100, "timeout must be an integer (milliseconds)") ;
}
- exec_live_start_everything(timeout, !!(wgolb & GOLB_DRYRUN), wgola[GOLA_DEFBUNDLE]) ;
+ exec_live_start_everything(timeout, wgola[GOLA_DEFBUNDLE], (wgolb & GOLB_DRYRUN) | (!!prune << 1) ) ;
+}
+
+void live_start_everything (char const *const *argv)
+{
+ live_start_default(argv, 0) ;
+}
+
+void live_reset (char const *const *argv)
+{
+ live_start_default(argv, 1) ;
}
diff --git a/src/s6-frontend/s6-frontend-internal.h b/src/s6-frontend/s6-frontend-internal.h
index 7bd1409..2bc83b0 100644
--- a/src/s6-frontend/s6-frontend-internal.h
+++ b/src/s6-frontend/s6-frontend-internal.h
@@ -21,7 +21,7 @@
/* live */
-extern void exec_live_start_everything (unsigned int, int, char const *) gccattr_noreturn ;
+extern void exec_live_start_everything (unsigned int, char const *, unsigned int) gccattr_noreturn ;
extern void live (char const *const *) gccattr_noreturn ;
extern void live_help (char const *const *) gccattr_noreturn ;
@@ -32,6 +32,7 @@ extern void live_status (char const *const *) gccattr_noreturn ;
extern void live_stop (char const *const *) gccattr_noreturn ;
extern void live_start_everything (char const *const *) gccattr_noreturn ;
+extern void live_reset (char const *const *) gccattr_noreturn ;
extern void live_stop_everything (char const *const *) gccattr_noreturn ;
extern void live_install (char const *const *) gccattr_noreturn ;
@@ -152,6 +153,7 @@ extern struct global_s *g ;
extern void main_exec (char const *const *) gccattr_noreturn ;
extern void main_pretty_exec (char const *const *) gccattr_noreturn ;
+extern void main_try (void (*)(char const *const *), char const *const *) ;
extern pid_t main_spawn (char const *const *argv) ;
extern void main_help (char const *const *) gccattr_noreturn ;
diff --git a/src/s6-frontend/s6-frontend.c b/src/s6-frontend/s6-frontend.c
index 6d829ef..c79464e 100644
--- a/src/s6-frontend/s6-frontend.c
+++ b/src/s6-frontend/s6-frontend.c
@@ -1,5 +1,6 @@
/* ISC license. */
+#include <sys/wait.h>
#include <string.h>
#include <unistd.h>
@@ -8,6 +9,7 @@
#include <skalibs/buffer.h>
#include <skalibs/envexec.h>
#include <skalibs/cspawn.h>
+#include <skalibs/djbunix.h>
#include <execline/config.h>
@@ -54,6 +56,25 @@ void main_exec (char const *const *argv)
xmexec_m(argv, CLEANUP_MODIF, sizeof(CLEANUP_MODIF)) ;
}
+void main_try (void (*f)(char const *const *), char const *const *argv)
+{
+ pid_t pid = fork() ;
+ if (pid == -1) strerr_diefusys(111, "fork") ;
+ if (!pid)
+ {
+ PROG = "s6-frontend (child)" ;
+ (*f)(argv) ;
+ strerr_dief(101, "can't happen: in main_try, noreturn function returned") ;
+ }
+ else
+ {
+ int wstat ;
+ pid_t r = wait_pid(pid, &wstat) ;
+ if (r == -1) strerr_diefusys(111, "waitpid") ;
+ if (WIFSIGNALED(wstat) || WEXITSTATUS(wstat)) _exit(wait_estatus(wstat)) ;
+ }
+}
+
void main_pretty_exec (char const *const *argv)
{
#ifdef S6_FRONTEND_USE_UTIL_LINUX
@@ -97,7 +118,10 @@ int main (int argc, char const *const *argv)
} ;
static struct command_s const commands[] =
{
+ { .s = "disable", .f = &set_disable },
+ { .s = "enable", .f = &set_enable },
{ .s = "help", .f = &main_help },
+ { .s = "kill", .f = &process_kill },
{ .s = "l", .f = &live },
{ .s = "live", .f = &live },
{ .s = "p", .f = &process },
@@ -107,6 +131,8 @@ int main (int argc, char const *const *argv)
{ .s = "repo", .f = &repository },
{ .s = "repository", .f = &repository },
{ .s = "set", .f = &set },
+ { .s = "start", .f = &live_start },
+ { .s = "stop", .f = &live_stop },
{ .s = "system", .f = &s6system },
{ .s = "version", .f = &version },
} ;
diff --git a/src/s6-frontend/system_boot.c b/src/s6-frontend/system_boot.c
index 73488de..94855ba 100644
--- a/src/s6-frontend/system_boot.c
+++ b/src/s6-frontend/system_boot.c
@@ -90,5 +90,5 @@ void system_boot (char const *const *argv)
strerr_dief1x(100, "timeout must be an unsigned integer (in milliseconds)") ;
}
system_init_spawn(wgola[GOLA_PREFIX]) ;
- exec_live_start_everything(timeout, !!(wgolb & GOLB_DRYRUN), wgola[GOLA_DEFBUNDLE]) ;
+ exec_live_start_everything(timeout, wgola[GOLA_DEFBUNDLE], wgolb & GOLB_DRYRUN) ;
}