xref: /onnv-gate/usr/src/lib/libdscp/svc/svc-dscp (revision 2117:fd716e844862)
11772Sjl139090#!/bin/sh
21772Sjl139090#
31772Sjl139090# CDDL HEADER START
41772Sjl139090#
51772Sjl139090# The contents of this file are subject to the terms of the
61772Sjl139090# Common Development and Distribution License (the "License").
71772Sjl139090# You may not use this file except in compliance with the License.
81772Sjl139090#
91772Sjl139090# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
101772Sjl139090# or http://www.opensolaris.org/os/licensing.
111772Sjl139090# See the License for the specific language governing permissions
121772Sjl139090# and limitations under the License.
131772Sjl139090#
141772Sjl139090# When distributing Covered Code, include this CDDL HEADER in each
151772Sjl139090# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
161772Sjl139090# If applicable, add the following below this CDDL HEADER, with the
171772Sjl139090# fields enclosed by brackets "[]" replaced with your own identifying
181772Sjl139090# information: Portions Copyright [yyyy] [name of copyright owner]
191772Sjl139090#
201772Sjl139090# CDDL HEADER END
211772Sjl139090#
221772Sjl139090#
231772Sjl139090# Copyright 2006 Sun Microsystems, Inc.	 All rights reserved.
241772Sjl139090# Use is subject to license terms.
251772Sjl139090#
261772Sjl139090# ident	"%Z%%M%	%I%	%E% SMI"
271772Sjl139090#
281772Sjl139090
291772Sjl139090#
301772Sjl139090# Start script for the SPARC-Enterprise DSCP service.
311772Sjl139090#
321772Sjl139090
331772Sjl139090. /lib/svc/share/smf_include.sh
341772Sjl139090
351772Sjl139090OPL=SUNW,SPARC-Enterprise
361772Sjl139090OPL_LIB=/usr/platform/${OPL}/lib
371772Sjl139090DM2S_DEVICE=/dev/dm2s0
381772Sjl139090PPP_OPTIONS=${OPL_LIB}/dscp.ppp.options
391772Sjl139090DSCP_IFNAME=/var/run/dscp.ifname
401772Sjl139090PRTDSCP=/usr/platform/${OPL}/sbin/prtdscp
411772Sjl139090PLATFORM=`/sbin/uname -i`
421772Sjl139090SLEEP=/bin/sleep
431772Sjl139090PKILL=/bin/pkill
441772Sjl139090
451772Sjl139090LD_LIBRARY_PATH=/lib:${OPL_LIB}; export LD_LIBRARY_PATH
461772Sjl139090
471772Sjl139090# This service can only run on OPL.
48*2117Smcwalterif  [ "${PLATFORM}" != "${OPL}" ]; then
491772Sjl139090	exit $SMF_EXIT_ERR_CONFIG
501772Sjl139090fi
511772Sjl139090
521772Sjl139090case "$1" in
531772Sjl139090'start')
541772Sjl139090
551772Sjl139090	if [ ! -x /usr/bin/pppd ]; then
561772Sjl139090		exit $SMF_EXIT_ERR_CONFIG
571772Sjl139090	fi
581772Sjl139090
591772Sjl139090	if [ ! -c $DM2S_DEVICE ]; then
601772Sjl139090		exit $SMF_EXIT_ERR_CONFIG
611772Sjl139090	fi
621772Sjl139090
631772Sjl139090	if [ ! -f $PPP_OPTIONS ]; then
641772Sjl139090		exit $SMF_EXIT_ERR_CONFIG
651772Sjl139090	fi
661772Sjl139090
671772Sjl139090	SUCCESS=0
681772Sjl139090	for UNIT in 0 1 2 3 4 5 6 7 8 9; do
691772Sjl139090		/usr/bin/pppd $DM2S_DEVICE unit $UNIT file $PPP_OPTIONS
701772Sjl139090		if [ ! "$?" = "1" ]; then
711772Sjl139090			echo "sppp$UNIT" > $DSCP_IFNAME
721772Sjl139090			SUCCESS=1
731772Sjl139090			break
741772Sjl139090		fi
751772Sjl139090	done
761772Sjl139090
771772Sjl139090	if [ $SUCCESS -ne 1 ]; then
781772Sjl139090		exit $SMF_EXIT_ERR_FATAL
791772Sjl139090	fi
801772Sjl139090
811772Sjl139090	# Wait for the DSCP link to come up, but only for 30 seconds
821772Sjl139090	for RETRY in 0 1 2 3 4 5; do
831772Sjl139090		${PRTDSCP} >/dev/null 2>&1
841772Sjl139090		if [ $? -eq 0 ]; then
851772Sjl139090			exit $SMF_EXIT_OK
861772Sjl139090		fi
871772Sjl139090		${SLEEP} 5
881772Sjl139090	done
891772Sjl139090
901772Sjl139090	# Stop pppd before we return failure
911772Sjl139090	${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
921772Sjl139090	${SLEEP} 1
931772Sjl139090	${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
941772Sjl139090	rm -f $DSCP_IFNAME
951772Sjl139090	exit $SMF_EXIT_ERR_FATAL
961772Sjl139090	;;
971772Sjl139090
981772Sjl139090'stop')
991772Sjl139090	# First try SIGTERM and then SIGKILL
1001772Sjl139090	${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
1011772Sjl139090	${SLEEP} 1
1021772Sjl139090	${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
1031772Sjl139090	rm -f $DSCP_IFNAME
1041772Sjl139090	exit $SMF_EXIT_OK
1051772Sjl139090	;;
1061772Sjl139090esac
107