2 config_get ifname "$1" ifname
4 config_get unit "$1" unit
7 if [ "${ifname%%[0-9]*}" = ppp ]; then
9 [ "$pppdev" -le "$unit" ] && pppdev="$(($unit + 1))"
11 pppdev="$(($pppdev + 1))"
13 config_set "$1" ifname "ppp$unit"
14 config_set "$1" unit "$unit"
21 # make sure only one pppd process is started
22 lock "/var/lock/ppp-${cfg}"
23 local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
24 [ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
25 lock -u "/var/lock/ppp-${cfg}"
29 # Workaround: sometimes hotplug2 doesn't deliver the hotplug event for creating
30 # /dev/ppp fast enough to be used here
31 [ -e /dev/ppp ] || mknod /dev/ppp c 108 0
33 config_get device "$cfg" device
34 config_get unit "$cfg" unit
35 config_get username "$cfg" username
36 config_get password "$cfg" password
37 config_get keepalive "$cfg" keepalive
39 config_get connect "$cfg" connect
40 config_get disconnect "$cfg" disconnect
41 config_get pppd_options "$cfg" pppd_options
42 config_get_bool defaultroute "$cfg" defaultroute 1
43 [ "$defaultroute" -eq 1 ] && defaultroute="defaultroute replacedefaultroute" || defaultroute=""
45 interval="${keepalive##*[, ]}"
46 [ "$interval" != "$keepalive" ] || interval=5
48 config_get_bool peerdns "$cfg" peerdns 1
49 [ "$peerdns" -eq 1 ] && peerdns="usepeerdns" || peerdns=""
51 config_get demand "$cfg" demand
52 [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
54 config_get_bool ipv6 "$cfg" ipv6 0
55 [ "$ipv6" -eq 1 ] && ipv6="+ipv6" || ipv6=""
58 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
59 ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
62 ${username:+user "$username" password "$password"} \
66 ${connect:+connect "$connect"} \
67 ${disconnect:+disconnect "$disconnect"} \
71 lock -u "/var/lock/ppp-${cfg}"
74 setup_interface_ppp() {
78 config_get device "$config" device
80 config_get mtu "$cfg" mtu
82 start_pppd "$config" \