On Fri, Feb 15, 2013 at 11:26:11AM +0100, Alfred Bartsch
wrote:> 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:
> {snip}
Your patch, in effectively, "rewrites" checkyesno() to remove the
warn()
call in cases where xxx_enable variables are set to values other than
yes/true/on/1 or no/false/off/0.
Here's a better idea:
Fix your /etc/rc.conf xxx_enable variables which contain values that
aren't permitted. That's what the warn() is for -- to tell you to fix
them. :-)
If there are ports (or worse, rc.d scripts) out there which recommend
xxx_enable variables with non-permitted values, then these ports need to
be fixed, not rc.subr(8) nor service(8). Please disclose what those are
so they can be fixed.
However, "service -e" does not emit warnings on my 2 systems:
root at icarus:~ # service -e
/etc/rc.d/hostid
/etc/rc.d/zvol
/etc/rc.d/ddb
/etc/rc.d/hostid_save
/etc/rc.d/zfs
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/devd
/etc/rc.d/netwait
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/named
/etc/rc.d/ntpdate
/etc/rc.d/dmesg
/etc/rc.d/virecover
/etc/rc.d/motd
/etc/rc.d/ntpd
/etc/rc.d/powerd
/usr/local/etc/rc.d/samba
/usr/local/etc/rc.d/postfix
/usr/local/etc/rc.d/mysql-server
/usr/local/etc/rc.d/apache22
/etc/rc.d/sshd
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/inetd
/etc/rc.d/gptboot
root at omake:~ # service -e
/etc/rc.d/hostid
/etc/rc.d/ddb
/etc/rc.d/hostid_save
/etc/rc.d/cleanvar
/etc/rc.d/ip6addrctl
/etc/rc.d/devd
/etc/rc.d/pflog
/etc/rc.d/pf
/etc/rc.d/netwait
/etc/rc.d/newsyslog
/etc/rc.d/syslogd
/etc/rc.d/named
/etc/rc.d/ntpdate
/etc/rc.d/dmesg
/etc/rc.d/virecover
/etc/rc.d/motd
/etc/rc.d/ntpd
/usr/local/etc/rc.d/sa-spamd
/usr/local/etc/rc.d/postfix
/usr/local/etc/rc.d/dovecot
/usr/local/etc/rc.d/apache22
/etc/rc.d/sshd
/etc/rc.d/cron
/etc/rc.d/mixer
/etc/rc.d/inetd
/etc/rc.d/gptboot
Regardless: the permitted values (see above) should be documented in
rc.conf(5) somewhere; I don't see any values other than "yes"
documented, but I'm probably overlooking it.
> 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?
It is the expected behaviour as I understand it per the man page. You
should also see rc(8).
As I understand it, an "enabled service" is not a process that's
running, but something that has a yes/true/on/1 value for its
xxx_enabled variable in rc.conf/related file. That's just how it works.
If you're used to, for example, Solaris "svcs" then yes things are
different here.
> 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.
There is already "service <name> status". See rc(8) (search for
"status") or try it yourself on a running service. Example:
root at icarus:~ # service postfix status
postfix is running as pid 1378.
Can you rephrase or give an example of what you want?
--
| Jeremy Chadwick jdc at koitsu.org |
| UNIX Systems Administrator http://jdc.koitsu.org/ |
| Mountain View, CA, US |
| Making life hard for others since 1977. PGP 4BD6C0CB |