mirror of
https://github.com/troglobit/finit.git
synced 2026-10-22 11:36:07 +00:00
Add support for a rescue (recovery) mode from kernel cmdline
This patch adds a rescue (revovery) mode to Finit. Simply add `rescue` to the kernel cmdline at boot and the following steps at bootstrap will be skipped: - Load of services/run/task/etc in /etc/finit.conf + /etc/finit.d/*.conf - fsck of filesystems in /etc/fstab - Remount of / to read-write - Mount of all filesystems in /etc/fstab - swapon - A few plugin hooks: - HOOK_ROOTFS_UP - HOOK_MOUNT_ERROR - HOOK_BASEFS_UP - `runparts DIR` - /etc/rc.local Instead of loading /etc/finit.conf and /etc/finit.d/*.conf Finit loads the file /lib/finit/rescue.conf, which can be overridden by the operator if needed. If this file is removed (or lost), Finit falls back to start a simple root shell, without any login. Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
bc149d95fc
commit
ab723d2f31
7 files changed
+58
-23
No files matched your search
+20
@@ -78,6 +78,9 @@ void conf_parse_cmdline(void)
|
||||
/* Catches finit_debug (deprecated), --debug, and debug */
|
||||
if (strstr(tok, "debug"))
|
||||
dbg = 1;
|
||||
|
||||
if (strstr(tok, "rescue") || strstr(tok, "recover"))
|
||||
rescue = 1;
|
||||
}
|
||||
fclose(fp);
|
||||
|
||||
@@ -551,6 +554,19 @@ int conf_reload(void)
|
||||
svc_mark_dynamic();
|
||||
tty_mark();
|
||||
|
||||
if (rescue) {
|
||||
int rc;
|
||||
char line[80] = "tty [12345] @console noclear nologin";
|
||||
|
||||
/* If rescue.conf is missing, fall back to a root shell */
|
||||
rc = parse_conf(RESCUE_CONF);
|
||||
if (rc)
|
||||
tty_register(line, global_rlimit, NULL);
|
||||
|
||||
print(rc, "Entering rescue mode");
|
||||
goto done;
|
||||
}
|
||||
|
||||
/* First, read /etc/finit.conf */
|
||||
parse_conf(FINIT_CONF);
|
||||
|
||||
@@ -795,6 +811,10 @@ int conf_monitor(uev_ctx_t *ctx)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* Skip second run, when called from finit.c in rescue mode */
|
||||
if (ctx && rescue)
|
||||
return 0;
|
||||
|
||||
/*
|
||||
* If only one watcher fails, that's OK. A user may have only
|
||||
* one of /etc/finit.conf or /etc/finit.d in use, and may also
|
||||
|
||||
Reference in new issue
Block a user