mirror of
https://github.com/troglobit/finit.git
synced 2026-10-13 10:14:47 +00:00
Add --enable-quiet to configure, makes Finit real quiet.
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
@@ -319,7 +319,8 @@ static int parse_conf(char *file)
|
||||
strcat(line, " ");
|
||||
}
|
||||
|
||||
print(0, "Loading %sconfiguration", line);
|
||||
if (verbose)
|
||||
print(0, "Loading %sconfiguration", line);
|
||||
while (!feof(fp)) {
|
||||
if (!fgets(line, sizeof(line), fp))
|
||||
continue;
|
||||
|
||||
@@ -28,6 +28,7 @@ defaults()
|
||||
debug=${debug:=0}
|
||||
embedded=${embedded:=0}
|
||||
inetd=${inetd:=1}
|
||||
verbose=${verbose:=1}
|
||||
static=${static:=0}
|
||||
disable_plugins=${disable_plugins:=0}
|
||||
}
|
||||
@@ -59,8 +60,13 @@ fi
|
||||
else
|
||||
echo "Inetd : DISABLED"
|
||||
fi
|
||||
if [ $verbose -ne 1 ]; then
|
||||
echo "Quiet Finit : YES"
|
||||
else
|
||||
echo "Quiet Finit : NO, verbose output (default)"
|
||||
fi
|
||||
if [ $static -ne 0 ]; then
|
||||
echo "Static finit : YES"
|
||||
echo "Static Finit : YES"
|
||||
fi
|
||||
if [ $disable_plugins -eq 1 ]; then
|
||||
echo "Plugins : DISABLED"
|
||||
@@ -98,7 +104,8 @@ usage()
|
||||
echo
|
||||
echo " --enable-embedded Enable embedded defaults, BusBox getty, mdev etc."
|
||||
echo " --enable-debug Enable debug flags, '-O0, -g'"
|
||||
echo " --enable-static Link finit statically. This disables a few features."
|
||||
echo " --enable-quiet Quiet mode, reduce screen output to absolute minimum."
|
||||
echo " --enable-static Link statically. This disables a few features."
|
||||
echo " --disable-inetd Disable inetd support if not needed."
|
||||
echo " --disable-plugins Disable plugins"
|
||||
echo
|
||||
@@ -171,6 +178,14 @@ while [ "$*" != "" ]; do
|
||||
embedded=1
|
||||
;;
|
||||
|
||||
enable-quiet)
|
||||
verbose=0
|
||||
;;
|
||||
|
||||
enable-static)
|
||||
static=1
|
||||
;;
|
||||
|
||||
disable-inetd)
|
||||
inetd=0
|
||||
;;
|
||||
@@ -179,10 +194,6 @@ while [ "$*" != "" ]; do
|
||||
disable_plugins=1
|
||||
;;
|
||||
|
||||
enable-static)
|
||||
static=1
|
||||
;;
|
||||
|
||||
help)
|
||||
usage
|
||||
;;
|
||||
@@ -263,6 +274,7 @@ if [ x"$heading" != x"" ]; then
|
||||
echo "#define INIT_HEADING \"$heading\"" >> config.h
|
||||
fi
|
||||
|
||||
echo "#define VERBOSE_MODE $verbose" >> config.h
|
||||
echo "#define FINIT_FIFO \"$fifo\"" >> config.h
|
||||
echo "#define FINIT_CONF \"$config\"" >> config.h
|
||||
echo "#define FINIT_RCSD \"$rcsd\"" >> config.h
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include "inetd.h"
|
||||
|
||||
int debug = 0;
|
||||
int verbose = 1;
|
||||
int verbose = VERBOSE_MODE;
|
||||
int runlevel = 0; /* Bootstrap */
|
||||
int cfglevel = RUNLEVEL; /* Fallback if no configured runlevel */
|
||||
int prevlevel = 0; /* HALT */
|
||||
@@ -104,7 +104,7 @@ int main(int argc, char* argv[])
|
||||
* Load plugins first, finit.conf may contain references to
|
||||
* features implemented by plugins.
|
||||
*/
|
||||
print_result(plugin_load_all(&loop, PLUGIN_PATH));
|
||||
plugin_load_all(&loop, PLUGIN_PATH);
|
||||
|
||||
/*
|
||||
* Parse configuration file
|
||||
|
||||
@@ -87,6 +87,8 @@ struct init_request {
|
||||
char data[368];
|
||||
};
|
||||
|
||||
extern int debug;
|
||||
extern int verbose;
|
||||
extern int runlevel;
|
||||
extern int cfglevel;
|
||||
extern int prevlevel;
|
||||
|
||||
@@ -172,6 +172,9 @@ char *runlevel_string(int levels)
|
||||
*/
|
||||
int banner(void)
|
||||
{
|
||||
if (getpid() == 1 && !verbose)
|
||||
return 0;
|
||||
|
||||
delline();
|
||||
#ifdef INIT_HEADING
|
||||
echo("%s", INIT_HEADING);
|
||||
@@ -515,7 +518,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (fmt) {
|
||||
if (verbose && fmt) {
|
||||
va_start(ap, fmt);
|
||||
vsnprintf(line, sizeof(line), fmt, ap);
|
||||
va_end(ap);
|
||||
@@ -547,7 +550,7 @@ int run_interactive(char *cmd, char *fmt, ...)
|
||||
}
|
||||
}
|
||||
|
||||
if (fmt)
|
||||
if (verbose && fmt)
|
||||
print_result(status);
|
||||
|
||||
/* Dump any results of cmd on stderr after we've printed [ OK ] or [FAIL] */
|
||||
|
||||
@@ -88,9 +88,6 @@ do { \
|
||||
#define SETBIT(a,i) (a |= (1 << (i)))
|
||||
#define CLRBIT(a,i) (a &= ~(1 << (i)))
|
||||
|
||||
extern int debug;
|
||||
extern int verbose;
|
||||
|
||||
int makepath (char *path);
|
||||
void ifconfig (char *ifname, char *addr, char *mask, int up);
|
||||
|
||||
|
||||
@@ -295,10 +295,12 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
|
||||
DIR *dp = opendir(path);
|
||||
struct dirent *entry;
|
||||
|
||||
print_desc("Loading plugins", NULL);
|
||||
if (verbose)
|
||||
print_desc("Loading plugins", NULL);
|
||||
if (!dp) {
|
||||
_e("Failed, cannot open plugin directory %s: %s", path, strerror(errno));
|
||||
return 1;
|
||||
fail = 1;
|
||||
goto exit;
|
||||
}
|
||||
plugpath = path;
|
||||
|
||||
@@ -319,6 +321,9 @@ int plugin_load_all(uev_ctx_t *ctx, char *path)
|
||||
|
||||
/* Always initialize plugins */
|
||||
init_plugins(ctx);
|
||||
exit:
|
||||
if (verbose)
|
||||
print_result(fail);
|
||||
|
||||
return fail;
|
||||
}
|
||||
|
||||
@@ -145,11 +145,13 @@ int service_start(svc_t *svc)
|
||||
|
||||
/* Don't try and start service if it doesn't exist. */
|
||||
if (!fexist(svc->cmd) && !svc->inetd.cmd) {
|
||||
char msg[80];
|
||||
if (verbose) {
|
||||
char msg[80];
|
||||
|
||||
snprintf(msg, sizeof(msg), "Service %s does not exist!", svc->cmd);
|
||||
print_desc("", msg);
|
||||
print_result(1);
|
||||
snprintf(msg, sizeof(msg), "Service %s does not exist!", svc->cmd);
|
||||
print_desc("", msg);
|
||||
print_result(1);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -193,10 +195,12 @@ int service_start(svc_t *svc)
|
||||
FLOG_INFO("Starting inetd service %s for requst from iface %s ...", svc->inetd.name, ifname);
|
||||
} else
|
||||
#endif
|
||||
if (svc_is_daemon(svc))
|
||||
print_desc("", svc->desc);
|
||||
else if (!respawn)
|
||||
print_desc("Starting ", svc->desc);
|
||||
if (verbose) {
|
||||
if (svc_is_daemon(svc))
|
||||
print_desc("", svc->desc);
|
||||
else if (!respawn)
|
||||
print_desc("Starting ", svc->desc);
|
||||
}
|
||||
|
||||
/* Block sigchild while forking. */
|
||||
sigemptyset(&nmask);
|
||||
@@ -281,11 +285,12 @@ int service_start(svc_t *svc)
|
||||
if (svc_is_inetd(svc)) {
|
||||
if (svc->inetd.type == SOCK_STREAM)
|
||||
close(sd);
|
||||
} else if (verbose) {
|
||||
if (SVC_TYPE_RUN == svc->type)
|
||||
print_result(WEXITSTATUS(complete(svc->cmd, pid)));
|
||||
else if (!respawn)
|
||||
print_result(svc->pid > 1 ? 0 : 1);
|
||||
}
|
||||
else if (SVC_TYPE_RUN == svc->type)
|
||||
print_result(WEXITSTATUS(complete(svc->cmd, pid)));
|
||||
else if (!respawn)
|
||||
print_result(svc->pid > 1 ? 0 : 1);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -308,13 +313,13 @@ int service_stop(svc_t *svc)
|
||||
if (SVC_TYPE_SERVICE != svc->type)
|
||||
return 0;
|
||||
|
||||
if (runlevel != 1)
|
||||
if (runlevel != 1 && verbose)
|
||||
print_desc("Stopping ", svc->desc);
|
||||
|
||||
_d("Sending SIGTERM to pid:%d name:%s", svc->pid, pid_get_name(svc->pid, NULL, 0));
|
||||
res = kill(svc->pid, SIGTERM);
|
||||
|
||||
if (runlevel != 1)
|
||||
if (runlevel != 1 && verbose)
|
||||
print_result(res);
|
||||
exit:
|
||||
svc->pid = 0;
|
||||
|
||||
Reference in New Issue
Block a user