Replace verbose and kernel quiet modes with silent and quiet

This patch replaces the verbose and kernel-quiet runtime options with
a (hopefully) more useful quiet and silent modes of operation.

By default Finit progressively shows all services it starts at boot, but
when boot has completed and services are started/restarted Finit prints
nothing.  If `--disable-quiet` is given all started/restared/stoppping
messages are shown even after boot.

However, if `--enable-silent` is given Finit is completely silent even
at boot, no progress is shown, until the first service is started, which
on most systems is login.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-04-11 00:50:37 +02:00
parent c4af8b7cbd
commit 1f1c2e0466
12 changed files with 43 additions and 43 deletions
+2 -2
View File
@@ -285,9 +285,9 @@ static void cb(uev_t *w, void *UNUSED(arg), int UNUSED(events))
case INIT_CMD_DEBUG:
debug = !debug;
if (debug)
verbose = 1;
silent = 0;
else
verbose = quiet ? 0 : VERBOSE_MODE;
silent = quiet ? 1 : SILENT_MODE;
break;
case INIT_CMD_RELOAD: /* 'init q' and 'initctl reload' */
+1 -1
View File
@@ -84,7 +84,7 @@ int client(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
verbose = 0;
silent = 1;
while ((c = getopt_long(argc, argv, "h?v", long_options, NULL)) != EOF) {
switch(c) {
case 'v':
+5 -6
View File
@@ -62,18 +62,17 @@ void conf_parse_cmdline(void)
FILE *fp;
char line[LINE_SIZE];
if ((fp = fopen("/proc/cmdline", "r")) != NULL) {
fp = fopen("/proc/cmdline", "r");
if (fp) {
fgets(line, sizeof(line), fp);
_d("Kernel command line: %s", line);
if (strstr(line, "finit_debug") || strstr(line, "--debug"))
debug = 1;
#ifdef KERNEL_QUIET
if (!debug && strstr(line, "quiet"))
quiet = 1;
else
quiet = 0;
#endif
fclose(fp);
}
}
@@ -360,7 +359,7 @@ static int parse_conf(char *file)
strcat(line, " ");
}
if (verbose)
if (!silent)
print(0, "Loading %sconfiguration", line);
while (!feof(fp)) {
if (!fgets(line, sizeof(line), fp))
+10 -10
View File
@@ -47,14 +47,14 @@ AC_ARG_ENABLE(embedded,
AC_ARG_ENABLE(rw-rootfs,
AS_HELP_STRING([--enable-rw-rootfs], [Remount / as read-write at boot, not for embedded]))
AC_ARG_ENABLE(quiet,
AS_HELP_STRING([--enable-quiet], [Quiet mode, reduce screen output to absolute minimum]))
AC_ARG_ENABLE(silent,
AS_HELP_STRING([--enable-silent], [Completely silent operation, not even boot messages]))
AC_ARG_ENABLE(inetd,
AS_HELP_STRING([--disable-inetd], [Disable built-in inetd super server, default enabled]))
AC_ARG_ENABLE(kernel-quiet,
AS_HELP_STRING([--disable-kernel-quiet], [Disable kernel cmdline quiet, default enabled]))
AC_ARG_ENABLE(quiet,
AS_HELP_STRING([--disable-quiet], [Disable quiet mode, default: silent after boot]))
AC_ARG_WITH(fifo,
AS_HELP_STRING([--with-fifo=FIFO], [Old Finit initctl FIFO, default /dev/initctl]),
@@ -128,19 +128,19 @@ AS_IF([test "x$enable_embedded" = "xyes"],[
AS_IF([test "x$enable_rw-rootfs" = "xyes"],[
AC_DEFINE(REMOUNT_ROOTFS, 1, [Remount / as rw at boot])])
AS_IF([test "x$enable_quiet" = "xyes"],[
AC_DEFINE(VERBOSE_MODE, 0, [Quiet Finit])
AS_IF([test "x$enable_silent" = "xyes"],[
AC_DEFINE(SILENT_MODE, 1, [Completely silent operation, not even boot messages])
],[
AC_DEFINE(VERBOSE_MODE, 1, [Verbose output, default])])
AC_DEFINE(SILENT_MODE, 0, [Normal output, default])])
### Disable features ###########################################################################
AS_IF([test "x$enable_inetd" != "xno"],enable_inetd="yes",[
AC_DEFINE(INETD_DISABLED, 1, [Disable built-in inetd])])
AS_IF([test "x$enable_kernel-quiet" != "xno"],[
AC_DEFINE(KERNEL_QUIET, 0, [Will print stopping/starting/etc messages])
AS_IF([test "x$enable_quiet" != "xno"],[
AC_DEFINE(QUIET_MODE, 0, [Will print stopping/starting/etc messages at runtime])
],[
AC_DEFINE(KERNEL_QUIET, 1, [Silent after initial boot, default])
AC_DEFINE(QUIET_MODE, 1, [Silent at runtime, after initial boot, default])
])
### With features ##############################################################################
+2 -2
View File
@@ -172,7 +172,7 @@ int run_interactive(char *cmd, char *fmt, ...)
return 1;
}
if (verbose && fmt) {
if (!silent && fmt) {
va_start(ap, fmt);
vsnprintf(line, sizeof(line), fmt, ap);
va_end(ap);
@@ -204,7 +204,7 @@ int run_interactive(char *cmd, char *fmt, ...)
}
}
if (verbose && fmt)
if (!silent && fmt)
print_result(status);
/* Dump any results of cmd on stderr after we've printed [ OK ] or [FAIL] */
+5 -5
View File
@@ -41,8 +41,8 @@
#include "inetd.h"
int debug = 0;
int quiet = KERNEL_QUIET; /* Delayed disable of verbose mode. */
int verbose = VERBOSE_MODE;
int quiet = QUIET_MODE; /* Delayed disable of silent mode. */
int silent = SILENT_MODE; /* Completely silent, including boot */
int runlevel = 0; /* Bootstrap 'S' */
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
int prevlevel = -1;
@@ -61,7 +61,7 @@ static int banner(void)
char buf[42] = INIT_HEADING;
const char separator[] = "========================================================================";
if (!verbose)
if (silent)
return 0;
fprintf(stderr, "\e[2K\e[1m%s %.*s\e[0m\n", buf, 66 - (int)strlen(buf), separator);
@@ -217,9 +217,9 @@ int main(int argc, char* argv[])
/* Start TTYs */
tty_runlevel(runlevel);
/* Disable verbose mode, if selected */
/* Enable silent mode, if selected */
if (quiet && !debug)
verbose = 0;
silent = 1;
/* Start new initctl API responder */
api_init(&loop);
+1 -1
View File
@@ -66,7 +66,7 @@ struct init_request {
extern int debug;
extern int quiet;
extern int verbose;
extern int silent;
extern int runlevel;
extern int cfglevel;
extern int prevlevel;
+1 -1
View File
@@ -142,7 +142,7 @@ void print(int action, const char *fmt, ...)
const char pending[] = " \e[1m[ \\/ ]\e[0m\n";
const char dots[] = " .....................................................................";
if (!verbose)
if (silent)
return;
if (fmt) {
+2 -1
View File
@@ -42,6 +42,7 @@ typedef struct {
int debug = 0;
int verbose = 0;
int silent = 1; /* For helpers.c */
int runlevel = 0;
static int do_send(struct init_request *rq, ssize_t len)
@@ -349,7 +350,6 @@ int main(int argc, char *argv[])
{NULL, 0, NULL, 0}
};
verbose = 0;
while ((c = getopt_long(argc, argv, "dh?v", long_options, NULL)) != EOF) {
switch(c) {
case 'h':
@@ -365,6 +365,7 @@ int main(int argc, char *argv[])
break;
}
}
silent = !verbose;
if (optind < argc) {
char *cmd = argv[optind++];
+3 -3
View File
@@ -304,7 +304,7 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
DIR *dp = opendir(path);
struct dirent *entry;
if (verbose)
if (!silent)
print_desc("Loading plugins", NULL);
if (!dp) {
_e("Failed, cannot open plugin directory %s: %s", path, strerror(errno));
@@ -326,7 +326,7 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
closedir(dp);
#else
_d("Finit built statically, not loading plugins from %s ...", path);
if (verbose)
if (!silent)
print_desc("Initializing plugins", NULL);
#endif /* ENABLE_STATIC */
@@ -336,7 +336,7 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
#ifndef ENABLE_STATIC
exit:
#endif
if (verbose)
if (!silent)
print_result(fail);
return fail;
+9 -9
View File
@@ -121,7 +121,7 @@ static int service_start(svc_t *svc)
/* Don't try and start service if it doesn't exist. */
if (!fexist(svc->cmd) && !svc->inetd.cmd) {
if (verbose) {
if (!silent) {
char msg[80];
snprintf(msg, sizeof(msg), "Service %s does not exist!", svc->cmd);
@@ -137,7 +137,7 @@ static int service_start(svc_t *svc)
if (is_norespawn())
return 1;
if (verbose) {
if (!silent) {
if (svc_is_daemon(svc) || svc_is_inetd(svc))
print_desc("Starting ", svc->desc);
else
@@ -147,7 +147,7 @@ static int service_start(svc_t *svc)
#ifndef INETD_DISABLED
if (svc_is_inetd(svc)) {
result = inetd_start(&svc->inetd);
if (verbose)
if (!silent)
print_result(result);
return result;
}
@@ -258,7 +258,7 @@ static int service_start(svc_t *svc)
svc->pid = 0;
}
if (verbose)
if (!silent)
print_result(result);
return 0;
@@ -280,7 +280,7 @@ static int service_stop(svc_t *svc)
#ifndef INETD_DISABLED
if (svc_is_inetd(svc)) {
int do_print = runlevel != 1 && verbose &&
int do_print = runlevel != 1 && !silent &&
svc->block != SVC_BLOCK_INETD_BUSY;
if (do_print)
@@ -302,13 +302,13 @@ static int service_stop(svc_t *svc)
if (SVC_TYPE_SERVICE != svc->type)
return 0;
if (runlevel != 1 && verbose)
if (runlevel != 1 && !silent)
print_desc("Stopping ", svc->desc);
_d("Sending SIGTERM to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0));
res = kill(svc->pid, SIGTERM);
if (runlevel != 1 && verbose)
if (runlevel != 1 && !silent)
print_result(res);
return res;
@@ -341,7 +341,7 @@ static int service_restart(svc_t *svc)
return 1;
}
if (verbose)
if (!silent)
print_desc("Restarting ", svc->desc);
/* Declare we're waiting for svc to re-assert/touch its pidfile */
@@ -350,7 +350,7 @@ static int service_restart(svc_t *svc)
_d("Sending SIGHUP to PID %d", svc->pid);
err = kill(svc->pid, SIGHUP);
if (verbose)
if (!silent)
print_result(err);
return err;
}
+2 -2
View File
@@ -68,8 +68,8 @@ void do_shutdown(int sig)
/* If we enabled terse mode at boot, restore to previous setting at shutdown */
if (quiet) {
verbose = VERBOSE_MODE;
if (verbose) {
silent = SILENT_MODE;
if (!silent) {
sched_yield();
fputs("\n", stderr);
}