Drop confusing splash cmdline and --enable-progress configure option

This patch reverts back to the progress/status behavior of Finit < v3.0
because this is what most users expect, including the maintainer.  The
resulting code and configure script is a lot simpler to understand and
maintain:

- No more --enable-progress or --enable-progress-classic configure
  flags.  Instead a progress_style variable in helpers.c that can
  be changed at compile time for those that really need it.
- No more 'splash' kernel commnand line option.  This turned out to
  be *very* confusing to many users who believed it was some sort of
  graphical splash screen à la Plymouth.

Also, when Finit debug is enabled we now have a global 'debug' flag
which now alo controls if klogctl() should be called to prevent the
kernel logs to the console or not.

Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
Joachim Wiberg committed 2021-02-14 20:11:08 +01:00
1 parent 13a33d345b
commit 35e4e0d073
13 files changed
+55 -130

No files matched your search

-19
View File
@@ -225,25 +225,6 @@ hook into the boot process or respond to various I/O.
For more information, see [doc/plugins.md](doc/plugins.md). For more information, see [doc/plugins.md](doc/plugins.md).
**Progress**
Finit prior to v3.0 showed the progress at boot: plugins and modules
being loaded, run/tasks/services being started, etc. By default Finit
is now silent, but progress can still be enabled at build-time using:
configure --enable-progress
or at boot from the kernel cmdline using the boot parameter `splash`:
```shell
append="init=/sbin/finit splash"
```
For a really nice boot, add `quiet` as well. This silences the output
from the kernel, leaving only warnings and errors. For other kernel
command line parameters, see [doc/build.md](doc/build.md#recovery).
**Automatic Reload** **Automatic Reload**
By default, Finit monitors `/etc/finit.d/` and `/etc/finit.d/enabled/` By default, Finit monitors `/etc/finit.d/` and `/etc/finit.d/enabled/`
-23
View File
@@ -58,14 +58,6 @@ AC_ARG_ENABLE(auto_reload,
AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[ AS_HELP_STRING([--enable-auto-reload], [Automatic reload on any .conf change]),,[
enable_auto_reload=no]) enable_auto_reload=no])
AC_ARG_ENABLE(progress,
AS_HELP_STRING([--enable-progress], [Modern progress display at bootup]),,[
enable_progress=no])
AC_ARG_ENABLE(progress-classic,
AS_HELP_STRING([--enable-progress-classic], [Pre Finit v3 bootup progress and heading]),,[
enable_progress_classic=no])
AC_ARG_ENABLE(watchdog, AC_ARG_ENABLE(watchdog,
AS_HELP_STRING([--enable-watchdog], [Enable built-in watchdog, uses /dev/watchdog]),,[ AS_HELP_STRING([--enable-watchdog], [Enable built-in watchdog, uses /dev/watchdog]),,[
enable_watchdog=no]) enable_watchdog=no])
@@ -141,19 +133,6 @@ AS_IF([test "x$enable_fallback_shell" = "xyes"], [
AS_IF([test "x$enable_auto_reload" = "xyes"], [ AS_IF([test "x$enable_auto_reload" = "xyes"], [
AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])]) AC_DEFINE(AUTO_RELOAD, 1, [Finit automatically does `initctl reload` on any .conf change])])
AS_IF([test "x$enable_progress" = "xyes"], [
AC_DEFINE(PROGRESS_STYLE, 2, [Modern bootup messages, systemd inspired])])
AS_IF([test "x$enable_progress_classic" = "xyes"], [
enable_progress=no
AC_DEFINE(PROGRESS_STYLE, 1, [Pre Finit v3 bootup messages and heading])])
AS_IF([test "x$enable_progress_classic" = "xyes" -o "x$enable_progress" = "xyes"], [
AC_DEFINE(SILENT_MODE, 0, [Display bootup progress, see above for style])
], [
AC_DEFINE(PROGRESS_STYLE, 0, [Default progress style])
AC_DEFINE(SILENT_MODE, 1, [Completely silent until login prompt (default)])])
AS_IF([test "x$enable_watchdog" = "xyes"], [ AS_IF([test "x$enable_watchdog" = "xyes"], [
AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])]) AC_DEFINE(BUILTIN_WATCHDOG, 1, [Enable built-in watchdog, kicks on /dev/watchdog])])
@@ -258,8 +237,6 @@ Optional features:
Scripting tool logit..: $enable_logit Scripting tool logit..: $enable_logit
Emergency shell.......: $enable_emergency_shell Emergency shell.......: $enable_emergency_shell
Fallback shell........: $enable_fallback_shell Fallback shell........: $enable_fallback_shell
Modern progress.......: $enable_progress
Classic progress......: $enable_progress_classic
Default hostname......: $hostname Default hostname......: $hostname
Default runlevel......: $runlevel Default runlevel......: $runlevel
+4 -8
View File
@@ -2,12 +2,11 @@ Tips & Tricks with the kernel cmdline
===================================== =====================================
This document summarizes the different boot parameters that can be This document summarizes the different boot parameters that can be
passed on the Linux kernel command line. Not just limited to Finit. passed on the Linux kernel command line. Not limited to Finit.
* `debug`, or `--debug` * `debug`__
Enable debug mode. The former syntax also enable kernel debug, and Enable kernel debug. Debug messages are printed to the console
the latter only in Finit. Debug messages are printed to the console until Finit starts up, the syslog daemon then empties `/dev/kmsg`
until a syslog daemon has been started.
* `init=/bin/sh` * `init=/bin/sh`
Bypass system default init and tell kernel to start a shell. Note, Bypass system default init and tell kernel to start a shell. Note,
@@ -32,7 +31,4 @@ passed on the Linux kernel command line. Not just limited to Finit.
so a `tty [1] @console nologin` configuration presents you with a so a `tty [1] @console nologin` configuration presents you with a
root console without login. root console without login.
* `splash`
Display Finit splash screen with progress at bootstrap and shutdown.
For more on kernel boot paramaters, see the man page `bootparam(7)`. For more on kernel boot paramaters, see the man page `bootparam(7)`.
+1 -1
View File
@@ -74,7 +74,7 @@ static void setup(void *arg)
path = which("mdev"); path = which("mdev");
if (path) { if (path) {
/* Embedded Linux systems usually have BusyBox mdev */ /* Embedded Linux systems usually have BusyBox mdev */
if (log_is_debug()) if (debug)
touch("/dev/mdev.log"); touch("/dev/mdev.log");
snprintf(cmd, sizeof(cmd), "%s -s", path); snprintf(cmd, sizeof(cmd), "%s -s", path);
+5 -8
View File
@@ -75,20 +75,17 @@ static void hide_args(int argc, char *argv[])
} }
} }
static void parse_arg(char *arg, int *dbg) static void parse_arg(char *arg)
{ {
/* Catches finit_debug (deprecated), --debug, and debug */ /* Catches finit_debug, --debug, and debug */
if (strstr(arg, "debug")) if (strstr(arg, "debug"))
*dbg = 1; debug = 1;
if (string_compare(arg, "rescue") || string_compare(arg, "recover")) if (string_compare(arg, "rescue") || string_compare(arg, "recover"))
rescue = 1; rescue = 1;
if (string_compare(arg, "single") || string_compare(arg, "S")) if (string_compare(arg, "single") || string_compare(arg, "S"))
single = 1; single = 1;
if (string_compare(arg, "splash"))
splash = 1;
} }
void conf_parse_cmdline(int argc, char *argv[]) void conf_parse_cmdline(int argc, char *argv[])
@@ -98,7 +95,7 @@ void conf_parse_cmdline(int argc, char *argv[])
char line[LINE_SIZE], *cmdline, *tok; char line[LINE_SIZE], *cmdline, *tok;
for (int i = 1; i < argc; i++) for (int i = 1; i < argc; i++)
parse_arg(argv[i], &dbg); parse_arg(argv[i]);
hide_args(argc, argv); hide_args(argc, argv);
@@ -116,7 +113,7 @@ void conf_parse_cmdline(int argc, char *argv[])
while ((tok = strtok(cmdline, " \t"))) { while ((tok = strtok(cmdline, " \t"))) {
cmdline = NULL; cmdline = NULL;
parse_arg(tok, &dbg); parse_arg(tok);
} }
fclose(fp); fclose(fp);
+3 -3
View File
@@ -172,7 +172,7 @@ int run_interactive(char *cmd, char *fmt, ...)
/* Redirect output from cmd to a tempfile */ /* Redirect output from cmd to a tempfile */
fp = tempfile(); fp = tempfile();
if (fp && !log_is_debug()) { if (fp && !debug) {
oldout = dup(STDOUT_FILENO); oldout = dup(STDOUT_FILENO);
olderr = dup(STDERR_FILENO); olderr = dup(STDERR_FILENO);
dup2(fileno(fp), STDOUT_FILENO); dup2(fileno(fp), STDOUT_FILENO);
@@ -183,7 +183,7 @@ int run_interactive(char *cmd, char *fmt, ...)
status = run(cmd); status = run(cmd);
/* Restore stderr/stdout */ /* Restore stderr/stdout */
if (fp && !log_is_debug()) { if (fp && !debug) {
if (oldout >= 0) { if (oldout >= 0) {
dup2(oldout, STDOUT_FILENO); dup2(oldout, STDOUT_FILENO);
close(oldout); close(oldout);
@@ -198,7 +198,7 @@ int run_interactive(char *cmd, char *fmt, ...)
print_result(status); print_result(status);
/* Dump any results of cmd on stderr after we've printed [ OK ] or [FAIL] */ /* Dump any results of cmd on stderr after we've printed [ OK ] or [FAIL] */
if (fp && !log_is_debug()) { if (fp && !debug) {
size_t len, written; size_t len, written;
rewind(fp); rewind(fp);
+9 -9
View File
@@ -55,9 +55,9 @@
int runlevel = 0; /* Bootstrap 'S' */ int runlevel = 0; /* Bootstrap 'S' */
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */ int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
int prevlevel = -1; int prevlevel = -1;
int debug = 0; /* debug mode from kernel cmdline */
int rescue = 0; /* rescue mode from kernel cmdline */ int rescue = 0; /* rescue mode from kernel cmdline */
int single = 0; /* single user mode from kernel cmdline */ int single = 0; /* single user mode from kernel cmdline */
int splash = 0; /* splash + progress enabled on kernel cmdline */
char *sdown = NULL; char *sdown = NULL;
char *network = NULL; char *network = NULL;
char *hostname = NULL; char *hostname = NULL;
@@ -78,7 +78,8 @@ static void banner(void)
* similar enabled to start emptying /dev/kmsg, but for * similar enabled to start emptying /dev/kmsg, but for
* our progress we want to own the console. * our progress we want to own the console.
*/ */
klogctl(6, NULL, 0); if (!debug)
klogctl(6, NULL, 0);
/* /*
* First level hooks, if you want to run here, you're * First level hooks, if you want to run here, you're
@@ -86,9 +87,6 @@ static void banner(void)
*/ */
plugin_run_hooks(HOOK_BANNER); plugin_run_hooks(HOOK_BANNER);
if (log_is_silent())
return;
print_banner(INIT_HEADING); print_banner(INIT_HEADING);
} }
@@ -310,8 +308,10 @@ static void finalize(void)
service_step_all(SVC_TYPE_ANY); service_step_all(SVC_TYPE_ANY);
/* Enable silent mode before starting TTYs */ /* Enable silent mode before starting TTYs */
_d("Going silent ..."); if (!debug) {
log_silent(); _d("Going silent ...");
show_progress(0);
}
/* Delayed start of TTYs at bootstrap */ /* Delayed start of TTYs at bootstrap */
_d("Launching all getty services ..."); _d("Launching all getty services ...");
@@ -381,7 +381,7 @@ int main(int argc, char *argv[])
fs_init(); fs_init();
/* /*
* Parse /proc/cmdline (debug, rescue, splash, console=, etc.) * Parse /proc/cmdline (debug, rescue, console=, etc.)
* Also calls log_init() to set correct log level * Also calls log_init() to set correct log level
*/ */
conf_parse_cmdline(argc, argv); conf_parse_cmdline(argc, argv);
@@ -407,7 +407,7 @@ int main(int argc, char *argv[])
umask(0); umask(0);
/* Set up canvas */ /* Set up canvas */
if (!rescue && !log_is_debug()) if (!rescue && !debug)
screen_init(); screen_init();
/* /*
+1 -1
View File
@@ -92,9 +92,9 @@ struct init_request {
extern int runlevel; extern int runlevel;
extern int cfglevel; extern int cfglevel;
extern int prevlevel; extern int prevlevel;
extern int debug;
extern int rescue; extern int rescue;
extern int single; extern int single;
extern int splash;
extern char *rcsd; extern char *rcsd;
extern char *sdown; extern char *sdown;
extern char *network; extern char *network;
+26 -7
View File
@@ -39,7 +39,14 @@
#include "util.h" #include "util.h"
#include "utmp-api.h" #include "utmp-api.h"
static int progress_style = PROGRESS_STYLE; typedef enum {
PROGRESS_SILENT,
PROGRESS_CLASSIC,
PROGRESS_MODERN,
} pstyle_t;
#define PROGRESS_DEFAULT PROGRESS_MODERN
static pstyle_t progress_style = PROGRESS_DEFAULT;
#ifndef HOSTNAME_PATH #ifndef HOSTNAME_PATH
#define HOSTNAME_PATH "/etc/hostname" #define HOSTNAME_PATH "/etc/hostname"
@@ -182,6 +189,14 @@ char *strip_line(char *line)
return line; return line;
} }
void show_progress(int onoff)
{
if (onoff)
progress_style = PROGRESS_DEFAULT;
else
progress_style = PROGRESS_SILENT;
}
/* /*
* Return screen length of string, not counting escape chars, and * Return screen length of string, not counting escape chars, and
* accounting for unicode characters as only one screen byte wide * accounting for unicode characters as only one screen byte wide
@@ -234,9 +249,13 @@ void print_banner(const char *heading)
{ {
char buf[4 * SCREEN_WIDTH]; char buf[4 * SCREEN_WIDTH];
if (progress_style == PROGRESS_SILENT)
return;
memset(buf, 0, sizeof(buf)); memset(buf, 0, sizeof(buf));
strlcat(buf, "\r\e[2K", sizeof(buf)); strlcat(buf, "\r\e[2K", sizeof(buf));
if (progress_style == 1) {
if (progress_style == PROGRESS_CLASSIC) {
strlcat(buf, "\e[1m", sizeof(buf)); strlcat(buf, "\e[1m", sizeof(buf));
strlcat(buf, heading, sizeof(buf)); strlcat(buf, heading, sizeof(buf));
pad(buf, sizeof(buf), "=", SCREEN_WIDTH - 2); pad(buf, sizeof(buf), "=", SCREEN_WIDTH - 2);
@@ -289,7 +308,7 @@ static char *status(int rc)
if (rc < 0 || rc >= (int)NELEMS(status1)) if (rc < 0 || rc >= (int)NELEMS(status1))
rc = NELEMS(status1) - 1; /* Default to "⋯" (pending) */ rc = NELEMS(status1) - 1; /* Default to "⋯" (pending) */
if (progress_style == 1) { if (progress_style == PROGRESS_CLASSIC) {
int hl = 1; int hl = 1;
if (rc == 1 || rc == 2) if (rc == 1 || rc == 2)
@@ -307,7 +326,7 @@ void printv(const char *fmt, va_list ap)
char buf[SCREEN_WIDTH]; char buf[SCREEN_WIDTH];
size_t len; size_t len;
if (!fmt || log_is_silent()) if (!fmt || progress_style == PROGRESS_SILENT)
return; return;
delline(); delline();
@@ -316,7 +335,7 @@ void printv(const char *fmt, va_list ap)
len = print_timestamp(buf, sizeof(buf)); len = print_timestamp(buf, sizeof(buf));
vsnprintf(&buf[len], sizeof(buf) - len, fmt, ap); vsnprintf(&buf[len], sizeof(buf) - len, fmt, ap);
if (progress_style == 1) if (progress_style == PROGRESS_CLASSIC)
cprintf("\r%s ", pad(buf, sizeof(buf), ".", sizeof(buf))); cprintf("\r%s ", pad(buf, sizeof(buf), ".", sizeof(buf)));
else else
cprintf("\r\e[2K%s%s", status(3), buf); cprintf("\r\e[2K%s%s", status(3), buf);
@@ -324,7 +343,7 @@ void printv(const char *fmt, va_list ap)
void print(int rc, const char *fmt, ...) void print(int rc, const char *fmt, ...)
{ {
if (log_is_silent()) if (progress_style == PROGRESS_SILENT)
return; return;
if (fmt) { if (fmt) {
@@ -338,7 +357,7 @@ void print(int rc, const char *fmt, ...)
if (rc < 0) if (rc < 0)
return; return;
if (progress_style == 1) if (progress_style == PROGRESS_CLASSIC)
cprintf("%s\n", status(rc)); cprintf("%s\n", status(rc));
else else
cprintf("\r%s\n", status(rc)); cprintf("\r%s\n", status(rc));
+1
View File
@@ -55,6 +55,7 @@ void console_init (void);
ssize_t cprintf (const char *fmt, ...); ssize_t cprintf (const char *fmt, ...);
char *strip_line (char *line); char *strip_line (char *line);
void show_progress (int onoff);
int getty (char *tty, speed_t speed, char *term, char *user); int getty (char *tty, speed_t speed, char *term, char *user);
int sh (char *tty); int sh (char *tty);
+3 -45
View File
@@ -28,43 +28,24 @@
#include <lite/lite.h> #include <lite/lite.h>
#include "finit.h" #include "finit.h"
#include "helpers.h"
#include "log.h" #include "log.h"
#include "util.h" #include "util.h"
static int up = 0; static int up = 0;
static int debug = 0;
static int silent = SILENT_MODE; /* Completely silent, including boot */
static int loglevel = LOG_NOTICE; static int loglevel = LOG_NOTICE;
static void muffler(void)
{
silent = SILENT_MODE;
/* User override from kernel cmdline */
if (splash)
silent = 0;
}
void log_init(int dbg) void log_init(int dbg)
{ {
if (dbg)
debug = 1;
if (debug) if (debug)
loglevel = LOG_DEBUG; loglevel = LOG_DEBUG;
else else
loglevel = LOG_NOTICE; loglevel = LOG_NOTICE;
muffler();
} }
/* If we enabled terse mode at boot, restore to previous setting at shutdown */ /* If we enabled terse mode at boot, restore to previous setting at shutdown */
void log_exit(void) void log_exit(void)
{ {
muffler();
if (!silent)
sched_yield();
/* /*
* Unless in debug mode at shutdown, Reinitialize screen, * Unless in debug mode at shutdown, Reinitialize screen,
* terminal may have been resized at runtime * terminal may have been resized at runtime
@@ -73,6 +54,8 @@ void log_exit(void)
screen_exit(); screen_exit();
else else
screen_init(); screen_init();
show_progress(1);
} }
void log_open(void) void log_open(void)
@@ -89,48 +72,23 @@ void log_open(void)
up = 1; up = 1;
} }
void log_silent(void)
{
if (debug)
silent = 0;
else
silent = 1;
}
int log_is_silent(void)
{
return silent;
}
/* Toggle debug mode */ /* Toggle debug mode */
void log_debug(void) void log_debug(void)
{ {
debug = !debug; debug = !debug;
if (debug) { if (debug) {
silent = 0;
loglevel = LOG_DEBUG; loglevel = LOG_DEBUG;
screen_exit(); screen_exit();
} else { } else {
silent = SILENT_MODE;
loglevel = LOG_NOTICE; loglevel = LOG_NOTICE;
screen_init(); screen_init();
} }
log_open(); log_open();
/* Also toggle silent mode (progress) */
log_silent();
logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled"); logit(LOG_NOTICE, "Debug mode %s", debug ? "enabled" : "disabled");
} }
int log_is_debug(void)
{
return debug;
}
/* /*
* Log to /dev/kmsg until syslogd has started, then openlog() * Log to /dev/kmsg until syslogd has started, then openlog()
* and continue logging as a regular daemon. * and continue logging as a regular daemon.
-4
View File
@@ -48,11 +48,7 @@
void log_init (int dbg); void log_init (int dbg);
void log_exit (void); void log_exit (void);
void log_silent (void);
int log_is_silent (void);
void log_debug (void); void log_debug (void);
int log_is_debug (void);
void logit (int prio, const char *fmt, ...); void logit (int prio, const char *fmt, ...);
+2 -2
View File
@@ -256,7 +256,7 @@ static int redirect(svc_t *svc)
return fredirect(console()); return fredirect(console());
return lredirect(svc); return lredirect(svc);
} else if (log_is_debug()) } else if (debug)
return fredirect(console()); return fredirect(console());
#ifdef REDIRECT_OUTPUT #ifdef REDIRECT_OUTPUT
else else
@@ -393,7 +393,7 @@ static int service_start(svc_t *svc)
status = execvp(svc->cmd, args); status = execvp(svc->cmd, args);
_exit(status); _exit(status);
} else if (log_is_debug()) { } else if (debug) {
char buf[CMD_SIZE] = ""; char buf[CMD_SIZE] = "";
for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++) { for (i = 0; i < (MAX_NUM_SVC_ARGS - 1) && svc->args[i][0] != 0; i++) {