aboutsummaryrefslogtreecommitdiff
path: root/src/rc/openrc-shutdown.c
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-04-12 17:56:30 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-04-12 17:56:36 -0500
commit05738bfce120114037d4f02c67ec740813f94b89 (patch)
tree20e6670fb45dcb5bb8ad70d28a301dbd57ab2351 /src/rc/openrc-shutdown.c
parent6f88ee4ec6f59e545346a7422facc3e5b6adac04 (diff)
init: add re-exec capability
This will allow the re-execution of the init process after upgrading OpenRC.
Diffstat (limited to 'src/rc/openrc-shutdown.c')
-rw-r--r--src/rc/openrc-shutdown.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c
index 978e8a68..8905d354 100644
--- a/src/rc/openrc-shutdown.c
+++ b/src/rc/openrc-shutdown.c
@@ -35,11 +35,12 @@
const char *applet = NULL;
const char *extraopts = NULL;
-const char *getoptstring = "kpr" getoptstring_COMMON;
+const char *getoptstring = "HkpRr" getoptstring_COMMON;
const struct option longopts[] = {
{ "halt", no_argument, NULL, 'H'},
{ "kexec", no_argument, NULL, 'k'},
{ "poweroff", no_argument, NULL, 'p'},
+ { "reexec", no_argument, NULL, 'R'},
{ "reboot", no_argument, NULL, 'r'},
longopts_COMMON
};
@@ -47,11 +48,13 @@ const char * const longopts_help[] = {
"halt the system",
"reboot the system using kexec",
"power off the system",
+ "re-execute init (use after upgrading)",
"reboot the system",
longopts_help_COMMON
};
const char *usagestring = NULL;
-const char *exclusive = "Select one of --halt, --kexec, --poweroff or --reboot";
+const char *exclusive = "Select one of "
+"--halt, --kexec, --poweroff, --reexec or --reboot";
static void send_cmd(const char *cmd)
{
@@ -79,6 +82,7 @@ int main(int argc, char **argv)
bool do_kexec = false;
bool do_poweroff = false;
bool do_reboot = false;
+ bool do_reexec = false;
applet = basename_c(argv[0]);
if (geteuid() != 0)
@@ -99,6 +103,10 @@ if (geteuid() != 0)
do_poweroff = true;
cmd_count++;
break;
+ case 'R':
+ do_reexec = true;
+ cmd_count++;
+ break;
case 'r':
do_reboot = true;
cmd_count++;
@@ -118,5 +126,7 @@ if (geteuid() != 0)
send_cmd("poweroff");
else if (do_reboot)
send_cmd("reboot");
+ else if (do_reexec)
+ send_cmd("reexec");
return 0;
}