blob: 1fa987659d7e562ee1a28a965929b3cdf2253506 [file] [log] [blame]
paul1b414a12005-04-11 07:05:21 +00001#!/sbin/sh
2#
3# Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved.
4# Use is subject to license terms.
5#
Paul Jakmae24f0632006-02-19 18:59:26 +00006# $Id: quagga.init.in,v 1.5 2006/02/19 18:59:26 paul Exp $
paul1b414a12005-04-11 07:05:21 +00007#
8# Starts/stops the appropriate daemon
9
10SMFINCLUDE=/lib/svc/share/smf_include.sh
11
12if [ -f "$SMFINCLUDE" ] ; then
13 . "$SMFINCLUDE";
14fi
15
16usage () {
paul9b78d052005-06-15 11:00:11 +000017 echo "Usage: $0 (start|stop) <fmri> <instance>";
paul1b414a12005-04-11 07:05:21 +000018}
19
20case $1 in
21 'help' | 'usage')
22 usage
23 ;;
24esac
25
paul9b78d052005-06-15 11:00:11 +000026# fmri and instance must be given.
paul1b414a12005-04-11 07:05:21 +000027FMRI="$2"
paul9b78d052005-06-15 11:00:11 +000028INSTANCE="$3"
29if [ -z "$FMRI" -o -z "$INSTANCE" ]; then
paul1b414a12005-04-11 07:05:21 +000030 usage
31 exit $SMF_EXIT_ERR_CONFIG
32fi
33
34# fmri must exist
35svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG
36
paul9b78d052005-06-15 11:00:11 +000037case ${INSTANCE} in
Paul Jakmae24f0632006-02-19 18:59:26 +000038 zebra | bgpd )
39 ;;
40 ospfd | ospf6d | ripd | ripngd )
41 /usr/sbin/svcadm enable zebra
paul1b414a12005-04-11 07:05:21 +000042 ;;
43 *)
44 usage
45 exit $SMF_EXIT_ERR_CONFIG;
46 ;;
47esac
48
paul9b78d052005-06-15 11:00:11 +000049svcprop -q -p @PACKAGE_TARNAME@/config_file ${FMRI} && \
50 CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}`
51svcprop -q -p @PACKAGE_TARNAME@/pid_file ${FMRI} && \
52 PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}`
53svcprop -q -p @PACKAGE_TARNAME@/user ${FMRI} && \
54 USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}`
55svcprop -q -p @PACKAGE_TARNAME@/group ${FMRI} && \
56 GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}`
57svcprop -q -p @PACKAGE_TARNAME@/vty_addr ${FMRI} && \
58 VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${FMRI}`
59svcprop -q -p @PACKAGE_TARNAME@/vty_port ${FMRI} && \
60 VTYPORT=`svcprop -p @PACKAGE_TARNAME@/vty_port ${FMRI}`
paul1b414a12005-04-11 07:05:21 +000061
62[ -n "${CONFFILE}" ] && ARGS=" -f ${CONFFILE}"
63[ -n "${PIDFILE}" ] && ARGS="${ARGS} --pid_file ${PIDFILE}"
64[ -n "${USER}" ] && ARGS="${ARGS} --user ${USER}"
65[ -n "${GROUP}" ] && ARGS="${ARGS} --group ${GROUP}"
paul9b78d052005-06-15 11:00:11 +000066
67# vty should default to disabled, ie port == 0
68[ -z "${VTYPORT}" ] && VTYPORT=0
69ARGS="${ARGS} --vty_port ${VTYPORT}"
70
71# default listen address should be localhost
72[ -z "${VTYADDR}" ] && VTYADDR=127.1
73ARGS="${ARGS} --vty_addr ${VTYADDR}"
paul1b414a12005-04-11 07:05:21 +000074
75# have to have a pid file for script to work
paul9b78d052005-06-15 11:00:11 +000076# we can assume it otherwise
77if [ -z "${PIDFILE}" ]; then
78 PIDFILE="@quagga_statedir@/${INSTANCE}.pid"
79else
80 ARGS="${ARGS} --pid_file ${PIDFILE}"
81fi
paul1b414a12005-04-11 07:05:21 +000082
paul9b78d052005-06-15 11:00:11 +000083# we need @quagga_statedir@ to exist, it might be on tmpfs.
84if [ ! -d @quagga_statedir@ ] ; then
85 mkdir -p @quagga_statedir@
86 chown @enable_user@:@enable_group@ @quagga_statedir@
87 chmod 751 @quagga_statedir@
88fi
89
paul1b414a12005-04-11 07:05:21 +000090start () {
paul9b78d052005-06-15 11:00:11 +000091 @sbindir@/${INSTANCE} ${ARGS} &
paul1b414a12005-04-11 07:05:21 +000092}
93
94stop () {
95 if [ -f "${PIDFILE}" ]; then
96 /usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"`
97 fi
98}
99
paul1b414a12005-04-11 07:05:21 +0000100case $1 in
101'start')
102 start ${2}
103 ;;
104'stop')
105 stop ${2}
106 ;;
107
paul1b414a12005-04-11 07:05:21 +0000108*)
109 usage
110 exit 1
111 ;;
112esac
113
114exit $SMF_EXIT_OK;