View | Details | Raw Unified | Return to bug 211883
Collapse All | Expand All

(-)files/nsd.in (-7 / +80 lines)
Lines 11-16 Link Here
11
#
11
#
12
# nsd_enable="YES"
12
# nsd_enable="YES"
13
#
13
#
14
# You could set alternative config with
15
#
16
# nsd_config="/path/to/config"
17
#
18
# Multiple profiles are supported with
19
#
20
# nsd_profiles="name1 name2"
21
# nsd_name1_enable="YES"
22
# nsd_name1_config="/path/to/config1"
23
# nsd_name2_enable="YES"
24
# nsd_name2_config="/path/to/config2"
25
#
14
26
15
. /etc/rc.subr
27
. /etc/rc.subr
16
28
Lines 19-34 Link Here
19
31
20
# read settings, set default values
32
# read settings, set default values
21
load_rc_config "${name}"
33
load_rc_config "${name}"
22
: ${nsd_enable="NO"}
34
: ${nsd_enable:="NO"}
35
: ${nsd_config:=%%ETCDIR%%/nsd.conf}
23
36
24
config=${nsd_config:=%%ETCDIR%%/nsd.conf}
37
# Set PID file
25
required_files=${config}
38
_pidprefix=/var/run/${name}
26
pidfile=`%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${config}`
39
_cfgpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${nsd_config})
40
pidfile=${_cfgpidfile:-${_pidprefix}.pid}
41
42
required_files=${nsd_config}
27
command="%%PREFIX%%/sbin/${name}"
43
command="%%PREFIX%%/sbin/${name}"
28
command_args="-c ${required_files}"
44
command_args="-c ${nsd_config} -P ${pidfile}"
29
extra_commands="reload"
45
extra_commands="reload"
30
46
31
load_rc_config $name
47
load_rc_config "${name}"
32
48
49
if [ -n "$2" ]; then
50
	profile="$2"
51
	if [ "x${nsd_profiles}" != "x" ]; then
52
		eval nsd_config="\${nsd_${profile}_config:-%%ETCDIR%%/nsd-${profile}.conf}"
53
		if [ "x${nsd_config}" = "x" ]; then
54
			echo "You must define a configuration file (nsd_${profile}_config)"
55
			exit 1
56
		fi
57
		_cfgpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile ${nsd_config})
58
		_defaultpidfile=$(%%PREFIX%%/sbin/nsd-checkconf -f -o pidfile /dev/null)
59
		# Replace empty or default value with profile-based
60
		if [ "x${_cfgpidfile}" = "x" -o "x${_cfgpidfile}" = "x${_defaultpidfile}" ] ; then 
61
			pidfile=${_pidprefix}-${profile}.pid
62
		else
63
			pidfile=${_cfgpidfile}
64
		fi
65
		required_files="${nsd_config}"
66
		eval nsd_enable="\${nsd_${profile}_enable:-${nsd_enable}}"
67
		command_args="-c ${nsd_config} -P ${pidfile}"
68
	else
69
		echo "$0: extra argument ignored"
70
	fi
71
else
72
	if [ "x${nsd_profiles}" != "x" -a "x$1" != "x" ]; then
73
		for profile in ${nsd_profiles}; do
74
			eval _enable="\${nsd_${profile}_enable}"
75
			case "x${_enable:-${nsd_enable}}" in
76
			x|x[Nn][Oo]|x[Nn][Oo][Nn][Ee])
77
				continue
78
				;;
79
			x[Yy][Ee][Ss])
80
				;;
81
			*)
82
				if test -z "$_enable"; then
83
					_var=nsd_enable
84
				else
85
					_var=nsd_"${profile}"_enable
86
				fi
87
				echo "Bad value" \
88
				    "'${_enable:-${nsd_enable}}'" \
89
				    "for ${_var}. " \
90
				    "Profile ${profile} skipped."
91
				continue
92
				;;
93
			esac
94
			echo "===> nsd profile: ${profile}"
95
			%%PREFIX%%/etc/rc.d/nsd $1 ${profile}
96
			retcode="$?"
97
			if [ "0${retcode}" -ne 0 ]; then
98
				failed="${profile} (${retcode}) ${failed:-}"
99
			else
100
				success="${profile} ${success:-}"
101
			fi
102
		done
103
		exit 0
104
	fi
105
fi
106
33
run_rc_command "$1"
107
run_rc_command "$1"
34

Return to bug 211883