diff options
author | dougb <dougb@FreeBSD.org> | 2011-04-23 04:26:31 +0000 |
---|---|---|
committer | dougb <dougb@FreeBSD.org> | 2011-04-23 04:26:31 +0000 |
commit | d05cc95927280821298e08e1be9fe78cc987ad6c (patch) | |
tree | 19cd95ff052dd0f9ab092912f12efc9fa1559f6b /etc/rc.d | |
parent | 44325abfea7570a22af7a54f3a32c64fa462744f (diff) | |
download | FreeBSD-src-d05cc95927280821298e08e1be9fe78cc987ad6c.zip FreeBSD-src-d05cc95927280821298e08e1be9fe78cc987ad6c.tar.gz |
Introduce to rc.subr get_pidfile_from_conf(). It does just what it sounds
like, determines the path to a pid file as it is specified in a conf file.
Use the new feature for rc.d/named and rc.d/devd, the 2 services in the
base that list their pid files in their conf files.
Remove the now-obsolete named_pidfile, and warn users if they have it set.
Diffstat (limited to 'etc/rc.d')
-rwxr-xr-x | etc/rc.d/devd | 13 | ||||
-rwxr-xr-x | etc/rc.d/named | 18 |
2 files changed, 29 insertions, 2 deletions
diff --git a/etc/rc.d/devd b/etc/rc.d/devd index a126645..e257da6 100755 --- a/etc/rc.d/devd +++ b/etc/rc.d/devd @@ -13,12 +13,23 @@ name="devd" rcvar=`set_rcvar` command="/sbin/${name}" -pidfile=/var/run/${name}.pid start_precmd=${name}_prestart +stop_precmd=find_pidfile + +find_pidfile() +{ + if get_pidfile_from_conf pid-file /etc/devd.conf; then + pidfile="$_pidfile_from_conf" + else + pidfile="/var/run/${name}.pid" + fi +} devd_prestart () { + find_pidfile + # If devd is disabled, turn it off in the kernel to avoid memory leaks. if ! checkyesno ${rcvar}; then $SYSCTL hw.bus.devctl_disable=1 diff --git a/etc/rc.d/named b/etc/rc.d/named index 81db646..676de76 100755 --- a/etc/rc.d/named +++ b/etc/rc.d/named @@ -112,8 +112,19 @@ named_reload() ${command%/named}/rndc reload } +find_pidfile() +{ + if get_pidfile_from_conf pid-file $named_conf; then + pidfile="$_pidfile_from_conf" + else + pidfile="/var/run/named/pid" + fi +} + named_stop() { + find_pidfile + # This duplicates an undesirably large amount of code from the stop # routine in rc.subr in order to use rndc to shut down the process, # and to give it a second chance in case rndc fails. @@ -156,6 +167,12 @@ create_file () { named_prestart() { + find_pidfile + + if [ -n "$named_pidfile" ]; then + warn 'named_pidfile: now determined from the conf file' + fi + command_args="-u ${named_uid:=root}" if [ ! "$named_conf" = '/etc/namedb/named.conf' ]; then @@ -279,7 +296,6 @@ load_rc_config $name # required_dirs="$named_chrootdir" # if it is set, it must exist -pidfile="${named_pidfile:-/var/run/named/pid}" named_confdir="${named_chrootdir}${named_conf%/*}" run_rc_command "$1" |