fix pptp support
[openwrt/svn-archive/archive.git] / openwrt / package / pptp / files / ifup.pptp
1 #!/bin/sh
2 . /etc/functions.sh
3 type=$1
4
5 [ "$(nvram get ${type}_proto)" = "pptp" ] || exit 0
6
7 [ -d "/var/lock" ] || mkdir -p /var/lock || exit 1
8
9 for module in slhc ppp_generic ppp_async ip_gre; do
10 /sbin/insmod $module 2>&- >&-
11 done
12
13 if=$(nvram get ${type}_ifname)
14 ip=$(nvram get ${type}_ipaddr)
15 netmask=$(nvram get ${type}_netmask)
16 [ -z "$ip" -o -z "$if" ] || ifconfig $if $ip ${netmask:+netmask $netmask} broadcast + up
17
18 while :; do
19 IP=$(nvram get pptp_server_ip)
20 USERNAME=$(nvram get ppp_username)
21 PASSWORD=$(nvram get ppp_passwd)
22 REDIAL=$(nvram get ppp_redialperiod)
23 REDIAL=${REDIAL:+lcp-echo-interval $REDIAL}
24 IDLETIME=$(nvram get ppp_idletime)
25 IDLETIME=${IDLETIME:+lcp-echo-failure $IDLETIME}
26 MTU=$(nvram get ppp_mtu)
27 MTU=${MTU:+ mtu $MTU mru $MTU}
28
29 /usr/sbin/pppd nodetach \
30 pty "/usr/sbin/pptp $IP --loglevel 0 --nolaunchpppd" \
31 file /etc/ppp/options.pptp \
32 connect /bin/true \
33 usepeerdns \
34 defaultroute \
35 linkname $type \
36 user "$USERNAME" \
37 password "$PASSWORD" \
38 $MTU \
39 $IDLETIME \
40 $REDIAL \
41 $IFNAME
42 done &
43