Add config option for manually started services

Example:
    service manual:yes [2] /usr/sbin/lighttpd -- HTTP Server

Signed-off-by: Robert Andersson <robert.m.andersson@se.atlascopco.com>
This commit is contained in:
Robert Andersson
2018-10-22 12:51:58 +02:00
parent 423c8d41a7
commit 6a7f115781
2 changed files with 13 additions and 0 deletions
+6
View File
@@ -185,6 +185,12 @@ Syntax
For a detailed description of conditions, and how to debug them, see
the [Finit Conditions](conditions.md) document.
If a service should not be automatically started, it can be configured
as manual with the optional `manual` argument. The service can then be
started at any time by running `initctl start <service>`.
manual:yes
The name of a service, shown by the `initctl` tool, defaults to the
basename of the service executable. It can be changed with the
optional `name` argument:
+7
View File
@@ -672,6 +672,7 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
int forking = 0;
#endif
int levels = 0;
int manual = 0;
char *line;
char *username = NULL, *log = NULL, *pid = NULL;
char *service = NULL, *proto = NULL, *ifaces = NULL;
@@ -736,6 +737,8 @@ int service_register(int type, char *cfg, struct rlimit rlimit[], char *file)
pid = cmd;
else if (!strncasecmp(cmd, "name:", 5))
name = cmd;
else if (!strncasecmp(cmd, "manual:yes", 10))
manual = 1;
else if (cmd[0] != '/' && strchr(cmd, '/'))
service = cmd; /* inetd service/proto */
else
@@ -811,6 +814,10 @@ recreate:
free(line);
return errno = ENOMEM;
}
if (type == SVC_TYPE_SERVICE && manual) {
svc_stop(svc);
}
}
#ifdef INETD_ENABLED
else {