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

+44
View File
@@ -136,6 +136,50 @@ int atonum(char *str)
return val;
}
/**
* runlevel_string - Convert a bit encoded runlevel to .conf syntax
* @levels: Bit encoded runlevels
*
* Returns:
* Pointer to string on the form [2345]
*/
char *runlevel_string(int levels)
{
int i, pos = 1;;
static char lvl[10] = "[]";
for (i = 0; i < 10; i++) {
if (ISSET(levels, i)) {
if (i == 0)
lvl[pos++] = 'S';
else
lvl[pos++] = '0' + i;
}
}
lvl[pos++] = ']';
lvl[pos] = 0;
return lvl;
}
/**
* banner - Show Finit version at boot or from cmdline
*
* This function prints the default Finit version, or a custom heading.
*
* Returns:
* This function is always successful, returning POSIX OK(0).
*/
int banner(void)
{
delline();
#ifdef INIT_HEADING
echo("%s", INIT_HEADING);
#else
echo("Finit version " VERSION " (" WHOAMI ") " __DATE__ " " __TIME__);
#endif
return 0;
}
/**
* pidfile_read - Reads a PID value from a pidfile.