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