Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 15 Feb 2013 11:26:11 +0100
From:      Alfred Bartsch <bartsch@dssgmbh.de>
To:        freebsd-stable@FreeBSD.org
Subject:   some issues with /usr/sbin/service
Message-ID:  <511E0D43.6070900@dssgmbh.de>

next in thread | raw e-mail | index | archive | help
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

we want to use this script for server administration purposes. After
doing some testing, for now there are following issues left:

1) every execution of "service -e"  casts a bunch of unnecessary
warnings into /var/log/messages:
    "... /usr/sbin/service: WARNING: $<name>_enable is not set
properly - see rc.conf(5)."
   This is caused by calling "checkyesno()", provided by /etc/subr. It
could be solved by using a local function, named "checkyes" or similar.

The following patch prohibits these annoying messages:

- --- service.orig        2013-02-10 20:01:14.000000000 +0100
+++ service     2013-02-15 08:51:30.000000000 +0100
@@ -28,6 +28,28 @@

 . /etc/rc.subr
 load_rc_config 'XXX'
+#
+# checkyes var
+#       Test $1 variable.
+#       Return 0 if it's "yes" (et al), nonzero otherwise.
+#
+checkyes()
+{
+        eval _value=\$${1}
+        debug "checkyes: $1 is set to $_value."
+        case $_value in
+
+                #       "yes", "true", "on", or "1"
+        [Yy][Ee][Ss]|[Tt][Rr][Uu][Ee]|[Oo][Nn]|1)
+                return 0
+                ;;
+
+                #     everything else
+        *)
+                return 1
+                ;;
+        esac
+}

 usage () {
        echo ''
@@ -100,7 +122,7 @@
                if grep -q ^rcvar $file; then
                        eval `grep ^name= $file`
                        eval `grep ^rcvar $file`
- -                       checkyesno $rcvar 2>/dev/null && echo $file
+                       checkyes $rcvar 2>/dev/null && echo $file
                fi
        done
        exit 0



2) "service -e" does not show ALL enabled services, but only those who
are explicitly enabled in /etc/defaults/rc.conf or /etc/rc.conf.
Is that expected behavior?
To catch all enabled services where the <name>_enabled variable is set
within the service procedure itself, perhaps a call like "service
<name> status" could help.

- -- 
Regards
Alfred Bartsch
Data-Service GmbH
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (FreeBSD)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iEYEARECAAYFAlEeDUMACgkQ5QGe2JdVf3hL5QCggTK3JP9A+ZybIX/iCsuqu5Ic
bYQAn2w7Y2klRoEy7ithoxeVcl4xA2be
=QJmh
-----END PGP SIGNATURE-----



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?511E0D43.6070900>