diff --git a/docs/config.md b/docs/config.md index b8c3e16e..6be0037a 100644 --- a/docs/config.md +++ b/docs/config.md @@ -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 `. + + 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: diff --git a/src/service.c b/src/service.c index a471a245..290abf0f 100644 --- a/src/service.c +++ b/src/service.c @@ -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 {