dmake: do not set MAKEFLAGS=k
[unleashed/tickless.git] / usr / src / lib / libdscp / svc / svc-dscp
blob768f87be3b89578c60b10e79a9957f2557d8831d
1 #!/bin/sh
3 # CDDL HEADER START
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.
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.
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]
20 # CDDL HEADER END
23 # Copyright 2006 Sun Microsystems, Inc. All rights reserved.
24 # Use is subject to license terms.
26 # ident "%Z%%M% %I% %E% SMI"
30 # Start script for the SPARC-Enterprise DSCP service.
33 . /lib/svc/share/smf_include.sh
35 OPL=SUNW,SPARC-Enterprise
36 OPL_LIB=/usr/platform/${OPL}/lib
37 DM2S_DEVICE=/dev/dm2s0
38 PPP_OPTIONS=${OPL_LIB}/dscp.ppp.options
39 DSCP_IFNAME=/var/run/dscp.ifname
40 PRTDSCP=/usr/platform/${OPL}/sbin/prtdscp
41 PLATFORM=`/usr/bin/uname -i`
42 SLEEP=/bin/sleep
43 PKILL=/bin/pkill
45 LD_LIBRARY_PATH=/lib:${OPL_LIB}; export LD_LIBRARY_PATH
47 # This service can only run on OPL.
48 if [ "${PLATFORM}" != "${OPL}" ]; then
49 exit $SMF_EXIT_ERR_CONFIG
52 case "$1" in
53 'start')
55 if [ ! -x /usr/bin/pppd ]; then
56 exit $SMF_EXIT_ERR_CONFIG
59 if [ ! -c $DM2S_DEVICE ]; then
60 exit $SMF_EXIT_ERR_CONFIG
63 if [ ! -f $PPP_OPTIONS ]; then
64 exit $SMF_EXIT_ERR_CONFIG
67 SUCCESS=0
68 for UNIT in 0 1 2 3 4 5 6 7 8 9; do
69 /usr/bin/pppd $DM2S_DEVICE unit $UNIT file $PPP_OPTIONS
70 if [ ! "$?" = "1" ]; then
71 echo "sppp$UNIT" > $DSCP_IFNAME
72 SUCCESS=1
73 break
75 done
77 if [ $SUCCESS -ne 1 ]; then
78 exit $SMF_EXIT_ERR_FATAL
81 # Wait for the DSCP link to come up, but only for 30 seconds
82 for RETRY in 0 1 2 3 4 5; do
83 ${PRTDSCP} >/dev/null 2>&1
84 if [ $? -eq 0 ]; then
85 exit $SMF_EXIT_OK
87 ${SLEEP} 5
88 done
90 # Stop pppd before we return failure
91 ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
92 ${SLEEP} 1
93 ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
94 rm -f $DSCP_IFNAME
95 exit $SMF_EXIT_ERR_FATAL
98 'stop')
99 # First try SIGTERM and then SIGKILL
100 ${PKILL} -TERM -f "pppd ${DM2S_DEVICE}"
101 ${SLEEP} 1
102 ${PKILL} -KILL -f "pppd ${DM2S_DEVICE}"
103 rm -f $DSCP_IFNAME
104 exit $SMF_EXIT_OK
106 esac