firmware-utils/mktplinkfw: add ability to put jffs2 eof marker into the image
[openwrt.git] / package / pptp / files / pptp.sh
1 find_gw() {
2 route -n | awk '$1 == "0.0.0.0" { print $2; exit }'
3 }
4
5 scan_pptp() {
6 config_set "$1" device "pptp-$1"
7 }
8
9 stop_interface_pptp() {
10 stop_interface_ppp "$1"
11 for ip in $(uci_get_state network "$1" serv_addrs); do
12 route del -host "$ip" 2>/dev/null
13 done
14 }
15
16 coldplug_interface_pptp() {
17 setup_interface_pptp "pptp-$1" "$1"
18 }
19
20 setup_interface_pptp() {
21 local config="$2"
22 local ifname
23
24 local device
25 config_get device "$config" device
26
27 local ipproto
28 config_get ipproto "$config" ipproto
29
30 local server
31 config_get server "$config" server
32
33 local buffering
34 config_get_bool buffering "$config" buffering 1
35 [ "$buffering" == 0 ] && buffering="--nobuffer" || buffering=
36
37 for module in slhc ppp_generic ppp_async ip_gre; do
38 /sbin/insmod $module 2>&- >&-
39 done
40 sleep 1
41
42 setup_interface "$device" "$config" "${ipproto:-dhcp}"
43 local gw="$(find_gw)"
44 [ -n "$gw" ] && {
45 local serv_addrs=""
46 for ip in $(resolveip -4 -t 3 "$server"); do
47 append serv_addrs "$ip"
48 route delete -host "$ip" 2>/dev/null
49 route add -host "$ip" gw "$gw"
50 done
51 uci_toggle_state network "$config" serv_addrs "$serv_addrs"
52 }
53
54 # fix up the netmask
55 config_get netmask "$config" netmask
56 [ -z "$netmask" -o -z "$device" ] || ifconfig $device netmask $netmask
57
58 config_get mtu "$config" mtu
59 mtu=${mtu:-1452}
60 start_pppd "$config" \
61 pty "/usr/sbin/pptp $server --loglevel 0 --nolaunchpppd $buffering" \
62 file /etc/ppp/options.pptp \
63 mtu $mtu mru $mtu
64 }
This page took 0.049141 seconds and 5 git commands to generate.