The shutdown, reboot and halt commands can be used to instruct the service
manager daemon to perform a service rollback and then to shutdown the
system. They can also perform shutdown directly, without service rollback.
+
+Note that for consistency with other packages a "halt" alias is provided,
+however it has no special significance.
.\"
.SH OPTIONS
.TP
\fBreboot\fR.
.TP
\fB\-h\fP
-Shutdown and then halt the system. This is the default if executed as
-neither \fBhalt\fR nor \fBreboot\fR.
+Shutdown and then halt the system (without powering down).
.TP
\fB\-p\fP
-Shutdown and then power down the system. This is the default if executed as
-\fBhalt\fR.
+Shutdown and then power down the system. This is the default unless executed
+as \fBreboot\fR.
.TP
\fB\-\-use\-passed\-cfd\fR
Instead of attempting to open a socket connection to the service daemon,
return p.substr(0, spos + 1);
}
+// Find the base name of a path (the name after the final '/').
+inline const char * base_name(const char *path)
+{
+ const char * basen = path;
+ const char * s = path;
+ while (*s != 0) {
+ if (*s == '/') basen = s + 1;
+ s++;
+ }
+ return basen;
+}
+
#endif
#include "control-cmds.h"
#include "service-constants.h"
#include "dinit-client.h"
+#include "dinit-util.h"
#include "dasynq.h"
bool use_passed_cfd = false;
auto shutdown_type = shutdown_type_t::POWEROFF;
+
+ const char *execname = base_name(argv[0]);
+ if (strcmp(execname, "reboot")) {
+ shutdown_type = shutdown_type_t::REBOOT;
+ }
for (int i = 1; i < argc; i++) {
if (argv[i][0] == '-') {
}
if (show_help) {
- cout << "dinit-shutdown : shutdown the system" << endl;
- cout << " --help : show this help" << endl;
- cout << " -r : reboot" << endl;
- cout << " -h : halt system" << endl;
- cout << " -p : power down (default)" << endl;
- cout << " --use-passed-cfd : use the socket file descriptor identified by the DINIT_CS_FD" << endl;
- cout << " environment variable to communicate with the init daemon." << endl;
- cout << " --system : perform shutdown immediately, instead of issuing shutdown" << endl;
- cout << " command to the init program. Not recommended for use" << endl;
- cout << " by users." << endl;
+ cout << execname << " : shutdown the system\n"
+ " --help : show this help\n"
+ " -r : reboot\n"
+ " -h : halt system\n"
+ " -p : power down (default)\n"
+ " --use-passed-cfd : use the socket file descriptor identified by the DINIT_CS_FD\n"
+ " environment variable to communicate with the init daemon.\n"
+ " --system : perform shutdown immediately, instead of issuing shutdown\n"
+ " command to the init program. Not recommended for use\n"
+ " by users.\n";
return 1;
}