.SH SYNOPSIS
.\"
.B dinitctl
-[\fB\-s\fR] [\fB\-\-quiet\fR] \fBstart\fR [\fB\-\-no\-wait\fR] [\fB\-\-pin\fR] \fIservice-name\fR
+[\fIoptions\fR] \fBstart\fR [\fB\-\-no\-wait\fR] [\fB\-\-pin\fR] \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] [\fB\-\-quiet\fR] \fBstop\fR [\fB\-\-no\-wait\fR] [\fB\-\-pin\fR] \fIservice-name\fR
+[\fIoptions\fR] \fBstop\fR [\fB\-\-no\-wait\fR] [\fB\-\-pin\fR] \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] [\fB\-\-quiet\fR] \fBwake\fR [\fB\-\-no\-wait\fR] \fIservice-name\fR
+[\fIoptions\fR] \fBwake\fR [\fB\-\-no\-wait\fR] \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] [\fB\-\-quiet\fR] \fBrelease\fR \fIservice-name\fR
+[\fIoptions\fR] \fBrelease\fR \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] [\fB\-\-quiet\fR] \fBunpin\fR \fIservice-name\fR
+[\fIoptions\fR] \fBunpin\fR \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBunload\fR \fIservice-name\fR
+[\fIoptions\fR] \fBunload\fR \fIservice-name\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBlist\fR
+[\fIoptions\fR] \fBlist\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBshutdown\fR
+[\fIoptions\fR] \fBshutdown\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBadd-dep\fR \fIdependency-type\fR \fIfrom-service\fR \fIto-service\fR
+[\fIoptions\fR] \fBadd-dep\fR \fIdependency-type\fR \fIfrom-service\fR \fIto-service\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBrm-dep\fR \fIdependency-type\fR \fIfrom-service\fR \fIto-service\fR
+[\fIoptions\fR] \fBrm-dep\fR \fIdependency-type\fR \fIfrom-service\fR \fIto-service\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBenable\fR [\fB\-\-from\fR \fIfrom-service\fR] \fIto-service\fR
+[\fIoptions\fR] \fBenable\fR [\fB\-\-from\fR \fIfrom-service\fR] \fIto-service\fR
.br
.B dinitctl
-[\fB\-s\fR] \fBdisable\fR [\fB\-\-from\fR \fIfrom-service\fR] \fIto-service\fR
+[\fIoptions\fR] \fBdisable\fR [\fB\-\-from\fR \fIfrom-service\fR] \fIto-service\fR
.\"
.SH DESCRIPTION
.\"
\fBdinit\fR daemon. It allows starting and stopping services, and listing
service status.
.\"
-.SH OPTIONS
+.SH GENERAL OPTIONS
.TP
\fB\-\-help\fR
display this help and exit
.TP
+\fB\-s\fR, \fB\-\-system\fR
+Control the system init process. The default is to control the user process. This option selects
+the path to the control socket used to communicate with the \fBdinit\fR daemon process.
+.TP
+\fB\-\-socket\-path\fR \fIsocket-path\fR, \fB\-p\fR \fIsocket-path\fR
+Specify the path to the socket used for communicating with the service manager daemon.
+.TP
+\fB\-\-quiet\fR
+Suppress status output, except for errors.
+.\"
+.SH COMMAND OPTIONS
+.TP
\fB\-\-no\-wait\fR
Do not wait for issued command to complete; exit immediately.
.TP
Pin the service in the requested state. The service will not leave the state until it is unpinned, although
start/stop commands will be "remembered" while the service is pinned.
.TP
-\fB\-s\fR, \fB\-\-system\fR
-Control the system init process. The default is to control the user process. This option selects
-the path to the control socket used to communicate with the \fBdinit\fR daemon process.
-.TP
\fIservice-name\fR
Specifies the name of the service to which the command applies.
.TP
else if (strcmp(argv[i], "--pin") == 0) {
do_pin = true;
}
+ else if (strcmp(argv[i], "--socket-path") || strcmp(argv[i], "-p")) {
+ ++i;
+ if (i == argc) {
+ cerr << "dinitctl: --socket-path/-p should be followed by socket path" << std::endl;
+ return 1;
+ }
+ control_socket_str = argv[i];
+ }
else if ((command == command_t::ENABLE_SERVICE || command == command_t::DISABLE_SERVICE)
&& strcmp(argv[i], "--from") == 0) {
++i;
"General options:\n"
" -s, --system : control system daemon instead of user daemon\n"
" --quiet : suppress output (except errors)\n"
+ " --socket-path <path>, -p <path>\n"
+ " : specify socket for communication with daemon\n"
"\n"
"Command options:\n"
" --help : show this help\n"
signal(SIGPIPE, SIG_IGN);
- control_socket_path = SYSCONTROLSOCKET;
-
// Locate control socket
- if (! sys_dinit) {
- char * userhome = getenv("HOME");
- if (userhome == nullptr) {
- struct passwd * pwuid_p = getpwuid(getuid());
- if (pwuid_p != nullptr) {
- userhome = pwuid_p->pw_dir;
+ if (! control_socket_str.empty()) {
+ control_socket_path = control_socket_str.c_str();
+ }
+ else {
+ control_socket_path = SYSCONTROLSOCKET; // default to system
+ if (! sys_dinit) {
+ char * userhome = getenv("HOME");
+ if (userhome == nullptr) {
+ struct passwd * pwuid_p = getpwuid(getuid());
+ if (pwuid_p != nullptr) {
+ userhome = pwuid_p->pw_dir;
+ }
+ }
+
+ if (userhome != nullptr) {
+ control_socket_str = userhome;
+ control_socket_str += "/.dinitctl";
+ control_socket_path = control_socket_str.c_str();
+ }
+ else {
+ cerr << "Cannot locate user home directory (set HOME or check /etc/passwd file)" << endl;
+ return 1;
}
- }
-
- if (userhome != nullptr) {
- control_socket_str = userhome;
- control_socket_str += "/.dinitctl";
- control_socket_path = control_socket_str.c_str();
- }
- else {
- cerr << "Cannot locate user home directory (set HOME or check /etc/passwd file)" << endl;
- return 1;
}
}