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