Make sure to also reload all .conf files in /etc/finit.d/ when changing runlevel.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-05-31 22:45:30 +02:00
1 parent f5584ecc3c
commit 2c1f3b1f7a
1 file changed
+13 -3
+13 -3
View File
@@ -290,6 +290,10 @@ void svc_runlevel(int newlevel)
_d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel); _d("Setting new runlevel --> %d <-- previous %d", runlevel, prevlevel);
utmp_save(prevlevel, newlevel); utmp_save(prevlevel, newlevel);
/* Make sure to reload all *.conf in /etc/finit.d/ */
svc_mark_dynamic();
parse_finit_d(rcsd);
_d("Stopping services services not allowed in new runlevel ..."); _d("Stopping services services not allowed in new runlevel ...");
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
if (!ISSET(svc->runlevels, runlevel)) { if (!ISSET(svc->runlevels, runlevel)) {
@@ -300,6 +304,10 @@ void svc_runlevel(int newlevel)
#endif #endif
svc_stop(svc); svc_stop(svc);
} }
/* ... or disabled/removed services from /etc/finit.d/ */
if (svc->mtime && svc->dirty != 0)
svc_stop(svc);
} }
/* Prev runlevel services stopped, call hooks before starting new runlevel ... */ /* Prev runlevel services stopped, call hooks before starting new runlevel ... */
@@ -322,6 +330,9 @@ void svc_runlevel(int newlevel)
svc_dance(svc); svc_dance(svc);
} }
/* Cleanup stale services */
svc_cleanup();
if (0 == runlevel) { if (0 == runlevel) {
do_shutdown(SIGUSR2); do_shutdown(SIGUSR2);
return; return;
@@ -935,10 +946,8 @@ void svc_reload_dynamic(void)
_d("Starting enabled/added services ..."); _d("Starting enabled/added services ...");
for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) { for (svc = svc_iterator(1); svc; svc = svc_iterator(0)) {
if (svc->mtime && svc->dirty > 0) { if (svc->mtime && svc->dirty > 0)
svc_dance(svc); svc_dance(svc);
svc->dirty = 0;
}
} }
} }
@@ -957,6 +966,7 @@ void svc_cleanup(void)
svc_stop(svc); svc_stop(svc);
svc_del(svc); svc_del(svc);
} }
svc->dirty = 0;
} }
} }