blob: ba9f67a09b86b0cb4021abbad20da7eadaeed682 (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
|
#! /bin/bash
. /usr/lib/network/network
_quotestring() {
echo "\"${1/\"/\\\"}\""
}
pppoe_up() {
local cfg
load_profile "$1"
mkdir -p "$STATE_DIR"/pppoe.eth0."$1"/
chmod 700 "$STATE_DIR"/pppoe.eth0."$1"/
cfg="$STATE_DIR"/pppoe.eth0."$1"/options
: > "${cfg}"
chmod 600 "${cfg}"
echo "plugin rp-pppoe.so" >> "${cfg}"
echo "nic-${INTERFACE}" >> "${cfg}"
if checkyesno ${DEFAULTROUTE:-1}; then
echo "defaultroute" >> "${cfg}"
else
echo "nodefaultroute" >> "${cfg}"
fi
if checkyesno ${USEPEERDNS:-1}; then
echo "usepeerdns" >> "${cfg}"
fi
echo "linkname $(_quotestring "$1")" >> "${cfg}"
echo "maxfail 5" >> "${cfg}"
echo "updetach" >> "${cfg}"
if [[ ${CONNECTION_MODE} == demand ]]; then
echo "demand" >> "${cfg}"
echo "idle ${IDLE_TIMEOUT}" >> "${cfg}"
else
echo "persist" >> "${cfg}"
fi
echo "user $(_quotestring "${USER}")" >> "${cfg}"
echo "password $(_quotestring "${PASSWORD}")" >> "${cfg}"
[[ -n ${LCP_ECHO_INTERVAL} ]] && echo "lcp-echo-interval ${LCP_ECHO_INTERVAL}" >> "${cfg}"
[[ -n ${LCP_ECHO_FAILURE} ]] && echo "lcp-echo-failure ${LCP_ECHO_FAILURE}" >> "${cfg}"
[[ -n ${PPPOE_SERVICE} ]] && echo "rp_pppoe_service $(_quotestring "${PPPOE_SERVICE}")" >> "${cfg}"
[[ -n ${PPPOE_AC} ]] && echo "rp_pppoe_ac $(_quotestring "${PPPOE_AC}")" >> "${cfg}"
[[ -n ${PPPOE_SESSION} ]] && echo "rp_pppoe_sess $(_quotestring "${PPPOE_SESSION}")" >> "${cfg}"
[[ -n ${PPPOE_MAC} ]] && echo "pppoe-mac $(_quotestring "${PPPOE_MAC}")" >> "${cfg}"
/sbin/ip link set dev ${INTERFACE} up
/usr/sbin/pppd file "${cfg}"
if [[ $? -ne 0 ]]; then
rm "${cfg}"
rmdir "$STATE_DIR"/pppoe.eth0."$1"/
report_fail "Couldn't make pppd connection."
return 1
fi
}
pppoe_down() {
load_profile "$1"
local cfg
cfg="$STATE_DIR"/pppoe.eth0."$1"/options
PIDFILE="/var/run/ppp-$1.pid"
if [[ -e $PIDFILE ]]; then
read PID < "$PIDFILE"
[[ "$PID" ]] && kill "$PID"
fi
rm "${cfg}"
rmdir "$STATE_DIR"/pppoe.eth0."$1"/
}
pppoe_$1 "$2"
exit $?
# vim: ft=sh ts=4 et sw=4:
|