fix lua compile issues on ixp4xx (EABI) by linking libgcc into liblua
[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 # Workaround: sometimes hotplug2 doesn't deliver the hotplug event for creating
24 # /dev/ppp fast enough to be used here
25 [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
26
27 config_get device "$cfg" device
28 config_get unit "$cfg" unit
29 config_get username "$cfg" username
30 config_get password "$cfg" password
31 config_get keepalive "$cfg" keepalive
32
33 config_get connect "$cfg" connect
34 config_get disconnect "$cfg" disconnect
35 config_get pppd_options "$cfg" pppd_options
36 config_get_bool defaultroute "$cfg" defaultroute 1
37 [ "$defaultroute" -eq 1 ] && defaultroute="defaultroute replacedefaultroute" || defaultroute=""
38
39 interval="${keepalive##*[, ]}"
40 [ "$interval" != "$keepalive" ] || interval=5
41
42 config_get_bool peerdns "$cfg" peerdns 1
43 [ "$peerdns" -eq 1 ] && peerdns="usepeerdns" || peerdns=""
44
45 config_get demand "$cfg" demand
46 [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
47
48 config_get_bool ipv6 "$cfg" ipv6 0
49 [ "$ipv6" -eq 1 ] && ipv6="+ipv6" || ipv6=""
50
51 /usr/sbin/pppd "$@" \
52 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
53 ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
54 $peerdns \
55 $defaultroute \
56 ${username:+user "$username" password "$password"} \
57 unit "$unit" \
58 linkname "$cfg" \
59 ipparam "$cfg" \
60 ${connect:+connect "$connect"} \
61 ${disconnect:+disconnect "$disconnect"} \
62 ${ipv6} \
63 ${pppd_options}
64
65 lock -u "/var/lock/ppp-${cfg}"
66 }
67
68 setup_interface_ppp() {
69 local iface="$1"
70 local config="$2"
71
72 config_get device "$config" device
73
74 config_get mtu "$cfg" mtu
75 mtu=${mtu:-1492}
76 start_pppd "$config" \
77 mtu $mtu mru $mtu \
78 "$device"
79 }
80
This page took 0.044837 seconds and 5 git commands to generate.