From 9b78d0528ad6756b051d82faddfa2c3422403a2e Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 15 Jun 2005 11:00:11 +0000 Subject: 2005-06-15 Paul Jakma * quagga.xml.in: Pass the FMRI to the method, removing need for daemon_name property and deducing the FMRI. remove the empty config_file and pid_file definitions, they just make things difficult in the method script, cause it then has to deal with svcprop returning "" for defined empty properties. Remove daemon_name everywhere. * quagga.init.in: Take the FMRI as an argument Remove deducing the FMRI from the defunct daemon_name property. Use svcprop -q to test for presence of a property first. Default vty_port to 0 and vty_addr to 127.1 if equivalent SMF properties are not set. Deduce the pid_file, we can infer it from @quagga_statedir@ I think, it's probably not useful to allow it to be configurable as a property anyway. /var/run/ is on tmpfs on Solaris, so we probably will need to create @quagga_statedir@ first run after boot. Use @sbindir@, not /usr/local/sbin. --- solaris/ChangeLog | 20 ++++++++++++++++ solaris/quagga.init.in | 62 ++++++++++++++++++++++++++++++++++---------------- solaris/quagga.xml.in | 31 ++++--------------------- 3 files changed, 67 insertions(+), 46 deletions(-) diff --git a/solaris/ChangeLog b/solaris/ChangeLog index 0713a1f2..ab0c618e 100644 --- a/solaris/ChangeLog +++ b/solaris/ChangeLog @@ -1,3 +1,23 @@ +2005-06-15 Paul Jakma + + * quagga.xml.in: Pass the FMRI to the method, removing need for + daemon_name property and deducing the FMRI. + remove the empty config_file and pid_file definitions, they just + make things difficult in the method script, cause it then has to + deal with svcprop returning "" for defined empty properties. + Remove daemon_name everywhere. + * quagga.init.in: Take the FMRI as an argument + Remove deducing the FMRI from the defunct daemon_name property. + Use svcprop -q to test for presence of a property first. + Default vty_port to 0 and vty_addr to 127.1 if equivalent + SMF properties are not set. + Deduce the pid_file, we can infer it from @quagga_statedir@ I + think, it's probably not useful to allow it to be configurable + as a property anyway. + /var/run/ is on tmpfs on Solaris, so we probably will need + to create @quagga_statedir@ first run after boot. + Use @sbindir@, not /usr/local/sbin. + 2005-06-02 Paul Jakma * quagga.xml.in: Fix mistake in bgpd definition. Change dependency diff --git a/solaris/quagga.init.in b/solaris/quagga.init.in index 1d3a5cd3..ba3b484a 100755 --- a/solaris/quagga.init.in +++ b/solaris/quagga.init.in @@ -3,7 +3,7 @@ # Copyright 2001,2003 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # -# $Id: quagga.init.in,v 1.3 2005/06/02 16:33:53 paul Exp $ +# $Id: quagga.init.in,v 1.4 2005/06/15 11:00:11 paul Exp $ # # Starts/stops the appropriate daemon @@ -14,7 +14,7 @@ if [ -f "$SMFINCLUDE" ] ; then fi usage () { - echo "Usage: $0 (start|stop) "; + echo "Usage: $0 (start|stop) "; } case $1 in @@ -23,9 +23,10 @@ case $1 in ;; esac -# fmri must be given. +# fmri and instance must be given. FMRI="$2" -if [ -z "$FMRI" ]; then +INSTANCE="$3" +if [ -z "$FMRI" -o -z "$INSTANCE" ]; then usage exit $SMF_EXIT_ERR_CONFIG fi @@ -33,10 +34,7 @@ fi # fmri must exist svcs ${FMRI} > /dev/null 2>&1 || exit $SMF_EXIT_ERR_CONFIG -DAEMON=`svcprop -p @PACKAGE_TARNAME@/daemon_name ${FMRI} 2> /dev/null` -[ -z "${DAEMON}" ] && exit $SMF_EXIT_ERR_CONFIG - -case ${DAEMON} in +case ${INSTANCE} in zebra | ospfd | ospf6d | ripd | ripngd | bgpd ) ;; *) @@ -45,28 +43,52 @@ case ${DAEMON} in ;; esac -CONFFILE=`svcprop -p @PACKAGE_TARNAME@/config_file ${FMRI}` -PIDFILE=`svcprop -p @PACKAGE_TARNAME@/pid_file ${FMRI}` -USER=`svcprop -p @PACKAGE_TARNAME@/user ${FMRI}` -GROUP=`svcprop -p @PACKAGE_TARNAME@/group ${FMRI}` -VTYADDR=`svcprop -p @PACKAGE_TARNAME@/vty_addr ${FMRI}` -VTYPORT=`svcprop -p @PACKAGE_TARNAME@/vty_port ${FMRI}` +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}" -[ -n "${VTYPORT}" ] && ARGS="${ARGS} --vty_port ${VTYPORT}" -[ -n "${VTYADDR}" ] && ARGS="${ARGS} --vty_addr ${VTYADDR}" + +# 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 -[ -z "${PIDFILE}" ] && exit $SMF_EXIT_ERR_CONFIG +# we can assume it otherwise +if [ -z "${PIDFILE}" ]; then + PIDFILE="@quagga_statedir@/${INSTANCE}.pid" +else + ARGS="${ARGS} --pid_file ${PIDFILE}" +fi # config file must exist #[ ! -f "$CONFFILE" ] && exit $SMF_EXIT_ERR_CONFIG +# 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 () { - /usr/local/quagga/sbin/${DAEMON} ${ARGS} & + @sbindir@/${INSTANCE} ${ARGS} & } stop () { @@ -76,9 +98,9 @@ stop () { } restart() { - stop ${DAEMON} + stop ${INSTANCE} sleep 1 - start ${DAEMON} + start ${INSTANCE} } case $1 in diff --git a/solaris/quagga.xml.in b/solaris/quagga.xml.in index 1de74ffb..dfa2eb6b 100644 --- a/solaris/quagga.xml.in +++ b/solaris/quagga.xml.in @@ -39,19 +39,19 @@ - - @@ -89,8 +87,6 @@ -