#!/bin/sh
#
# Copyright (c) 1993, by Sun Microsystems, Inc.
#
#ident	"$Header: /net/projects/S2.6/cvs/os_net/src_ws/usr/src/tadcmd/locations/init.d/asppp,v 1.1 1997/10/09 10:36:53 ang Exp $"
#
#LocINFO Asynchronous Point to Point Protocol
#

procexist() {
    pid=`/usr/bin/ps -e | /usr/bin/grep " ${1}$" |
	     /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
    if [ -z "$pid" ]
    then
	return 1
    fi
    return 0
}

#
# Note that this script makes copies of the uucp setup files but do note replace
# or remove them on start/stop.
#
# You can put the following in /etc/uucp/Sysfiles to get aspppd to use
# ppp specific configuration files:
#
#	service=ppp	systems=Systems.ppp \
#			dialers=Dialers.ppp \
#			devices=Devices.ppp
#

case "$1" in

'start')
    cp -p $LOCDB/etc/asppp.cf /etc 2>/dev/null
#    cp -p $LOCDB/etc/uucp/*.ppp /etc/uucp
    ${SH} /etc/init.d/asppp $1
    ;;

'stop')
    ${SH} /etc/init.d/asppp $1
    rm -f /etc/asppp.cf
#    rm -f /etc/uucp/*.ppp
    ;;

'create')
    if [ -f /etc/asppp.cf ]
    then
    	cp -p /etc/asppp.cf $LOCDB/etc
    	if [ -f /etc/uucp/Systems.ppp ]
    	then
	    uuEXT=.ppp
    	fi
    	mkdir -p $LOCDB/etc/uucp
    	cp -p /etc/uucp/Systems${uuEXT} $LOCDB/etc/uucp/Systems.ppp 2>/dev/null
    	cp -p /etc/uucp/Devices${uuEXT} $LOCDB/etc/uucp/Devices.ppp 2>/dev/null
    	cp -p /etc/uucp/Dialers${uuEXT} $LOCDB/etc/uucp/Dialers.ppp 2>/dev/null
	exit `procexist aspppd`
    else
	exit 1
    fi
    ;;

*)
    echo "Usage: $0 { start | stop | create }" 1>&2
    ;;
esac

exit 0
