2006-07-30 06:09:09 +03:00
|
|
|
scan_ppp() {
|
|
|
|
config_get ifname "$1" ifname
|
|
|
|
pppdev="${pppdev:-0}"
|
|
|
|
config_set "$1" ifname "ppp$pppdev"
|
|
|
|
config_set "$1" unit "$pppdev"
|
2007-08-31 19:19:19 +03:00
|
|
|
pppdev="$(($pppdev + 1))"
|
2006-07-30 06:09:09 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
start_pppd() {
|
|
|
|
local cfg="$1"; shift
|
2006-10-26 04:33:36 +03:00
|
|
|
|
2006-10-25 02:59:08 +03:00
|
|
|
# make sure only one pppd process is started
|
2006-10-26 04:33:36 +03:00
|
|
|
lock "/var/lock/ppp-${cfg}"
|
2006-11-19 01:19:32 +02:00
|
|
|
local pid="$(head -n1 /var/run/ppp-${cfg}.pid 2>/dev/null)"
|
2006-10-26 04:33:36 +03:00
|
|
|
[ -d "/proc/$pid" ] && grep pppd "/proc/$pid/cmdline" 2>/dev/null >/dev/null && {
|
|
|
|
lock -u "/var/lock/ppp-${cfg}"
|
|
|
|
return 0
|
|
|
|
}
|
2006-10-25 02:59:08 +03:00
|
|
|
|
2006-07-30 06:09:09 +03:00
|
|
|
config_get device "$cfg" device
|
|
|
|
config_get unit "$cfg" unit
|
|
|
|
config_get username "$cfg" username
|
|
|
|
config_get password "$cfg" password
|
|
|
|
config_get keepalive "$cfg" keepalive
|
2007-05-02 00:53:32 +03:00
|
|
|
|
|
|
|
config_get connect "$cfg" connect
|
|
|
|
config_get disconnect "$cfg" disconnect
|
2007-07-23 05:50:03 +03:00
|
|
|
config_get pppd_options "$cfg" pppd_options
|
2007-09-01 15:57:15 +03:00
|
|
|
config_get_bool defaultroute "$cfg" defaultroute 1
|
|
|
|
[ "$defaultroute" -eq 1 ] && defaultroute="defaultroute replacedefaultroute" || defaultroute=""
|
2007-05-02 00:53:32 +03:00
|
|
|
|
2006-12-20 07:12:49 +02:00
|
|
|
interval="${keepalive##*[, ]}"
|
2006-09-12 03:31:37 +03:00
|
|
|
[ "$interval" != "$keepalive" ] || interval=5
|
|
|
|
|
2006-07-30 06:09:09 +03:00
|
|
|
config_get demand "$cfg" demand
|
2007-01-08 23:33:53 +02:00
|
|
|
[ -n "$demand" ] && echo "nameserver 1.1.1.1" > /tmp/resolv.conf.auto
|
2006-07-30 06:09:09 +03:00
|
|
|
/usr/sbin/pppd "$@" \
|
2006-12-20 07:12:49 +02:00
|
|
|
${keepalive:+lcp-echo-interval $interval lcp-echo-failure ${keepalive%%[, ]*}} \
|
2006-07-30 06:09:09 +03:00
|
|
|
${demand:+precompiled-active-filter /etc/ppp/filter demand idle }${demand:-persist} \
|
|
|
|
usepeerdns \
|
2007-09-01 15:57:15 +03:00
|
|
|
$defaultroute \
|
2006-08-04 11:43:04 +03:00
|
|
|
${username:+user "$username" password "$password"} \
|
2007-08-31 19:20:40 +03:00
|
|
|
unit "$unit" \
|
2006-07-30 06:09:09 +03:00
|
|
|
linkname "$cfg" \
|
2007-05-02 00:53:32 +03:00
|
|
|
ipparam "$cfg" \
|
|
|
|
${connect:+connect "$connect"} \
|
2007-07-23 05:50:03 +03:00
|
|
|
${disconnect:+disconnect "$disconnect"} \
|
|
|
|
${pppd_options}
|
2006-10-26 04:33:36 +03:00
|
|
|
|
|
|
|
lock -u "/var/lock/ppp-${cfg}"
|
2006-07-30 06:09:09 +03:00
|
|
|
}
|
2007-05-02 00:53:32 +03:00
|
|
|
|
|
|
|
setup_interface_ppp() {
|
|
|
|
local iface="$1"
|
|
|
|
local config="$2"
|
|
|
|
|
|
|
|
config_get device "$config" device
|
|
|
|
|
|
|
|
config_get mtu "$cfg" mtu
|
|
|
|
mtu=${mtu:-1492}
|
|
|
|
start_pppd "$config" \
|
|
|
|
mtu $mtu mru $mtu \
|
|
|
|
"$device"
|
|
|
|
}
|
|
|
|
|