blob: 92c4d41af2f39cc8bb3dc20d25fb143fedd35d8a (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
|
#!/bin/sh
# $FreeBSD$
#
# PROVIDE: quagga
# REQUIRE: netif routing
# KEYWORD: nojail
#
# Add the following line to /etc/rc.conf to enable quagga:
#quagga_enable="YES"
#
# You may also wish to use the following variables to fine-tune startup:
# quagga_flags="-d"
# quagga_daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"
# Per daemon tuning may be done with daemon_name_flags
# zebra_flags="-dP 0"
# bgpd_flags="-dnrP 0" and so on
# If you want to give the routing deamons a chance to catchup before
# continueing, set quagga_wait_for to a "default" or certain prefix.
# quagga_wait_for="default"
#
# If the quagga daemons require additional shared libraries to start,
# use the following variable to run ldconfig(8) in advance:
#quagga_extralibs_path="/usr/local/lib ..."
#
. /etc/rc.subr
name="quagga"
rcvar=quagga_enable
start_postcmd=start_postcmd
stop_postcmd=stop_postcmd
start_postcmd()
{
# Wait only when last daemon has started.
if [ "${quagga_daemons}" = "${quagga_daemons% ${name}}" ]; then
return;
fi
if [ ${quagga_wait_for} ]; then
echo Waiting for ${quagga_wait_for} route...
while true; do
/sbin/route -n get ${quagga_wait_for} >/dev/null 2>&1 && break;
sleep 1;
done
fi
}
stop_postcmd()
{
rm -f $pidfile
}
do_cmd()
{
local ret
ret=0
for daemon in ${quagga_daemons}; do
command=%%PREFIX%%/sbin/${daemon}
required_files=%%SYSCONF_DIR%%/${daemon}.conf
pidfile=%%LOCALSTATE_DIR%%/${daemon}.pid
if [ ${quagga_cmd} = "start" -a ! -f ${required_files} ]; then
continue
fi
if [ ${quagga_cmd} = "stop" -a -z $(check_process ${command}) ]; then
continue
fi
eval flags=\$\{${daemon}_flags:-\"${quagga_flags}\"\}
name=${daemon}
_rc_restart_done=false
run_rc_command "$1" || ret=1
done
return ${ret}
}
# set defaults
load_rc_config $name
: ${quagga_enable="NO"}
: ${quagga_flags="-d"}
: ${quagga_daemons="zebra ripd ripngd ospfd ospf6d bgpd isisd"}
quagga_cmd=$1
case "$1" in
force*)
quagga_cmd=${quagga_cmd#force}
;;
fast*)
quagga_cmd=${quagga_cmd#fast}
;;
esac
shift
if [ $# -ge 1 ]; then
quagga_daemons="$*"
fi
case "${quagga_cmd}" in
start)
if [ ! -z ${quagga_extralibs_path} ]; then
/sbin/ldconfig -m ${quagga_extralibs_path}
fi
do_cmd "start"
;;
stop)
quagga_daemons=$(reverse_list ${quagga_daemons})
do_cmd "stop"
;;
restart)
quagga_daemons=$(reverse_list ${quagga_daemons})
do_cmd "stop"
quagga_daemons=$(reverse_list ${quagga_daemons})
do_cmd "start"
;;
*)
do_cmd "${quagga_cmd}"
;;
esac
|