325N/A#!/sbin/sh
325N/A#
325N/A# CDDL HEADER START
325N/A#
325N/A# The contents of this file are subject to the terms of the
325N/A# Common Development and Distribution License (the "License").
325N/A# You may not use this file except in compliance with the License.
325N/A#
325N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
325N/A# or http://www.opensolaris.org/os/licensing.
325N/A# See the License for the specific language governing permissions
325N/A# and limitations under the License.
325N/A#
325N/A# When distributing Covered Code, include this CDDL HEADER in each
325N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
325N/A# If applicable, add the following below this CDDL HEADER, with the
325N/A# fields enclosed by brackets "[]" replaced with your own identifying
325N/A# information: Portions Copyright [yyyy] [name of copyright owner]
325N/A#
325N/A# CDDL HEADER END
325N/A#
325N/A#
325N/A# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
325N/A# Use is subject to license terms.
325N/A#
325N/A# ident "%Z%%M% %I% %E% SMI"
325N/A
325N/A# This script is the shared method script for the legacy ipv4/ipv6
325N/A# routing services.
325N/A
325N/A. /lib/svc/share/smf_include.sh
325N/A
325N/Adaemon_prog=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon | \
325N/A /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \
325N/A /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'`
325N/Adaemon_args=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-args | \
325N/A /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \
325N/A /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'`
325N/Adaemon_stop=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-stop-cmd | \
325N/A /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \
325N/A /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'`
325N/A
325N/Amethod="$1"
325N/Aproto="$2"
325N/A
325N/Acase "$method" in
325N/A'start' )
325N/A # No legacy daemon specified.
325N/A if [ -z "$daemon_prog" ]; then
325N/A echo "${proto}-routing-daemon not specified by routeadm."
325N/A exit $SMF_EXIT_ERR_CONFIG
325N/A fi
325N/A # No legacy stop command specified.
325N/A if [ -z "$daemon_stop" ]; then
325N/A echo "${proto}-routing-stop-cmd not specified by routeadm."
325N/A exit $SMF_EXIT_ERR_CONFIG
325N/A fi
325N/A smf_configure_ip || exit $SMF_EXIT_OK
325N/A
325N/A # Run daemon - fail if it does not successfully daemonize.
325N/A eval "$daemon_prog $daemon_args"
325N/A if [ "$?" != "0" ]; then
325N/A echo "Error: $daemon $daemon_args failed to daemonize."
325N/A exit $SMF_EXIT_ERR_FATAL
325N/A fi
325N/A # Create pidfile.
325N/A daemon_name=`/usr/bin/basename $daemon_prog`
325N/A if smf_is_globalzone; then
325N/A /usr/bin/pgrep -P 1 -z `smf_zonename` -f $daemon_prog > \
325N/A /var/tmp/${daemon_name}.pid
325N/A else
325N/A /usr/bin/pgrep -z `smf_zonename` -f $daemon_prog > \
325N/A /var/tmp/${daemon_name}.pid
325N/A fi
325N/A ;;
325N/A'stop' )
325N/A smf_configure_ip || exit $SMF_EXIT_OK
325N/A
325N/A # Stop daemon - ignore result.
325N/A if [ -n "$daemon_stop" ]; then
325N/A eval "$daemon_stop"
325N/A fi
325N/A ;;
325N/A'*' )
325N/A echo "Usage: $0 { start | stop }"
325N/A exit $SMF_EXIT_ERR_FATAL
325N/A ;;
325N/Aesac
325N/A
325N/Aexit "$SMF_EXIT_OK"
325N/A