add first batch of enrik's ar7 system code cleanups
[openwrt.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
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 while :; do
14 PPTP_PROTO="$(nvram get pptp_proto)"
15 [ "$PPTP_PROTO" = "static" ] || PPTP_PROTO=""
16 PPTP_PROTO="${PPTP_PROTO:-dhcp}"
17 IP=$(nvram get pptp_server_ip)
18 USERNAME=$(nvram get ppp_username)
19 PASSWORD=$(nvram get ppp_passwd)
20 REDIAL=$(nvram get ppp_redialperiod)
21 REDIAL=${REDIAL:+lcp-echo-interval $REDIAL}
22 IDLETIME=$(nvram get ppp_idletime)
23 IDLETIME=${IDLETIME:+lcp-echo-failure $IDLETIME}
24 MTU=$(nvram get ppp_mtu)
25 MTU=${MTU:+ mtu $MTU mru $MTU}
26
27 do_ifup $PPTP_PROTO $type
28
29 # hack for some buggy ISPs
30 NETMASK=$(nvram get ${type}_netmask)
31 IFNAME=$(nvram get pptp_ifname)
32 [ -z "$NETMASK" -o -z "$IFNAME" ] || ifconfig $IFNAME netmask $NETMASK
33
34 /usr/sbin/pppd nodetach \
35 pty "/usr/sbin/pptp $IP --loglevel 0 --nolaunchpppd" \
36 file /etc/ppp/options.pptp \
37 connect /bin/true \
38 usepeerdns \
39 defaultroute \
40 replacedefaultroute \
41 linkname $type \
42 user "$USERNAME" \
43 password "$PASSWORD" \
44 $MTU \
45 $IDLETIME \
46 $REDIAL
47 done &
48
This page took 0.046804 seconds and 5 git commands to generate.