summaryrefslogtreecommitdiffstats
path: root/src/connections/ppp
blob: a82677bd32caf0d1b5a143733bf9463396e78ab8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /bin/bash
. /usr/lib/network/network


ppp_up() {
    load_profile "$1"
    [[ -z "$PEER" ]] && PEER="provider"
    [[ -z "$PPP_TIMEOUT" ]] && PPP_TIMEOUT=30

    /usr/sbin/pppd call "$PEER" updetach child-timeout "$PPP_TIMEOUT" linkname "$PEER"

    if [[ $? -ne 0 ]]; then
       report_fail "Couldn't make pppd connection."
       return 1
    fi
}

ppp_down() {
    load_profile "$1"
    PIDFILE="/var/run/ppp-$(basename $PEER).pid"

    if [[ -e $PIDFILE ]]; then
        PID=$(head -1 $PIDFILE)
        [[ -n "$PID" ]] && kill "$(head -1 $PIDFILE)"
    fi
    kill "$(head -1 $PIDFILE)"
}

ppp_$1 "$2"
exit $?

# vim: ft=sh ts=4 et sw=4: