source: trunk/package/pptp/files/pptp.sh @ 21563

Last change on this file since 21563 was 21563, checked in by jow, 6 years ago

[package] pptp: add "buffering" uci option to enable --nobuffer if needed (#7080)

  • Property svn:eol-style set to native
File size: 1.1 KB
Line 
1find_gw() {
2        route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
3}
4
5stop_interface_pptp() {
6        stop_interface_ppp "$1"
7}
8
9coldplug_interface_pptp() {
10        setup_interface_pptp "pptp-$1" "$1"
11}
12
13setup_interface_pptp() {
14        local config="$2"
15        local ifname
16
17        local device
18        config_get device "$config" device
19
20        local ipproto
21        config_get ipproto "$config" ipproto
22
23        local server
24        config_get server "$config" server
25
26        local buffering
27        config_get_bool buffering "$config" buffering 1
28        [ "$buffering" == 0 ] && buffering="--nobuffer" || buffering=
29
30        for module in slhc ppp_generic ppp_async ip_gre; do
31                /sbin/insmod $module 2>&- >&-
32        done
33        sleep 1
34
35        setup_interface "$device" "$config" "${ipproto:-dhcp}"
36        local gw="$(find_gw)"
37        [ -n "$gw" ] && {
38                [ "$gw" != 0.0.0.0 ] && route delete "$server" 2>/dev/null >/dev/null
39                route add "$server" gw "$gw"
40        }
41
42        # fix up the netmask
43        config_get netmask "$config" netmask
44        [ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
45
46        config_get mtu "$config" mtu
47        mtu=${mtu:-1452}
48        start_pppd "$config" \
49                pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
50                file /etc/ppp/options.pptp \
51                mtu $mtu mru $mtu
52}
Note: See TracBrowser for help on using the repository browser.