Refactor: Cleanup and expand client code to support <version|q|reload|debug>

Further refactoring of the client code.  Supported commands:

- debug:   Toggle PID 1 debug flag
- version: Show Finit version or custom header string
- reload:  Reload config files in /etc/finit.d/, same as SIGHUP

Also supported is the legacy 'init q' command, to reload config.

The 'status' command now supports an optiona '-v', either as an
argument to init itself, or as argument to the command.  When it
is given 'status' lists verbose information about all services.
Currently only the service arguments are listed.

Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
Joachim Nilsson committed 2015-06-07 12:11:07 +02:00
1 parent 811bd75eab
commit 2026486fda
9 files changed
+233 -145

No files matched your search

+35
View File
@@ -54,6 +54,25 @@ static char *strip_line(char *line)
return line;
}
void parse_kernel_cmdline(void)
{
FILE *fp;
char line[LINE_SIZE];
if ((fp = fopen("/proc/cmdline", "r")) != NULL) {
fgets(line, sizeof(line), fp);
_d("Kernel command line: %s", line);
if (strstr(line, "finit_debug") || strstr(line, "--debug"))
debug = 1;
if (!debug && strstr(line, "quiet"))
verbose = 0;
fclose(fp);
}
}
/* Convert optional "[!123456789S]" string into a bitmask */
int parse_runlevels(char *runlevels)
{
@@ -378,6 +397,22 @@ int parse_finit_conf(char *file)
return result;
}
/* Called on SIGHUP or 'init q' */
void reload_finit_d(void)
{
/* Mark and sweep */
svc_mark_dynamic();
/* Reload all *.conf in /etc/finit.d/ */
parse_finit_d(rcsd);
/* Reload dirty services */
service_reload_dynamic();
/* Cleanup stale services */
svc_clean_dynamic(service_unregister);
}
/**
* Local Variables: