2012-05-05 16:56:28 +00:00
|
|
|
#!/bin/sh
|
2008-04-07 01:07:50 +00:00
|
|
|
|
2012-06-05 16:04:23 +00:00
|
|
|
. /lib/functions.sh
|
2012-05-05 16:56:28 +00:00
|
|
|
. ../netifd-proto.sh
|
|
|
|
init_proto "$@"
|
2010-05-28 00:30:09 +00:00
|
|
|
|
2012-05-05 16:56:28 +00:00
|
|
|
INCLUDE_ONLY=1
|
|
|
|
. ./ppp.sh
|
2008-04-07 01:07:50 +00:00
|
|
|
|
2012-05-05 16:56:28 +00:00
|
|
|
proto_pptp_init_config() {
|
|
|
|
ppp_generic_init_config
|
|
|
|
proto_config_add_string "server"
|
|
|
|
proto_config_add_boolean "buffering"
|
|
|
|
available=1
|
|
|
|
no_device=1
|
2010-05-06 19:51:27 +00:00
|
|
|
}
|
|
|
|
|
2012-05-05 16:56:28 +00:00
|
|
|
proto_pptp_setup() {
|
|
|
|
local config="$1"
|
|
|
|
local iface="$2"
|
|
|
|
local load
|
2010-05-24 16:28:46 +00:00
|
|
|
|
2012-05-14 20:58:20 +00:00
|
|
|
json_get_vars server buffering
|
2012-05-14 20:58:16 +00:00
|
|
|
|
|
|
|
serv_addr=
|
|
|
|
for ip in $(resolveip -t 5 "$server"); do
|
2012-06-03 17:01:30 +00:00
|
|
|
( proto_add_host_dependency "$config" "$server" )
|
2012-05-14 20:58:16 +00:00
|
|
|
serv_addr=1
|
|
|
|
done
|
|
|
|
[ -n "$serv_addr" ] || {
|
|
|
|
echo "Could not resolve server address"
|
|
|
|
sleep 5
|
|
|
|
proto_setup_failed "$config"
|
|
|
|
exit 1
|
|
|
|
}
|
2006-07-30 03:09:09 +00:00
|
|
|
|
2012-05-05 16:56:28 +00:00
|
|
|
[ "${buffering:-1}" == 0 ] && buffering="--nobuffer" || buffering=
|
2010-05-24 16:28:46 +00:00
|
|
|
|
2006-07-30 03:09:09 +00:00
|
|
|
for module in slhc ppp_generic ppp_async ip_gre; do
|
2012-05-05 16:56:28 +00:00
|
|
|
grep -q "$module" /proc/modules && continue
|
2006-07-30 03:09:09 +00:00
|
|
|
/sbin/insmod $module 2>&- >&-
|
2012-05-05 16:56:28 +00:00
|
|
|
load=1
|
2006-07-30 03:09:09 +00:00
|
|
|
done
|
2012-05-05 16:56:28 +00:00
|
|
|
[ "$load" = "1" ] && sleep 1
|
2007-08-30 16:53:22 +00:00
|
|
|
|
2012-05-05 16:56:28 +00:00
|
|
|
ppp_generic_setup "$config" \
|
2010-05-24 16:28:46 +00:00
|
|
|
pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
|
2012-05-05 16:56:28 +00:00
|
|
|
file /etc/ppp/options.pptp
|
2006-07-30 03:09:09 +00:00
|
|
|
}
|
2012-05-05 16:56:28 +00:00
|
|
|
|
|
|
|
proto_pptp_teardown() {
|
|
|
|
ppp_generic_teardown "$@"
|
|
|
|
}
|
|
|
|
|
|
|
|
add_protocol pptp
|