From d05cc95927280821298e08e1be9fe78cc987ad6c Mon Sep 17 00:00:00 2001 From: dougb Date: Sat, 23 Apr 2011 04:26:31 +0000 Subject: 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. --- etc/rc.subr | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) (limited to 'etc/rc.subr') 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. -- cgit v1.1