Skip to content

Commit 21f40fb

Browse files
committed
Allow more initctl commands in runlevels S/0/6
Relax the constraints introduced in a39ee0b, for issue #342, a bit on when start/stop/restart/reload service can be called. Also, allow 'initctl reload', but ignore it when the system is in runlevels S/0/6. This makes it possible to start manual:yes type services at botostrap, for example, which has been a common feature request. Signed-off-by: Joachim Wiberg <[email protected]>
1 parent 24f0cee commit 21f40fb

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

src/api.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ static int stop(svc_t *svc, void *user_data)
6868
service_timeout_cancel(svc);
6969
svc_stop(svc);
7070
service_step(svc);
71-
service_step_all(SVC_TYPE_ANY);
71+
if (!IS_RESERVED_RUNLEVEL(runlevel))
72+
service_step_all(SVC_TYPE_ANY);
7273

7374
return 0;
7475
}
@@ -83,7 +84,8 @@ static int start(svc_t *svc, void *user_data)
8384
service_timeout_cancel(svc);
8485
svc_start(svc);
8586
service_step(svc);
86-
service_step_all(SVC_TYPE_ANY);
87+
if (!IS_RESERVED_RUNLEVEL(runlevel))
88+
service_step_all(SVC_TYPE_ANY);
8789

8890
return 0;
8991
}
@@ -391,11 +393,6 @@ static void api_cb(uev_t *w, void *arg, int events)
391393
}
392394

393395
switch (rq.cmd) {
394-
case INIT_CMD_RELOAD:
395-
case INIT_CMD_START_SVC:
396-
case INIT_CMD_RESTART_SVC:
397-
case INIT_CMD_STOP_SVC:
398-
case INIT_CMD_RELOAD_SVC:
399396
case INIT_CMD_REBOOT:
400397
case INIT_CMD_HALT:
401398
case INIT_CMD_POWEROFF:
@@ -453,6 +450,10 @@ static void api_cb(uev_t *w, void *arg, int events)
453450
break;
454451

455452
case INIT_CMD_RELOAD: /* 'init q' and 'initctl reload' */
453+
if (IS_RESERVED_RUNLEVEL(runlevel)) {
454+
warnx("Ignoring reload in runlevel S and 6/0.");
455+
goto done;
456+
}
456457
dbg("reload");
457458
sm_reload();
458459
break;
@@ -576,7 +577,7 @@ static void api_cb(uev_t *w, void *arg, int events)
576577
dbg("Unsupported cmd: %d", rq.cmd);
577578
break;
578579
}
579-
580+
done:
580581
if (result)
581582
rq.cmd = INIT_CMD_NACK;
582583
else

0 commit comments

Comments
 (0)