13048Samaguire#!/sbin/sh 23048Samaguire# 33048Samaguire# CDDL HEADER START 43048Samaguire# 53048Samaguire# The contents of this file are subject to the terms of the 63048Samaguire# Common Development and Distribution License (the "License"). 73048Samaguire# You may not use this file except in compliance with the License. 83048Samaguire# 93048Samaguire# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 103048Samaguire# or http://www.opensolaris.org/os/licensing. 113048Samaguire# See the License for the specific language governing permissions 123048Samaguire# and limitations under the License. 133048Samaguire# 143048Samaguire# When distributing Covered Code, include this CDDL HEADER in each 153048Samaguire# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 163048Samaguire# If applicable, add the following below this CDDL HEADER, with the 173048Samaguire# fields enclosed by brackets "[]" replaced with your own identifying 183048Samaguire# information: Portions Copyright [yyyy] [name of copyright owner] 193048Samaguire# 203048Samaguire# CDDL HEADER END 213048Samaguire# 223048Samaguire# 23*3448Sdh155122# Copyright 2007 Sun Microsystems, Inc. All rights reserved. 243048Samaguire# Use is subject to license terms. 253048Samaguire# 263048Samaguire# ident "%Z%%M% %I% %E% SMI" 273048Samaguire 283048Samaguire# This script is the shared method script for the legacy ipv4/ipv6 293048Samaguire# routing services. 303048Samaguire 313048Samaguire. /lib/svc/share/smf_include.sh 323048Samaguire 333048Samaguiredaemon_prog=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon | \ 343048Samaguire /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 353048Samaguire /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 363048Samaguiredaemon_args=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-args | \ 373048Samaguire /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 383048Samaguire /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 393048Samaguiredaemon_stop=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-stop-cmd | \ 403048Samaguire /usr/bin/nawk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 413048Samaguire /usr/bin/nawk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 423048Samaguire 433048Samaguiremethod="$1" 443048Samaguireproto="$2" 453048Samaguire 463048Samaguirecase "$method" in 473048Samaguire'start' ) 483048Samaguire # No legacy daemon specified. 493048Samaguire if [ -z "$daemon_prog" ]; then 503048Samaguire echo "${proto}-routing-daemon not specified by routeadm." 513048Samaguire exit $SMF_EXIT_ERR_CONFIG 523048Samaguire fi 533048Samaguire # No legacy stop command specified. 543048Samaguire if [ -z "$daemon_stop" ]; then 553048Samaguire echo "${proto}-routing-stop-cmd not specified by routeadm." 563048Samaguire exit $SMF_EXIT_ERR_CONFIG 573048Samaguire fi 58*3448Sdh155122 smf_configure_ip || exit $SMF_EXIT_OK 593048Samaguire 603048Samaguire # Run daemon - fail if it does not successfully daemonize. 613048Samaguire eval "$daemon_prog $daemon_args" 623048Samaguire if [ "$?" != "0" ]; then 633048Samaguire echo "Error: $daemon $daemon_args failed to daemonize." 643048Samaguire exit $SMF_EXIT_ERR_FATAL 653048Samaguire fi 663048Samaguire # Create pidfile. 673048Samaguire daemon_name=`/usr/bin/basename $daemon_prog` 68*3448Sdh155122 if smf_is_globalzone; then 69*3448Sdh155122 /usr/bin/pgrep -P 1 -z `smf_zonename` -f $daemon_prog > \ 70*3448Sdh155122 /var/tmp/${daemon_name}.pid 71*3448Sdh155122 else 72*3448Sdh155122 /usr/bin/pgrep -z `smf_zonename` -f $daemon_prog > \ 73*3448Sdh155122 /var/tmp/${daemon_name}.pid 74*3448Sdh155122 fi 753048Samaguire ;; 763048Samaguire'stop' ) 77*3448Sdh155122 smf_configure_ip || exit $SMF_EXIT_OK 783048Samaguire 793048Samaguire # Stop daemon - ignore result. 803048Samaguire if [ -n "$daemon_stop" ]; then 813048Samaguire eval "$daemon_stop" 823048Samaguire fi 833048Samaguire ;; 843048Samaguire'*' ) 853048Samaguire echo "Usage: $0 { start | stop }" 863048Samaguire exit $SMF_EXIT_ERR_FATAL 873048Samaguire ;; 883048Samaguireesac 893048Samaguire 903048Samaguireexit "$SMF_EXIT_OK" 91