paul | 1b414a1 | 2005-04-11 07:05:21 +0000 | [diff] [blame] | 1 | #!/sbin/sh |
| 2 | # |
| 3 | # Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved. |
| 4 | # Use is subject to license terms. |
| 5 | # |
paul | 2e7d9eb | 2005-04-26 02:35:03 +0000 | [diff] [blame^] | 6 | # $Id: quagga.init.in,v 1.2 2005/04/26 02:35:03 paul Exp $ |
paul | 1b414a1 | 2005-04-11 07:05:21 +0000 | [diff] [blame] | 7 | # |
| 8 | # Starts/stops the appropriate daemon |
| 9 | |
| 10 | SMFINCLUDE=/lib/svc/share/smf_include.sh |
| 11 | |
| 12 | if [ -f "$SMFINCLUDE" ] ; then |
| 13 | . "$SMFINCLUDE"; |
| 14 | fi |
| 15 | |
| 16 | usage () { |
| 17 | echo "Usage: $0 (start|stop) <fmri>"; |
| 18 | } |
| 19 | |
| 20 | case $1 in |
| 21 | 'help' | 'usage') |
| 22 | usage |
| 23 | ;; |
| 24 | esac |
| 25 | |
| 26 | # fmri must be given. |
| 27 | FMRI="$2" |
| 28 | if [ -z "$FMRI" ]; then |
| 29 | usage |
| 30 | exit $SMF_EXIT_ERR_CONFIG |
| 31 | fi |
| 32 | |
| 33 | # fmri must exist |
| 34 | svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG |
| 35 | |
| 36 | DAEMON=`svcprop -p @PACKAGE_NAME@/daemon_name ${FMRI} 2> /dev/null` |
| 37 | [ -z "${DAEMON}" ] && exit $SMF_EXIT_ERR_CONFIG |
| 38 | |
| 39 | case ${DAEMON} in |
| 40 | zebra | ospfd | ospf6d | ripd | ripngd | bgpd ) |
| 41 | ;; |
| 42 | *) |
| 43 | usage |
| 44 | exit $SMF_EXIT_ERR_CONFIG; |
| 45 | ;; |
| 46 | esac |
| 47 | |
paul | 2e7d9eb | 2005-04-26 02:35:03 +0000 | [diff] [blame^] | 48 | CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}` |
| 49 | PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}` |
| 50 | USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}` |
| 51 | GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}` |
| 52 | VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${FMRI}` |
| 53 | VTYPORT=`svcprop -p @PACKAGE_TARNAME@/vty_port ${FMRI}` |
paul | 1b414a1 | 2005-04-11 07:05:21 +0000 | [diff] [blame] | 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 | |
| 68 | start () { |
| 69 | /usr/local/quagga/sbin/${DAEMON} ${ARGS} & |
| 70 | } |
| 71 | |
| 72 | stop () { |
| 73 | if [ -f "${PIDFILE}" ]; then |
| 74 | /usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"` |
| 75 | fi |
| 76 | } |
| 77 | |
| 78 | restart() { |
paul | 2e7d9eb | 2005-04-26 02:35:03 +0000 | [diff] [blame^] | 79 | stop ${DAEMON} |
paul | 1b414a1 | 2005-04-11 07:05:21 +0000 | [diff] [blame] | 80 | sleep 1 |
paul | 2e7d9eb | 2005-04-26 02:35:03 +0000 | [diff] [blame^] | 81 | start ${DAEMON} |
paul | 1b414a1 | 2005-04-11 07:05:21 +0000 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | case $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 | ;; |
| 99 | esac |
| 100 | |
| 101 | exit $SMF_EXIT_OK; |