2 # Filename: grml-pptp-xdsl-students
3 # Purpose: connect via pptp to inode ["students-setup"] (www.inode.at)
4 # Authors: grml-team (grml.org), (c) Martin Hecher <hecka@grml.org>
5 # Bug-Reports: see http://grml.org/bugs/
6 # License: This file is licensed under the GPL v2.
7 ################################################################################
9 ################################################################################
11 # This script is based on 'knoppix-pptp' (version 0.3.1)
12 # by Wolfgang Scheicher
13 # and based on grml-pptp-inode
14 # by Andreas 'Jimmy' Gredler
15 ################################################################################
20 if [ $(id -ru) -ne 0 ] ; then
27 set $(grep "option routers" /var/lib/dhcp3/dhclient.leases | tail -1 | cut -f5 -d' ' | tr -d ";")
32 if route -n | grep $ANT >>/dev/null
37 /sbin/route add $ANT gw $ROUTER
39 if ifconfig | grep ppp0 >>/dev/null
41 set $(ifconfig ppp0 | grep P-t-P | tr -s [:blank:] | cut -f4 -d' ' | cut -b7-)
43 /sbin/route del default
44 /sbin/route add default gw $GATEWAY
51 /sbin/dhclient ${NET_DEVICE}
53 echo "name ${VPNUSERNAME}" > /etc/ppp/peers/inode
54 cat >> /etc/ppp/peers/inode << "EOF"
60 logfile /var/log/pptp.log
64 echo "${VPNUSERNAME} XDSL ${VPNPASSWORD} *" >> /etc/ppp/pap-secrets
65 chmod 0600 /etc/ppp/pap-secrets
67 printf "#!/bin/sh\nLANG=C\nVPNSERVER=\"${VPNSERVER}\"\n" > /etc/init.d/pptp
69 cat >> /etc/init.d/pptp << "EOF"
71 PPTP="/usr/sbin/pptp $VPNSERVER call inode"
75 echo "Starting up XDSL: pptp"
76 start-stop-daemon --start --exec $PPTP
82 echo "Shutting down XDSL: pptp"
83 start-stop-daemon --stop --exec $PPTP
85 /sbin/route del -host $VPNSERVER
86 /sbin/route add default gw $GATEWAY
91 echo -n "Reconnecting XDSL: pptd"
92 start-stop-daemon --start --exec $PPTP
96 echo "Usage: /etc/init.d/pptp {start|stop|reconnect}"
104 chmod +x /etc/init.d/pptp
105 touch /var/log/pptp.log
106 /etc/init.d/pptp start
107 $DIALOG --title "Information" --no-cancel --msgbox "Please click OK and wait until remote IP is assigned." 0 0
108 $DIALOG --title "PPTP Log" --no-cancel --tailbox /var/log/pptp.log 0 0
111 [ -n "$VPNSERVER" ] || VPNSERVER="10.0.0.138"
112 [ -n "$VPNUSERNAME" ] || VPNUSERNAME="$(cat /etc/ppp/pap-secrets | grep XDSL | cut -d " " -f1)"
113 [ -n "$VPNPASSWORD" ] || VPNPASSWORD="$(cat /etc/ppp/pap-secrets | grep XDSL | cut -d " " -f3)"
115 if [ -z "$VPNUSERNAME" ] || [ -z "$VPNPASSWORD" ] ; then
117 COMMAND1=$($DIALOG --stdout --title "Inode XDSL Graz" --inputbox \
118 "Account name (e.g. grml@tug):" 0 35) || exit 0
119 COMMAND2=$($DIALOG --stdout --title "Inode XDSL Graz" --passwordbox "Account password (hidden typing):" 0 40) || exit 0
128 NETDEVICES="$(grep -ve 'lo:' -ve 'Inter-|' -ve 'face |bytes' /proc/net/dev | awk -F: '{print $1}')"
131 [ -d "/sys/class/net/${1}/wireless" ] && return 0
132 # Card exists but is not configured yet
133 [ -n "$(iwconfig $1 2>/dev/null | head -1)" ] && return 0
137 if [ -z "$NETDEVICES" ]; then
138 $DIALOG --msgbox "No network devices found." 15 45
142 count="$(echo "$NETDEVICES" | wc -w)"
144 if [ "$count" -gt 1 ]; then
146 for DEVICE in $NETDEVICES; do
147 wireless "$DEVICE" && DEVICELIST="$DEVICELIST ${DEVICE} Wireless" || DEVICELIST="$DEVICELIST ${DEVICE} LAN"
150 $DIALOG --menu "Network device to connect from:" 18 45 12 $DEVICELIST 2>"$TMP" || bailout
151 read NET_DEVICE <"$TMP" ; rm -f "$TMP"
153 # Remove additional spaces
154 NET_DEVICE="$(echo $NETDEVICES)"
157 VPNUSERNAME=${COMMAND1%/*}
158 VPNPASSWORD=${COMMAND2#*/}
159 [ ! -z "$VPNUSERNAME" ] || exit 1
160 [ ! -z "$VPNPASSWORD" ] || exit 1
161 [ ! -z "$NET_DEVICE" ] || exit 1
165 $DIALOG --title "Inode XDSL Graz" --msgbox "Found already configured
166 account.\nIf the settings are wrong, delete the entries in
167 /etc/ppp/pap-secrets" 10 45
171 ## END OF FILE #################################################################