Touch /etc/nologin when runlevel change comes in

The /etc/nologin file must be set as soon as the runlevel change to
0/1/6 comes in, not when done with runlevel change and services have
been started, if any.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson
2016-09-18 11:24:10 +02:00
parent a94c97221e
commit 2c1e9877f9
+6 -6
View File
@@ -127,6 +127,12 @@ restart:
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
runlevel_set(prevlevel, runlevel);
/* Disable login in single-user mode as well as shutdown/reboot */
if (runlevel == 1 || runlevel == 0 || runlevel == 6)
touch("/etc/nologin");
else
erase("/etc/nologin");
/* Make sure to (re)load all *.conf in /etc/finit.d/ */
conf_reload_dynamic();
@@ -154,12 +160,6 @@ restart:
/* Cleanup stale services */
svc_clean_dynamic(service_unregister);
/* Disable login in single-user mode as well as shutdown/reboot */
if (runlevel == 1 || runlevel == 0 || runlevel == 6)
touch("/etc/nologin");
else
erase("/etc/nologin");
if (0 == runlevel) {
do_shutdown(SHUT_OFF);
sm->state = SM_RUNNING_STATE;