+ initial edition of meta-queue for RIB updates processing (bug #431)
[jleu-quagga.git] / solaris / quagga.init.in
blob30a9c6943fb6ae7c5c9e5fb49deb0b3d724144b1
1 #!/sbin/sh
3 # Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved.
4 # Use is subject to license terms.
6 # This file is part of Quagga.
8 # Quagga is free software; you can redistribute it and/or modify it
9 # under the terms of the GNU General Public License as published by the
10 # Free Software Foundation; either version 2, or (at your option) any
11 # later version.
13 # Quagga is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 # General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with Quagga; see the file COPYING. If not, write to the Free
20 # Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
21 # 02111-1307, USA.
23 # $Id$
25 # Starts/stops the given daemon
27 SMFINCLUDE=/lib/svc/share/smf_include.sh
28 DAEMON_PATH=@sbindir@
30 quagga_is_globalzone () {
31 if [ "${QUAGGA_INIT_ZONENAME:=`/sbin/zonename`}" != "global" ]; then
32 return 1
33 else
34 return 0
38 # Include smf functions, if available. If not, define smf_present to indicate
39 # there is no SMF. Should allow this script to work pre-S10.
40 if [ -f "$SMFINCLUDE" ] ; then
41 . "$SMFINCLUDE";
42 else
43 # pre-SMF system, fake up any functions and exit codes
44 # which SMFINCLUDE usually provides.
45 smf_present () {
46 return 1
48 SMF_EXIT_OK=0;
49 SMF_EXIT_ERR_CONFIG=96;
50 SMF_EXIT_ERR_FATAL=95;
53 # if there's no SMF, set some default DAEMON_ARGS
54 smf_present || DAEMON_ARGS=""
56 usage () {
57 if smf_present ; then
58 echo "Usage: $0 <daemon> <daemon arguments>";
59 else
60 echo "Usage: $0 <stop|start> <daemon> <daemon arguments>";
62 echo "The --pid_file argument is implied";
63 echo "This help message: $0 <help|usage>";
66 # parse arguments, different according to SMF or not.
67 case $1 in
68 'help' | 'usage')
69 usage
70 exit SMF_EXIT_OK
72 esac
74 if smf_present ; then
75 QUAGGA_METHOD="start"
76 else
77 QUAGGA_METHOD="$1"
78 shift;
81 DAEMON="$1"
82 shift
83 DAEMON_ARGS="$@"
85 # daemon path must be given
86 if [ -z "$DAEMON_PATH/$DAEMON" ]; then
87 usage
88 exit $SMF_EXIT_ERR_FATAL
91 # only bgpd is suitable for running in a non-global zone, at this
92 # time.
93 case "${DAEMON}" in
94 zebra)
95 quagga_is_globalzone || exit $SMF_EXIT_OK
97 bgpd)
99 ospfd | ospf6d | ripd | ripngd )
100 quagga_is_globalzone || exit $SMF_EXIT_OK
103 usage
104 exit $SMF_EXIT_ERR_CONFIG;
106 esac
108 # we need @quagga_statedir@ to exist, it probably is on tmpfs.
109 if [ ! -d @quagga_statedir@ ] ; then
110 mkdir -p @quagga_statedir@
111 chown @enable_user@:@enable_group@ @quagga_statedir@
112 chmod 751 @quagga_statedir@
115 PIDFILE="@quagga_statedir@/${DAEMON}.pid"
117 start () {
118 $DAEMON_PATH/$DAEMON $DAEMON_ARGS --pid_file ${PIDFILE} &
121 stop () {
122 if [ -f "${PIDFILE}" ]; then
123 /usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"`
127 case "$QUAGGA_METHOD" in
128 'start')
129 start
131 'stop')
132 stop
136 usage
137 exit SMF_EXIT_ERR_FATAL
139 esac
141 exit $SMF_EXIT_OK;