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"
22 # make sure the network state references the correct ifname
24 config_get ifname
"$cfg" ifname
25 set_interface_ifname
"$cfg" "$ifname"
27 # make sure only one pppd process is started
28 lock
"/var/lock/ppp-${cfg}"
29 local pid
="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
30 [ -d "/proc/$pid" ] && grep pppd
"/proc/$pid/cmdline" 2>/dev
/null
>/dev
/null
&& {
31 lock
-u "/var/lock/ppp-${cfg}"
35 # Workaround: sometimes hotplug2 doesn't deliver the hotplug event for creating
36 # /dev/ppp fast enough to be used here
37 [ -e /dev
/ppp
] || mknod
/dev
/ppp c
108 0
39 config_get device
"$cfg" device
40 config_get unit
"$cfg" unit
41 config_get username
"$cfg" username
42 config_get password
"$cfg" password
43 config_get keepalive
"$cfg" keepalive
45 config_get connect
"$cfg" connect
46 config_get disconnect
"$cfg" disconnect
47 config_get pppd_options
"$cfg" pppd_options
48 config_get_bool defaultroute
"$cfg" defaultroute
1
49 [ "$defaultroute" -eq 1 ] && defaultroute
="defaultroute replacedefaultroute" || defaultroute
=""
51 interval
="${keepalive##*[, ]}"
52 [ "$interval" != "$keepalive" ] || interval
=5
54 config_get_bool peerdns
"$cfg" peerdns
1
55 [ "$peerdns" -eq 1 ] && peerdns
="usepeerdns" || peerdns
=""
57 config_get demand
"$cfg" demand
58 [ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp
/resolv.conf.auto
60 config_get_bool ipv6
"$cfg" ipv6
0
61 [ "$ipv6" -eq 1 ] && ipv6
="+ipv6" || ipv6
=""
64 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
65 ${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
68 ${username:+user "$username" password "$password"} \
72 ${connect:+connect "$connect"} \
73 ${disconnect:+disconnect "$disconnect"} \
77 lock
-u "/var/lock/ppp-${cfg}"
80 setup_interface_ppp
() {
84 config_get device
"$config" device
86 config_get mtu
"$config" mtu
88 start_pppd
"$config" \