1#! /bin/sh
2
3test -f /usr/sbin/pppoe-server || exit 0
4test -f /etc/default/pppoe-server && . /etc/default/pppoe-server
5
6case $1 in
7  start)
8    OPTIONS=""
9    if [ -n "$MSS" ]; then
10      OPTIONS="$OPTIONS -m $MSS"
11    fi
12    if [ -n "$DEVICES" ]; then
13      for i in $DEVICES; do
14        OPTIONS="$OPTIONS -I $i"
15      done
16    fi
17    if [ -n "$LOCAL_IP" ]; then
18      OPTIONS="$OPTIONS -L $LOCAL_IP"
19    fi
20    if [ -n "$REMOTE_IP" ]; then
21      OPTIONS="$OPTIONS -R $REMOTE_IP"
22    fi
23    if [ -n "$SERVICE_NAME" ]; then
24      OPTIONS="$OPTIONS -S $SERVICE_NAME"
25    fi
26    if [ -n "$MAX_SESSIONS" ]; then
27      OPTIONS="$OPTIONS -N $MAX_SESSIONS"
28    fi
29    if [ -n "$ACCESS_CONCENTRATOR_NAME" ]; then
30      OPTIONS="$OPTIONS -C $ACCESS_CONCENTRATOR_NAME"
31    fi
32    echo -n "Starting PPPoE server: pppoe-server"
33    start-stop-daemon --start --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS
34    echo "."
35    ;;
36  stop)
37    echo -n "Stopping PPPoE server: pppoe-server"
38    start-stop-daemon --stop --quiet --exec /usr/sbin/pppoe-server -- $OPTIONS
39    echo "."
40    ;;
41  status)
42    pid=$(pidof pppoe-server)
43    if [ -n "$pid" ] ; then
44	    echo "Running with pid $pid"
45    else
46	    echo "Not running"
47    fi
48    ;;
49  restart|force-reload)
50    $0 stop
51    $0 start
52    ;;
53  *)
54    echo "Usage: /etc/init.d/pppoe-server {start|stop|restart|force-reload}"
55    exit 1
56    ;;
57esac
58
59exit 0
60