Article Listing 1 Listing 2 Listing 3 nov2005.tar

Listing 3 check-pppoe.sh init.d startup procedure

#! /bin/sh

PATH=/usr/local/sbin:/usr/sbin:/sbin:/opt/sbin
N=$0
CHECKPPPOE=`type -p check-pppoe.daemon`

#
# Exit if the PPPoE checking daemon isn't installed.
#

[ -z "$CHECKPPPOE" ] && exit 1

pppoeName=${CHECKPPPOE##/*/}
pppoeBaseName=${pppoeName%%.*}

case "$1" in
  restart)
    $N stop
    $N start
    ;;
  start)
    echo "Starting daemon: check-pppoe"
    start-stop-daemon --start \
    --pidfile /var/run/$pppoeBaseName.pid \
    --background \
    --startas $CHECKPPPOE
    ;;
  stop)
    echo "Stoping daemon: check-pppoe"
    start-stop-daemon --stop \
    --quiet \
    --pidfile /var/run/$pppoeBaseName.pid \
    1>/dev/null
    ;;
  *)
    echo "Usage: $N {start|stop|restart}" >&2
    exit 1
    ;;
esac

exit 0