2 config_get ifname
"$1" ifname
4 config_get devunit
"$1" unit
8 if [ ! -d /tmp
/.ppp-counter
]; then
9 mkdir
-p /tmp
/.ppp-counter
12 maxunit
="$(cat /tmp/.ppp-counter/max-unit 2>/dev/null)"
13 if [ -z "$maxunit" ]; then
18 while [ $i -le $maxunit ]; do
20 unitdev
="$(cat /tmp/.ppp-counter/ppp${i} 2>/dev/null)"
21 if [ "$unitdev" = "$1" ]; then
28 if [ -z "$unit" ] ||
[ -z "$pppif" ]; then
29 maxunit
="$(($maxunit + 1))"
30 if [ -n "$devunit" ]; then
32 elif [ "${ifname%%[0-9]*}" = ppp
]; then
37 [ "$maxunit" -lt "$unit" ] && maxunit
="$unit"
39 echo "$1" >/tmp
/.ppp-counter
/$pppif 2>/dev
/null
40 echo "$maxunit" >/tmp
/.ppp-counter
/max-unit
2>/dev
/null
42 config_set
"$1" ifname
"ppp$unit"
43 config_set
"$1" unit
"$unit"
51 # make sure the network state references the correct ifname
53 config_get ifname
"$cfg" ifname
54 set_interface_ifname
"$cfg" "$ifname"
56 # make sure only one pppd process is started
57 lock
"/var/lock/ppp-${cfg}"
58 local pid
="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
59 [ -d "/proc/$pid" ] && grep pppd
"/proc/$pid/cmdline" 2>/dev
/null
>/dev
/null
&& {
60 lock
-u "/var/lock/ppp-${cfg}"
64 # Workaround: sometimes hotplug2 doesn't deliver the hotplug event for creating
65 # /dev/ppp fast enough to be used here
66 [ -e /dev
/ppp
] || mknod
/dev
/ppp c
108 0
69 config_get device
"$cfg" device
72 config_get unit
"$cfg" unit
75 config_get username
"$cfg" username
78 config_get password
"$cfg" password
81 config_get keepalive
"$cfg" keepalive
84 config_get connect
"$cfg" connect
87 config_get disconnect
"$cfg" disconnect
90 config_get pppd_options
"$cfg" pppd_options
93 config_get_bool defaultroute
"$cfg" defaultroute
1
94 [ "$defaultroute" -eq 1 ] && defaultroute
="defaultroute replacedefaultroute" || defaultroute
=""
96 local interval
="${keepalive##*[, ]}"
97 [ "$interval" != "$keepalive" ] || interval
=5
100 config_get dns
"$config" dns
110 config_get_bool peerdns
"$cfg" peerdns
$peer_default
112 echo -n "" > /tmp
/resolv.conf.auto
114 [ "$peerdns" -eq 1 ] && {
119 echo "nameserver $dns" >> /tmp
/resolv.conf.auto
124 config_get_bool demand
"$cfg" demand
0
127 [ "$demand" -eq 1 ] && {
128 demandargs
="precompiled-active-filter /etc/ppp/filter demand idle"
129 [ "$has_dns" -eq 0 ] && \
130 echo "nameserver 1.1.1.1" > /tmp
/resolv.conf.auto
136 config_get_bool ipv6
"$cfg" ipv6
0
137 [ "$ipv6" -eq 1 ] && ipv6
="+ipv6" || ipv6
=""
139 /usr
/sbin
/pppd
"$@" \
140 ${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
144 ${username:+user "$username" password "$password"} \
148 ${connect:+connect "$connect"} \
149 ${disconnect:+disconnect "$disconnect"} \
153 lock
-u "/var/lock/ppp-${cfg}"
156 setup_interface_ppp
() {
161 config_get device
"$config" device
164 config_get mtu
"$config" mtu
167 start_pppd
"$config" \