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 # Latest change: Sun Jan 15 16:19:24 CET 2006 [mika]
8 ################################################################################
10 ################################################################################
12 # This script is based on 'knoppix-pptp' (version 0.3.1)
13 # by Wolfgang Scheicher
14 # and based on grml-pptp-inode
15 # by Andreas 'Jimmy' Gredler
16 ################################################################################
21 if [ "$UID" != 0 ]; then
28 set $(grep "option routers" /var/lib/dhcp3/dhclient.leases | tail -1 | cut -f5 -d' ' | tr -d ";")
33 if route -n | grep $ANT >>/dev/null
38 /sbin/route add $ANT gw $ROUTER
40 if ifconfig | grep ppp0 >>/dev/null
42 set $(ifconfig ppp0 | grep P-t-P | tr -s [:blank:] | cut -f4 -d' ' | cut -b7-)
44 /sbin/route del default
45 /sbin/route add default gw $GATEWAY
52 /sbin/dhclient ${NET_DEVICE}
54 echo "name ${VPNUSERNAME}" > /etc/ppp/peers/inode
55 cat >> /etc/ppp/peers/inode << "EOF"
61 logfile /var/log/pptp.log
65 echo "${VPNUSERNAME} XDSL ${VPNPASSWORD} *" >> /etc/ppp/pap-secrets
66 chmod 0600 /etc/ppp/pap-secrets
68 echo -e "#!/bin/sh\nLANG=C\nVPNSERVER=\"${VPNSERVER}\"\n" > /etc/init.d/pptp
70 cat >> /etc/init.d/pptp << "EOF"
72 PPTP="/usr/sbin/pptp $VPNSERVER call inode"
76 echo "Starting up XDSL: pptp"
77 start-stop-daemon --start --exec $PPTP
83 echo "Shutting down XDSL: pptp"
84 start-stop-daemon --stop --exec $PPTP
86 /sbin/route del -host $VPNSERVER
87 /sbin/route add default gw $GATEWAY
92 echo -n "Reconnecting XDSL: pptd"
93 start-stop-daemon --start --exec $PPTP
97 echo "Usage: /etc/init.d/pptp {start|stop|reconnect}"
105 chmod +x /etc/init.d/pptp
106 touch /var/log/pptp.log
107 /etc/init.d/pptp start
108 $DIALOG --title "Information" --no-cancel --msgbox "Please click OK and wait until remote IP is assigned." 0 0
109 $DIALOG --title "PPTP Log" --no-cancel --tailbox /var/log/pptp.log 0 0
112 [ -n "$VPNSERVER" ] || VPNSERVER="10.0.0.138"
113 [ -n "$VPNUSERNAME" ] || VPNUSERNAME="$(cat /etc/ppp/pap-secrets | grep XDSL | cut -d " " -f1)"
114 [ -n "$VPNPASSWORD" ] || VPNPASSWORD="$(cat /etc/ppp/pap-secrets | grep XDSL | cut -d " " -f3)"
116 if [ -z "$VPNUSERNAME" ] || [ -z "$VPNPASSWORD" ] ; then
118 COMMAND1=$($DIALOG --stdout --title "Inode XDSL Graz" --inputbox \
119 "Account name (e.g. grml@tug):" 0 35) || exit 0
120 COMMAND2=$($DIALOG --stdout --title "Inode XDSL Graz" --passwordbox "Account password (hidden typing):" 0 40) || exit 0
129 NETDEVICES="$(cat /proc/net/dev | awk -F: '/[0-9]:/{print $1}')"
132 case "$(cat /proc/net/wireless 2>/dev/null)" in *$1*) return 0;; esac
133 # Card exists but is not configured yet
134 [ -n "$(iwconfig $1 2>/dev/null | head -1)" ] && return 0
138 if [ -z "$NETDEVICES" ]; then
139 $DIALOG --msgbox "No network devices found." 15 45
143 count="$(echo "$NETDEVICES" | wc -w)"
145 if [ "$count" -gt 1 ]; then
147 for DEVICE in $NETDEVICES; do
148 wireless "$DEVICE" && DEVICELIST="$DEVICELIST ${DEVICE} Wireless" || DEVICELIST="$DEVICELIST ${DEVICE} LAN"
151 $DIALOG --menu "Network device to connect from:" 18 45 12 $DEVICELIST 2>"$TMP" || bailout
152 read NET_DEVICE <"$TMP" ; rm -f "$TMP"
154 # Remove additional spaces
155 NET_DEVICE="$(echo $NETDEVICES)"
158 VPNUSERNAME=${COMMAND1%/*}
159 VPNPASSWORD=${COMMAND2#*/}
160 [ ! -z "$VPNUSERNAME" ] || exit 1
161 [ ! -z "$VPNPASSWORD" ] || exit 1
162 [ ! -z "$NET_DEVICE" ] || exit 1
166 $DIALOG --title "Inode XDSL Graz" --msgbox "Found already configured
167 account.\nIf the settings are wrong, delete the entries in
168 /etc/ppp/pap-secrets" 10 45
172 ## END OF FILE #################################################################