25cf1a301a396c38e8adf52c15f537b80d2483f7jl#!/bin/sh
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# CDDL HEADER START
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# The contents of this file are subject to the terms of the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# Common Development and Distribution License (the "License").
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# You may not use this file except in compliance with the License.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# or http://www.opensolaris.org/os/licensing.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# See the License for the specific language governing permissions
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# and limitations under the License.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# When distributing Covered Code, include this CDDL HEADER in each
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# If applicable, add the following below this CDDL HEADER, with the
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# fields enclosed by brackets "[]" replaced with your own identifying
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# information: Portions Copyright [yyyy] [name of copyright owner]
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# CDDL HEADER END
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# Use is subject to license terms.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# ident "%Z%%M% %I% %E% SMI"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# Start script for the SPARC-Enterprise DSCP service.
25cf1a301a396c38e8adf52c15f537b80d2483f7jl#
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl. /lib/svc/share/smf_include.sh
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlOPL=SUNW,SPARC-Enterprise
25cf1a301a396c38e8adf52c15f537b80d2483f7jlOPL_LIB=/usr/platform/${OPL}/lib
25cf1a301a396c38e8adf52c15f537b80d2483f7jlDM2S_DEVICE=/dev/dm2s0
25cf1a301a396c38e8adf52c15f537b80d2483f7jlPPP_OPTIONS=${OPL_LIB}/dscp.ppp.options
25cf1a301a396c38e8adf52c15f537b80d2483f7jlDSCP_IFNAME=/var/run/dscp.ifname
25cf1a301a396c38e8adf52c15f537b80d2483f7jlPRTDSCP=/usr/platform/${OPL}/sbin/prtdscp
25cf1a301a396c38e8adf52c15f537b80d2483f7jlPLATFORM=`/sbin/uname -i`
25cf1a301a396c38e8adf52c15f537b80d2483f7jlSLEEP=/bin/sleep
25cf1a301a396c38e8adf52c15f537b80d2483f7jlPKILL=/bin/pkill
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlLD_LIBRARY_PATH=/lib:${OPL_LIB}; export LD_LIBRARY_PATH
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl# This service can only run on OPL.
0b05a701b49058a6d47b581827961c6c39b1071amcwalterif [ "${PLATFORM}" != "${OPL}" ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_CONFIG
25cf1a301a396c38e8adf52c15f537b80d2483f7jlfi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jlcase "$1" in
25cf1a301a396c38e8adf52c15f537b80d2483f7jl'start')
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ ! -x /usr/bin/pppd ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_CONFIG
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ ! -c $DM2S_DEVICE ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_CONFIG
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ ! -f $PPP_OPTIONS ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_CONFIG
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl SUCCESS=0
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for UNIT in 0 1 2 3 4 5 6 7 8 9; do
25cf1a301a396c38e8adf52c15f537b80d2483f7jl /usr/bin/pppd $DM2S_DEVICE unit $UNIT file $PPP_OPTIONS
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ ! "$?" = "1" ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl echo "sppp$UNIT" > $DSCP_IFNAME
25cf1a301a396c38e8adf52c15f537b80d2483f7jl SUCCESS=1
25cf1a301a396c38e8adf52c15f537b80d2483f7jl break
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl done
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ $SUCCESS -ne 1 ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_FATAL
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl # Wait for the DSCP link to come up, but only for 30 seconds
25cf1a301a396c38e8adf52c15f537b80d2483f7jl for RETRY in 0 1 2 3 4 5; do
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${PRTDSCP} >/dev/null 2>&1
25cf1a301a396c38e8adf52c15f537b80d2483f7jl if [ $? -eq 0 ]; then
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_OK
25cf1a301a396c38e8adf52c15f537b80d2483f7jl fi
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${SLEEP} 5
25cf1a301a396c38e8adf52c15f537b80d2483f7jl done
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl # Stop pppd before we return failure
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${SLEEP} 1
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl rm -f $DSCP_IFNAME
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_ERR_FATAL
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ;;
25cf1a301a396c38e8adf52c15f537b80d2483f7jl
25cf1a301a396c38e8adf52c15f537b80d2483f7jl'stop')
25cf1a301a396c38e8adf52c15f537b80d2483f7jl # First try SIGTERM and then SIGKILL
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${SLEEP} 1
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
25cf1a301a396c38e8adf52c15f537b80d2483f7jl rm -f $DSCP_IFNAME
25cf1a301a396c38e8adf52c15f537b80d2483f7jl exit $SMF_EXIT_OK
25cf1a301a396c38e8adf52c15f537b80d2483f7jl ;;
25cf1a301a396c38e8adf52c15f537b80d2483f7jlesac