mirror of
https://github.com/troglobit/finit.git
synced 2026-10-15 10:29:35 +00:00
Fix #352: separate runlevel S from runlevel 0
Due to an old design decision runlevel S was encoded internally as '0', meaning it was the same as halt/poweroff. If you want to run scripts at system shutdown this was less then ideal since it meant your scripts also ran at bootstrap. This change is quite invasive. It introduces INIT_LEVEL (10) as the value for runlevel S, meaning all code that parses and/or evaluates anything for runlevel 0/S was affected and had to be reworked. Signed-off-by: Joachim Wiberg <troglobit@gmail.com>
This commit is contained in:
1 parent
80191f2fd5
commit
e00fda5dc3
12 files changed
+67
-47
No files matched your search
+24
-10
@@ -761,17 +761,18 @@ static int plugins_list(char *arg)
|
||||
char *runlevel_string(int currlevel, int levels)
|
||||
{
|
||||
static char lvl[21];
|
||||
int i, pos = 1;
|
||||
int i = INIT_LEVEL;
|
||||
int pos = 1;
|
||||
|
||||
memset(lvl, 0, sizeof(lvl));
|
||||
lvl[0] = '[';
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
do {
|
||||
if (ISSET(levels, i)) {
|
||||
if (!plain && currlevel == i)
|
||||
pos = strlcat(lvl, "\e[1m", sizeof(lvl));
|
||||
|
||||
if (i == 0)
|
||||
if (i == INIT_LEVEL)
|
||||
lvl[pos++] = 'S';
|
||||
else
|
||||
lvl[pos++] = '0' + i;
|
||||
@@ -781,7 +782,14 @@ char *runlevel_string(int currlevel, int levels)
|
||||
} else {
|
||||
lvl[pos++] = '-';
|
||||
}
|
||||
}
|
||||
|
||||
/* XXX: ugly hack to get order right: S0123456789 */
|
||||
if (i == INIT_LEVEL)
|
||||
i = 0;
|
||||
else
|
||||
i++;
|
||||
} while (i < INIT_LEVEL);
|
||||
|
||||
|
||||
lvl[pos++] = ']';
|
||||
lvl[pos] = 0;
|
||||
@@ -792,18 +800,24 @@ char *runlevel_string(int currlevel, int levels)
|
||||
char *runlevel_arr(int levels)
|
||||
{
|
||||
static char lvl[42];
|
||||
int i = INIT_LEVEL;
|
||||
int p = 2, s = 0;
|
||||
|
||||
strlcpy(lvl, "[ ", sizeof(lvl));
|
||||
for (int i = 0; i < 10; i++) {
|
||||
do {
|
||||
if (ISSET(levels, i)) {
|
||||
if (i == 0)
|
||||
if (i == INIT_LEVEL)
|
||||
p += snprintf(&lvl[p], sizeof(lvl) - p, "\"S\"");
|
||||
else
|
||||
p += snprintf(&lvl[p], sizeof(lvl) - p, "%s%c", s ? ", " : "", '0' + i);
|
||||
s++;
|
||||
}
|
||||
}
|
||||
/* XXX: ugly hack to get order right: S0123456789 */
|
||||
if (i == INIT_LEVEL)
|
||||
i = 0;
|
||||
else
|
||||
i++;
|
||||
} while (i < INIT_LEVEL);
|
||||
strlcat(lvl, " ]", sizeof(lvl));
|
||||
|
||||
return lvl;
|
||||
@@ -1162,7 +1176,7 @@ static int show_status(char *arg)
|
||||
if (heading) {
|
||||
char title[80];
|
||||
|
||||
snprintf(title, sizeof(title), "%-*s %-*s %-8s %-12s ",
|
||||
snprintf(title, sizeof(title), "%-*s %-*s %-8s %-13s ",
|
||||
pw, "PID", iw, "IDENT", "STATUS", "RUNLEVELS");
|
||||
if (!verbose)
|
||||
strlcat(title, "DESCRIPTION", sizeof(title));
|
||||
@@ -1184,9 +1198,9 @@ static int show_status(char *arg)
|
||||
|
||||
lvls = runlevel_string(runlevel, svc->runlevels);
|
||||
if (strchr(lvls, '\e'))
|
||||
printf("%-20.20s ", lvls);
|
||||
printf("%-21.21s ", lvls);
|
||||
else
|
||||
printf("%-12.12s ", lvls);
|
||||
printf("%-13.13s ", lvls);
|
||||
|
||||
if (!verbose)
|
||||
puts(svc->desc);
|
||||
|
||||
Reference in new issue
Block a user