Bug#743274: insserv: warns about configuration changes
Jesse Smith
jsmith at resonatingmedia.com
Sun Jul 21 21:14:00 BST 2019
I have added a silent mode flag for insserv. Running the program with
either "-q" or "--silent" will surpress most warning messages. insserv
will only print fatal errors, when it is about to exit, when in silent mode.
A patch for the new behaviour is attached. Maybe we can get update-rc.d
patched to match the new behaviour.
This change will be available in insserv-1.21.0.
- Jesse
-------------- next part --------------
diff --git a/insserv.8.in b/insserv.8.in
index bc8f351..0a4b0cf 100644
--- a/insserv.8.in
+++ b/insserv.8.in
@@ -264,6 +264,11 @@ Currently the following options are recognized by insserv:
.BR \-v ,\ \-\-verbose
Perform operation with more diagnotic messages printed on stderr.
.TP
+.BR \-q ,\ \-\-silent
+Perform operations silently. This blocks warning messages
+from being printed to stderr. Only fatal error messages
+are printed.
+.TP
.BR \-c\ <config> ,\ \-\-config\ <config>
Specify path to the insserv.conf file and the insserv.conf.d
directory. Useful for testing.
diff --git a/insserv.c b/insserv.c
index c9d8c69..ef8025f 100644
--- a/insserv.c
+++ b/insserv.c
@@ -176,7 +176,7 @@ static char buf[LINE_MAX];
/* When to be verbose, and what level of verbosity */
static int verbose = 0;
-
+static boolean silent_mode = false;
static boolean dryrun = false;
/* When paths set do not add root if any */
@@ -1233,6 +1233,9 @@ void error (const char *restrict const fmt, ...)
*/
void warn (const char *restrict const fmt, ...)
{
+ if (silent_mode)
+ return; /* do not print warnings in silent mode */
+
va_list ap;
va_start(ap, fmt);
_logger(fmt, ap);
@@ -2762,6 +2765,7 @@ static struct option long_options[] =
{"path", 1, (int*)0, 'p'},
{"override", 1, (int*)0, 'o'},
{"upstart-job", 1, (int*)0, 'u'},
+ {"silent", 0, (int*)0, 'q'},
{"recursive", 0, (int*)0, 'e'},
{"showall", 0, (int*)0, 's'},
{"show-all", 0, (int*)0, 's'},
@@ -2778,6 +2782,7 @@ static void help(const char *restrict const name)
printf(" -r, --remove Remove the listed scripts from all runlevels.\n");
printf(" -f, --force Ignore if a required service is missed.\n");
printf(" -v, --verbose Provide information on what is being done.\n");
+ printf(" -q, --silent Do not print warnings, only fatal errors.\n");
/* printf(" -l, --legacy-path Place dependency files in /etc/init.d instead of /lib/insserv.\n"); */
printf(" -i, --insserv-dir Place dependency files in a location other than /lib/insserv\n");
printf(" -p <path>, --path <path> Path to replace " INITDIR ".\n");
@@ -2830,7 +2835,7 @@ int main (int argc, char *argv[])
for (c = 0; c < argc; c++)
argr[c] = (char*)0;
- while ((c = getopt_long(argc, argv, "c:dfrhvni:o:p:u:es", long_options, (int *)0)) != -1) {
+ while ((c = getopt_long(argc, argv, "c:dfrhqvni:o:p:u:es", long_options, (int *)0)) != -1) {
size_t l;
switch (c) {
case 'c':
@@ -2848,6 +2853,9 @@ int main (int argc, char *argv[])
case 'f':
ignore = true;
break;
+ case 'q':
+ silent_mode = true;
+ break;
case 'v':
verbose ++;
break;
More information about the Debian-init-diversity
mailing list