00239850cc49a1112d209420b900c18f72ca7283
[openwrt/svn-archive/archive.git] / package / pptp / files / pptp.sh
1 #!/bin/sh
2
3 . /etc/functions.sh
4 . ../netifd-proto.sh
5 init_proto "$@"
6
7 INCLUDE_ONLY=1
8 . ./ppp.sh
9
10 proto_pptp_init_config() {
11 ppp_generic_init_config
12 proto_config_add_string "server"
13 proto_config_add_boolean "buffering"
14 available=1
15 no_device=1
16 }
17
18 proto_pptp_setup() {
19 local config="$1"
20 local iface="$2"
21 local load
22
23 json_get_var server server
24 proto_add_host_dependency "$config" "$server"
25
26 json_get_var buffering buffering
27 [ "${buffering:-1}" == 0 ] && buffering="--nobuffer" || buffering=
28
29 for module in slhc ppp_generic ppp_async ip_gre; do
30 grep -q "$module" /proc/modules && continue
31 /sbin/insmod $module 2>&- >&-
32 load=1
33 done
34 [ "$load" = "1" ] && sleep 1
35
36 ppp_generic_setup "$config" \
37 pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
38 file /etc/ppp/options.pptp
39 }
40
41 proto_pptp_teardown() {
42 ppp_generic_teardown "$@"
43 }
44
45 add_protocol pptp