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