tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

rc scripts telling you when they will not start



One thing that has always bothered me about netbsd rc is that running
an rc script will often silently do nothing.

If a service is turned NO by default in /etc/defaults/rc.conf, and you
run /etc/rc.d/foo start, you get nothing + a 0 return status.

The following patch gives a nice little messages:

--- rc.subr-bak 2012-01-07 09:22:36.000000000 -0500
+++ rc.subr     2012-01-07 10:13:49.000000000 -0500
@@ -55,6 +55,7 @@

                #       "no", "false", "off", or "0"
        [Nn][Oo]|[Ff][Aa][Ll][Ss][Ee]|[Oo][Ff][Ff]|0)
+               warn "\$${1} is set to $_value - not running $1."
                return 1
                ;;
        *)

rc.d # /etc/rc.d/named start
/etc/rc.d/named: WARNING: $named is set to NO - not running named.
rc.d # /etc/rc.d/named ftpd start
/etc/rc.d/named: WARNING: $named is set to NO - not running named.

The issues I haven't addressed are the return status, which I think
should be non-zero.



Also, I guess this would make the boot kind of noisy.  Could we add
something like:
(/etc/rc)
-        run_rc_script $_rc_elem start
+        run_rc_script $_rc_elem start silent

and then test if the boot rc_arg has 'silent' before printing the warning?

Matt


Home | Main Index | Thread Index | Old Index