oops... typo
[openwrt.git] / package / ppp / files / ppp.sh
1 scan_ppp() {
2 config_get ifname "$1" ifname
3 pppdev="${pppdev:-0}"
4 config_set "$1" ifname "ppp$pppdev"
5 config_set "$1" unit "$pppdev"
6 pppdev="$(($pppdev + 1))"
7 }
8
9 start_pppd() {
10 local cfg="$1"; shift
11
12 # make sure only one pppd process is started
13 lock "/var/lock/ppp-${cfg}"
14 local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
15 [ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
16 lock -u "/var/lock/ppp-${cfg}"
17 return 0
18 }
19
20 config_get device "$cfg" device
21 config_get unit "$cfg" unit
22 config_get username "$cfg" username
23 config_get password "$cfg" password
24 config_get keepalive "$cfg" keepalive
25
26 config_get connect "$cfg" connect
27 config_get disconnect "$cfg" disconnect
28 config_get pppd_options "$cfg" pppd_options
29
30 interval="${keepalive##*[, ]}"
31 [ "$interval" != "$keepalive" ] || interval=5
32
33 config_get demand "$cfg" demand
34 [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
35 /usr/sbin/pppd "$@" \
36 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
37 ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
38 usepeerdns \
39 defaultroute \
40 replacedefaultroute \
41 ${username:+user "$username" password "$password"} \
42 unit "$unit" \
43 linkname "$cfg" \
44 ipparam "$cfg" \
45 ${connect:+connect "$connect"} \
46 ${disconnect:+disconnect "$disconnect"} \
47 ${pppd_options}
48
49 lock -u "/var/lock/ppp-${cfg}"
50 }
51
52 setup_interface_ppp() {
53 local iface="$1"
54 local config="$2"
55
56 config_get device "$config" device
57
58 config_get mtu "$cfg" mtu
59 mtu=${mtu:-1492}
60 start_pppd "$config" \
61 mtu $mtu mru $mtu \
62 "$device"
63 }
64
This page took 0.039613 seconds and 5 git commands to generate.