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