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