blob: 9fc2fe744c479546710280241bff43dc87cac36b (
plain)
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
123
124
|
#!/sbin/sh
#
# Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
# $Id: quagga.init.in,v 1.6 2006/03/30 13:38:28 paul Exp $
#
# Starts/stops the given daemon
SMFINCLUDE=/lib/svc/share/smf_include.sh
DAEMON_PATH=@sbindir@
quagga_is_globalzone () {
if [ "${QUAGGA_INIT_ZONENAME:=`/sbin/zonename`}" != "global" ]; then
return 1
else
return 0
fi
}
# Include smf functions, if available. If not, define smf_present to indicate
# there is no SMF. Should allow this script to work pre-S10.
if [ -f "$SMFINCLUDE" ] ; then
. "$SMFINCLUDE";
else
# pre-SMF system, fake up any functions and exit codes
# which SMFINCLUDE usually provides.
smf_present () {
return 1
}
SMF_EXIT_OK=0;
SMF_EXIT_ERR_CONFIG=96;
SMF_EXIT_ERR_FATAL=95;
fi
# if there's no SMF, set some default DAEMON_ARGS
smf_present || DAEMON_ARGS=""
usage () {
if smf_present ; then
echo "Usage: $0 <daemon> <daemon arguments>";
else
echo "Usage: $0 <stop|start> <daemon> <daemon arguments>";
fi
echo "The --pid_file argument is implied";
echo "This help message: $0 <help|usage>";
}
# parse arguments, different according to SMF or not.
case $1 in
'help' | 'usage')
usage
exit SMF_EXIT_OK
;;
esac
if smf_present ; then
QUAGGA_METHOD="start"
else
QUAGGA_METHOD="$1"
shift;
fi
DAEMON="$1"
shift
DAEMON_ARGS="$@"
# daemon path must be given
if [ -z "$DAEMON_PATH/$DAEMON" ]; then
usage
exit $SMF_EXIT_ERR_FATAL
fi
# only bgpd is suitable for running in a non-global zone, at this
# time.
case "${DAEMON}" in
zebra)
quagga_is_globalzone || exit $SMF_EXIT_OK
;;
bgpd)
;;
ospfd | ospf6d | ripd | ripngd )
quagga_is_globalzone || exit $SMF_EXIT_OK
;;
*)
usage
exit $SMF_EXIT_ERR_CONFIG;
;;
esac
# we need @quagga_statedir@ to exist, it probably is on tmpfs.
if [ ! -d @quagga_statedir@ ] ; then
mkdir -p @quagga_statedir@
chown @enable_user@:@enable_group@ @quagga_statedir@
chmod 751 @quagga_statedir@
fi
PIDFILE="@quagga_statedir@/${DAEMON}.pid"
start () {
$DAEMON_PATH/$DAEMON $DAEMON_ARGS --pid_file ${PIDFILE} &
}
stop () {
if [ -f "${PIDFILE}" ]; then
/usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"`
fi
}
case "$QUAGGA_METHOD" in
'start')
start
;;
'stop')
stop
;;
*)
usage
exit SMF_EXIT_ERR_FATAL
;;
esac
exit $SMF_EXIT_OK;
|