1*25cf1a30Sjl#!/bin/sh 2*25cf1a30Sjl# 3*25cf1a30Sjl# CDDL HEADER START 4*25cf1a30Sjl# 5*25cf1a30Sjl# The contents of this file are subject to the terms of the 6*25cf1a30Sjl# Common Development and Distribution License (the "License"). 7*25cf1a30Sjl# You may not use this file except in compliance with the License. 8*25cf1a30Sjl# 9*25cf1a30Sjl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*25cf1a30Sjl# or http://www.opensolaris.org/os/licensing. 11*25cf1a30Sjl# See the License for the specific language governing permissions 12*25cf1a30Sjl# and limitations under the License. 13*25cf1a30Sjl# 14*25cf1a30Sjl# When distributing Covered Code, include this CDDL HEADER in each 15*25cf1a30Sjl# file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*25cf1a30Sjl# If applicable, add the following below this CDDL HEADER, with the 17*25cf1a30Sjl# fields enclosed by brackets "[]" replaced with your own identifying 18*25cf1a30Sjl# information: Portions Copyright [yyyy] [name of copyright owner] 19*25cf1a30Sjl# 20*25cf1a30Sjl# CDDL HEADER END 21*25cf1a30Sjl# 22*25cf1a30Sjl# 23*25cf1a30Sjl# Copyright 2006 Sun Microsystems, Inc. All rights reserved. 24*25cf1a30Sjl# Use is subject to license terms. 25*25cf1a30Sjl# 26*25cf1a30Sjl# ident "%Z%%M% %I% %E% SMI" 27*25cf1a30Sjl# 28*25cf1a30Sjl 29*25cf1a30Sjl# 30*25cf1a30Sjl# Start script for the SPARC-Enterprise DSCP service. 31*25cf1a30Sjl# 32*25cf1a30Sjl 33*25cf1a30Sjl. /lib/svc/share/smf_include.sh 34*25cf1a30Sjl 35*25cf1a30SjlOPL=SUNW,SPARC-Enterprise 36*25cf1a30SjlFJOPL=FJSV,SPARC-Enterprise 37*25cf1a30SjlTMPOPL=SUNW,OPL-Enterprise 38*25cf1a30SjlOPL_LIB=/usr/platform/${OPL}/lib 39*25cf1a30SjlDM2S_DEVICE=/dev/dm2s0 40*25cf1a30SjlPPP_OPTIONS=${OPL_LIB}/dscp.ppp.options 41*25cf1a30SjlDSCP_IFNAME=/var/run/dscp.ifname 42*25cf1a30SjlPRTDSCP=/usr/platform/${OPL}/sbin/prtdscp 43*25cf1a30SjlPLATFORM=`/sbin/uname -i` 44*25cf1a30SjlSLEEP=/bin/sleep 45*25cf1a30SjlPKILL=/bin/pkill 46*25cf1a30Sjl 47*25cf1a30SjlLD_LIBRARY_PATH=/lib:${OPL_LIB}; export LD_LIBRARY_PATH 48*25cf1a30Sjl 49*25cf1a30Sjl# This service can only run on OPL. 50*25cf1a30Sjlif [ "${PLATFORM}" != "${OPL}" -a \ 51*25cf1a30Sjl "${PLATFORM}" != "${FJOPL}" -a \ 52*25cf1a30Sjl "${PLATFORM}" != "${TMPOPL}" ]; then 53*25cf1a30Sjl 54*25cf1a30Sjl exit $SMF_EXIT_ERR_CONFIG 55*25cf1a30Sjlfi 56*25cf1a30Sjl 57*25cf1a30Sjlcase "$1" in 58*25cf1a30Sjl'start') 59*25cf1a30Sjl 60*25cf1a30Sjl if [ ! -x /usr/bin/pppd ]; then 61*25cf1a30Sjl exit $SMF_EXIT_ERR_CONFIG 62*25cf1a30Sjl fi 63*25cf1a30Sjl 64*25cf1a30Sjl if [ ! -c $DM2S_DEVICE ]; then 65*25cf1a30Sjl exit $SMF_EXIT_ERR_CONFIG 66*25cf1a30Sjl fi 67*25cf1a30Sjl 68*25cf1a30Sjl if [ ! -f $PPP_OPTIONS ]; then 69*25cf1a30Sjl exit $SMF_EXIT_ERR_CONFIG 70*25cf1a30Sjl fi 71*25cf1a30Sjl 72*25cf1a30Sjl SUCCESS=0 73*25cf1a30Sjl for UNIT in 0 1 2 3 4 5 6 7 8 9; do 74*25cf1a30Sjl /usr/bin/pppd $DM2S_DEVICE unit $UNIT file $PPP_OPTIONS 75*25cf1a30Sjl if [ ! "$?" = "1" ]; then 76*25cf1a30Sjl echo "sppp$UNIT" > $DSCP_IFNAME 77*25cf1a30Sjl SUCCESS=1 78*25cf1a30Sjl break 79*25cf1a30Sjl fi 80*25cf1a30Sjl done 81*25cf1a30Sjl 82*25cf1a30Sjl if [ $SUCCESS -ne 1 ]; then 83*25cf1a30Sjl exit $SMF_EXIT_ERR_FATAL 84*25cf1a30Sjl fi 85*25cf1a30Sjl 86*25cf1a30Sjl # Wait for the DSCP link to come up, but only for 30 seconds 87*25cf1a30Sjl for RETRY in 0 1 2 3 4 5; do 88*25cf1a30Sjl ${PRTDSCP} >/dev/null 2>&1 89*25cf1a30Sjl if [ $? -eq 0 ]; then 90*25cf1a30Sjl exit $SMF_EXIT_OK 91*25cf1a30Sjl fi 92*25cf1a30Sjl ${SLEEP} 5 93*25cf1a30Sjl done 94*25cf1a30Sjl 95*25cf1a30Sjl # Stop pppd before we return failure 96*25cf1a30Sjl ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}" 97*25cf1a30Sjl ${SLEEP} 1 98*25cf1a30Sjl ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}" 99*25cf1a30Sjl rm -f $DSCP_IFNAME 100*25cf1a30Sjl exit $SMF_EXIT_ERR_FATAL 101*25cf1a30Sjl ;; 102*25cf1a30Sjl 103*25cf1a30Sjl'stop') 104*25cf1a30Sjl # First try SIGTERM and then SIGKILL 105*25cf1a30Sjl ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}" 106*25cf1a30Sjl ${SLEEP} 1 107*25cf1a30Sjl ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}" 108*25cf1a30Sjl rm -f $DSCP_IFNAME 109*25cf1a30Sjl exit $SMF_EXIT_OK 110*25cf1a30Sjl ;; 111*25cf1a30Sjlesac 112