Browse Source

Add --system-mgr option to run as system mgr if not PID 1

This is complementary to the --container option which does the opposite.
Davin McCall 4 years ago
parent
commit
c48ad26470
2 changed files with 12 additions and 0 deletions
  1. 8 0
      doc/manpages/dinit.8.m4
  2. 4 0
      src/dinit.cc

+ 8 - 0
doc/manpages/dinit.8.m4

@@ -68,6 +68,14 @@ Run as the system service manager. This is the default if invoked as the root
 user. This option affects the default service definition directory and control
 socket path.
 .TP
+\fB\-m\fR, \fB\-\-system\-mgr\fR
+Run as the system manager (perform operations directly related to machine startup
+and shutdown). This is the default when running as process ID 1. The main user-visible
+effect of this option is to invoke the \fBshutdown\fR program when a shutdown is
+requested (and after all services have stopped), and to provide some basic support
+for system recovery in case the \fBboot\fR service (or other specified service)
+cannot be started.
+.TP
 \fB\-u\fR, \fB\-\-user\fR
 Run as a user. This is the opposite of \fB\-\-system\fR, and is the default if
 not invoked as the root user.

+ 4 - 0
src/dinit.cc

@@ -225,6 +225,9 @@ int dinit_main(int argc, char **argv)
                 else if (strcmp(argv[i], "--system") == 0 || strcmp(argv[i], "-s") == 0) {
                     am_system_init = true;
                 }
+                else if (strcmp(argv[i], "--system-mgr") == 0 || strcmp(argv[i], "-m") == 0) {
+                    am_system_mgr = true;
+                }
                 else if (strcmp(argv[i], "--user") == 0 || strcmp(argv[i], "-u") == 0) {
                     am_system_init = false;
                 }
@@ -265,6 +268,7 @@ int dinit_main(int argc, char **argv)
                             "                              set base directory for service description\n"
                             "                              files\n"
                             " --system, -s                 run as the system service manager\n"
+                            " --system-mgr, -m             run as system manager (perform shutdown etc)\n"
                             " --user, -u                   run as a user service manager\n"
                             " --container, -o              run in container mode (do not manage system)\n"
                             " --socket-path <path>, -p <path>\n"