1 #!/sbin/sh 2 # 3 # CDDL HEADER START 4 # 5 # The contents of this file are subject to the terms of the 6 # Common Development and Distribution License (the "License"). 7 # You may not use this file except in compliance with the License. 8 # 9 # You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 # or http://www.opensolaris.org/os/licensing. 11 # See the License for the specific language governing permissions 12 # and limitations under the License. 13 # 14 # When distributing Covered Code, include this CDDL HEADER in each 15 # file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 # If applicable, add the following below this CDDL HEADER, with the 17 # fields enclosed by brackets "[]" replaced with your own identifying 18 # information: Portions Copyright [yyyy] [name of copyright owner] 19 # 20 # CDDL HEADER END 21 # 22 # 23 # Copyright 2007 Sun Microsystems, Inc. All rights reserved. 24 # Use is subject to license terms. 25 # 26 27 # This script is the shared method script for the legacy ipv4/ipv6 28 # routing services. 29 30 . /lib/svc/share/smf_include.sh 31 32 daemon_prog=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon | \ 33 /usr/xpg4/bin/awk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 34 /usr/xpg4/bin/awk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 35 daemon_args=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-args | \ 36 /usr/xpg4/bin/awk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 37 /usr/xpg4/bin/awk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 38 daemon_stop=`/usr/sbin/svccfg -s $SMF_FMRI listprop routeadm/daemon-stop-cmd | \ 39 /usr/xpg4/bin/awk '{ for (i = 3; i <= NF; i++) printf $i" " }' | \ 40 /usr/xpg4/bin/awk '{ sub(/^\"/,""); sub(/\"[ \t]*$/,""); print }'` 41 42 method="$1" 43 proto="$2" 44 45 case "$method" in 46 'start' ) 47 # No legacy daemon specified. 48 if [ -z "$daemon_prog" ]; then 49 echo "${proto}-routing-daemon not specified by routeadm." 50 exit $SMF_EXIT_ERR_CONFIG 51 fi 52 # No legacy stop command specified. 53 if [ -z "$daemon_stop" ]; then 54 echo "${proto}-routing-stop-cmd not specified by routeadm." 55 exit $SMF_EXIT_ERR_CONFIG 56 fi 57 smf_configure_ip || exit $SMF_EXIT_OK 58 59 # Run daemon - fail if it does not successfully daemonize. 60 eval "$daemon_prog $daemon_args" 61 if [ "$?" != "0" ]; then 62 echo "Error: $daemon $daemon_args failed to daemonize." 63 exit $SMF_EXIT_ERR_FATAL 64 fi 65 # Create pidfile. 66 daemon_name=`/usr/bin/basename $daemon_prog` 67 if smf_is_globalzone; then 68 /usr/bin/pgrep -P 1 -z `smf_zonename` -f $daemon_prog > \ 69 /var/tmp/${daemon_name}.pid 70 else 71 /usr/bin/pgrep -z `smf_zonename` -f $daemon_prog > \ 72 /var/tmp/${daemon_name}.pid 73 fi 74 ;; 75 'stop' ) 76 smf_configure_ip || exit $SMF_EXIT_OK 77 78 # Stop daemon - ignore result. 79 if [ -n "$daemon_stop" ]; then 80 eval "$daemon_stop" 81 fi 82 ;; 83 '*' ) 84 echo "Usage: $0 { start | stop }" 85 exit $SMF_EXIT_ERR_FATAL 86 ;; 87 esac 88 89 exit "$SMF_EXIT_OK"