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.subr | |
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.subr')
-rw-r--r-- | etc/rc.subr | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/etc/rc.subr b/etc/rc.subr index 9f3c7b6..74a6b63 100644 --- a/etc/rc.subr +++ b/etc/rc.subr @@ -384,6 +384,45 @@ wait_for_pids() } # +# get_pidfile_from_conf string file +# +# Takes a string to search for in the specified file. +# Ignores lines with traditional comment characters. +# +# Example: +# +# if get_pidfile_from_conf string file; then +# pidfile="$_pidfile_from_conf" +# else +# pidfile='appropriate default' +# fi +# +get_pidfile_from_conf() +{ + local string file line + + string="$1" ; file="$2" + + if [ -z "$string" -o -z "$file" ] || [ ! -s "$file" ]; then + err 3 'USAGE: get_pidfile_from_conf string file' + fi + + while read line; do + case "$line" in + *[#\;]*${string}*) continue ;; + *${string}*) break ;; + esac + done < $file + + if [ -n "$line" ]; then + line=${line#*/} + _pidfile_from_conf="/${line%%[\"\;]*}" + else + return 1 + fi +} + +# # check_startmsgs # If rc_quiet is set (usually as a result of using faststart at # boot time) check if rc_startmsgs is enabled. |