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