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

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

[package] pptp: support interface sections without ifname by implementing scan_pptp()

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