| #!/sbin/sh |
| # |
| # Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved. |
| # Use is subject to license terms. |
| # |
| # $Id: quagga.init.in,v 1.5 2006/02/19 18:59:26 paul Exp $ |
| # |
| # Starts/stops the appropriate daemon |
| |
| SMFINCLUDE=/lib/svc/share/smf_include.sh |
| |
| if [ -f "$SMFINCLUDE" ] ; then |
| . "$SMFINCLUDE"; |
| fi |
| |
| usage () { |
| echo "Usage: $0 (start|stop) <fmri> <instance>"; |
| } |
| |
| case $1 in |
| 'help' | 'usage') |
| usage |
| ;; |
| esac |
| |
| # fmri and instance must be given. |
| FMRI="$2" |
| INSTANCE="$3" |
| if [ -z "$FMRI" -o -z "$INSTANCE" ]; then |
| usage |
| exit $SMF_EXIT_ERR_CONFIG |
| fi |
| |
| # fmri must exist |
| svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG |
| |
| case ${INSTANCE} in |
| zebra | bgpd ) |
| ;; |
| ospfd | ospf6d | ripd | ripngd ) |
| /usr/sbin/svcadm enable zebra |
| ;; |
| *) |
| usage |
| exit $SMF_EXIT_ERR_CONFIG; |
| ;; |
| esac |
| |
| svcprop -q -p @PACKAGE_TARNAME@/config_file ${FMRI} && \ |
| CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}` |
| svcprop -q -p @PACKAGE_TARNAME@/pid_file ${FMRI} && \ |
| PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}` |
| svcprop -q -p @PACKAGE_TARNAME@/user ${FMRI} && \ |
| USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}` |
| svcprop -q -p @PACKAGE_TARNAME@/group ${FMRI} && \ |
| GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}` |
| svcprop -q -p @PACKAGE_TARNAME@/vty_addr ${FMRI} && \ |
| VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${FMRI}` |
| svcprop -q -p @PACKAGE_TARNAME@/vty_port ${FMRI} && \ |
| VTYPORT=`svcprop -p @PACKAGE_TARNAME@/vty_port ${FMRI}` |
| |
| [ -n "${CONFFILE}" ] && ARGS=" -f ${CONFFILE}" |
| [ -n "${PIDFILE}" ] && ARGS="${ARGS} --pid_file ${PIDFILE}" |
| [ -n "${USER}" ] && ARGS="${ARGS} --user ${USER}" |
| [ -n "${GROUP}" ] && ARGS="${ARGS} --group ${GROUP}" |
| |
| # vty should default to disabled, ie port == 0 |
| [ -z "${VTYPORT}" ] && VTYPORT=0 |
| ARGS="${ARGS} --vty_port ${VTYPORT}" |
| |
| # default listen address should be localhost |
| [ -z "${VTYADDR}" ] && VTYADDR=127.1 |
| ARGS="${ARGS} --vty_addr ${VTYADDR}" |
| |
| # have to have a pid file for script to work |
| # we can assume it otherwise |
| if [ -z "${PIDFILE}" ]; then |
| PIDFILE="@quagga_statedir@/${INSTANCE}.pid" |
| else |
| ARGS="${ARGS} --pid_file ${PIDFILE}" |
| fi |
| |
| # we need @quagga_statedir@ to exist, it might be on tmpfs. |
| if [ ! -d @quagga_statedir@ ] ; then |
| mkdir -p @quagga_statedir@ |
| chown @enable_user@:@enable_group@ @quagga_statedir@ |
| chmod 751 @quagga_statedir@ |
| fi |
| |
| start () { |
| @sbindir@/${INSTANCE} ${ARGS} & |
| } |
| |
| stop () { |
| if [ -f "${PIDFILE}" ]; then |
| /usr/bin/kill -TERM `/usr/bin/cat "${PIDFILE}"` |
| fi |
| } |
| |
| case $1 in |
| 'start') |
| start ${2} |
| ;; |
| 'stop') |
| stop ${2} |
| ;; |
| |
| *) |
| usage |
| exit 1 |
| ;; |
| esac |
| |
| exit $SMF_EXIT_OK; |