blob: 02fdc60d235fce2a550cc8c4cd25a1da20a96dc5 [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#
6# $Id: quagga.init.in,v 1.1 2005/04/11 07:05:21 paul Exp $
7#
8# Starts/stops the appropriate daemon
9
10SMFINCLUDE=/lib/svc/share/smf_include.sh
11
12if [ -f "$SMFINCLUDE" ] ; then
13 . "$SMFINCLUDE";
14fi
15
16usage () {
17 echo "Usage: $0 (start|stop) <fmri>";
18}
19
20case $1 in
21 'help' | 'usage')
22 usage
23 ;;
24esac
25
26# fmri must be given.
27FMRI="$2"
28if [ -z "$FMRI" ]; then
29 usage
30 exit $SMF_EXIT_ERR_CONFIG
31fi
32
33# fmri must exist
34svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG
35
36DAEMON=`svcprop -p @PACKAGE_NAME@/daemon_name ${FMRI} 2> /dev/null`
37[ -z "${DAEMON}" ] && exit $SMF_EXIT_ERR_CONFIG
38
39case ${DAEMON} in
40 zebra | ospfd | ospf6d | ripd | ripngd | bgpd )
41 ;;
42 *)
43 usage
44 exit $SMF_EXIT_ERR_CONFIG;
45 ;;
46esac
47
48CONFFILE=`svcprop -p @PACKAGE_NAME@/config_file ${FMRI}`
49PIDFILE=`svcprop -p @PACKAGE_NAME@/pid_file ${FMRI}`
50USER=`svcprop -p @PACKAGE_NAME@/user ${FMRI}`
51GROUP=`svcprop -p @PACKAGE_NAME@/group ${FMRI}`
52VTYADDR=`svcprop -p @PACKAGE_NAME@/vty_addr ${FMRI}`
53VTYPORT=`svcprop -p @PACKAGE_NAME@/vty_port ${FMRI}`
54
55[ -n "${CONFFILE}" ] && ARGS=" -f ${CONFFILE}"
56[ -n "${PIDFILE}" ] && ARGS="${ARGS} --pid_file ${PIDFILE}"
57[ -n "${USER}" ] && ARGS="${ARGS} --user ${USER}"
58[ -n "${GROUP}" ] && ARGS="${ARGS} --group ${GROUP}"
59[ -n "${VTYPORT}" ] && ARGS="${ARGS} --vty_port ${VTYPORT}"
60[ -n "${VTYADDR}" ] && ARGS="${ARGS} --vty_addr ${VTYADDR}"
61
62# have to have a pid file for script to work
63[ -z "${PIDFILE}" ] && exit $SMF_EXIT_ERR_CONFIG
64
65# config file must exist
66[ ! -f "$CONFFILE" ] && exit $SMF_EXIT_ERR_CONFIG
67
68start () {
69 /usr/local/quagga/sbin/${DAEMON} ${ARGS} &
70}
71
72stop () {
73 if [ -f "${PIDFILE}" ]; then
74 /usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"`
75 fi
76}
77
78restart() {
79 stop ${daemon}
80 sleep 1
81 start ${daemon}
82}
83
84case $1 in
85'start')
86 start ${2}
87 ;;
88'stop')
89 stop ${2}
90 ;;
91
92'restart')
93 restart ${2}
94 ;;
95*)
96 usage
97 exit 1
98 ;;
99esac
100
101exit $SMF_EXIT_OK;