3 #***********************************************************************
7 # Shell script to bring up a PPPoE connection
9 # Copyright (C) 2000 Roaring Penguin Software Inc.
13 # This file may be distributed under the terms of the GNU General
18 # Usage: pppoe-start [config_file]
19 # pppoe-start interface user [config_file]
20 # Second form overrides USER and ETH from config file.
21 # If config_file is omitted, defaults to /etc/ppp/pppoe.conf
23 #***********************************************************************
27 exec_prefix
=@exec_prefix@
30 CONNECT
=@sbindir@
/pppoe-connect
32 IFCONFIG
=/sbin
/ifconfig
34 # Set to "C" locale so we can parse messages from commands
39 CONFIG
=/etc
/ppp
/pppoe.conf
44 if [ "`@ID@ -u`" != 0 ] ; then
45 $ECHO "$ME: You must be root to run this script" >& 2
50 if [ "$DEBUG" = "1" ] ; then
51 $ECHO "*** Running in debug mode... please be patient..."
52 DEBUG
=/tmp
/pppoe-debug-$$
55 if [ "$?" != 0 ] ; then
56 $ECHO "Could not create directory $DEBUG... exiting"
59 DEBUG
=$DEBUG/pppoe-debug.txt
61 # Initial debug output
62 $ECHO "---------------------------------------------" > $DEBUG
63 $ECHO "* The following section contains information about your system" >> $DEBUG
65 $ECHO "Output of uname -a" >> $DEBUG
67 $ECHO "---------------------------------------------" >> $DEBUG
68 $ECHO "* The following section contains information about your network" >> $DEBUG
69 $ECHO "* interfaces. The one you chose for PPPoE should contain the words:" >> $DEBUG
70 $ECHO "* 'UP' and 'RUNNING'. If it does not, you probably have an Ethernet" >> $DEBUG
71 $ECHO "* driver problem." >> $DEBUG
72 $ECHO "Output of ifconfig -a" >> $DEBUG
73 $IFCONFIG -a >> $DEBUG
74 $ECHO "---------------------------------------------" >> $DEBUG
75 if [ "`uname -s`" = "Linux" ] ; then
76 $ECHO "* The following section contains information about kernel modules" >> $DEBUG
77 $ECHO "* If the module for your Ethernet card is 'tulip', you might" >> $DEBUG
78 $ECHO "* want to look for an updated version at http://www.scyld.com" >> $DEBUG
79 $ECHO "Output of lsmod" >> $DEBUG
81 $ECHO "---------------------------------------------" >> $DEBUG
83 $ECHO "* The following section lists your routing table." >> $DEBUG
84 $ECHO "* If you have an entry which starts with '0.0.0.0', you probably" >> $DEBUG
85 $ECHO "* have defined a default route and gateway, and pppd will" >> $DEBUG
86 $ECHO "* not create a default route using your ISP. Try getting" >> $DEBUG
87 $ECHO "* rid of this route." >> $DEBUG
88 $ECHO "Output of netstat -n -r" >> $DEBUG
89 netstat
-n -r >> $DEBUG
90 $ECHO "---------------------------------------------" >> $DEBUG
91 $ECHO "Contents of /etc/resolv.conf" >> $DEBUG
92 $ECHO "* The following section lists DNS setup." >> $DEBUG
93 $ECHO "* If you can browse by IP address, but not name, suspect" >> $DEBUG
94 $ECHO "* a DNS problem." >> $DEBUG
95 cat /etc
/resolv.conf
>> $DEBUG
96 $ECHO "---------------------------------------------" >> $DEBUG
97 $ECHO "* The following section lists /etc/ppp/options." >> $DEBUG
98 $ECHO "* You should have NOTHING in that file." >> $DEBUG
99 $ECHO "Contents of /etc/ppp/options" >> $DEBUG
100 cat /etc
/ppp
/options
>> $DEBUG 2>/dev
/null
101 $ECHO "---------------------------------------------" >> $DEBUG
106 # Sort out command-line arguments
116 if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then
117 $ECHO "$ME: Cannot read configuration file '$CONFIG'" >& 2
123 # Check for command-line overriding of ETH and USER
132 if [ -r "$PIDFILE" ] ; then
134 # Check if still running
135 kill -0 $PID > /dev
/null
2>&1
137 $ECHO "$ME: There already seems to be a PPPoE connection up (PID $PID)" >& 2
140 # Delete bogus PIDFILE
141 rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start"
144 echo $$
> $PIDFILE.start
146 # Start the connection in the background unless we're debugging
147 if [ "$DEBUG" != "" ] ; then
152 $CONNECT "$@" > /dev
/null
2>&1 &
155 if [ "$CONNECT_TIMEOUT" = "" -o "$CONNECT_TIMEOUT" = 0 ] ; then
159 # Don't monitor connection if dial-on-demand
160 if [ "$DEMAND" != "" -a "$DEMAND" != "no" ] ; then
167 @sbindir@
/pppoe-status
$CONFIG > /dev
/null
2>&1
169 # Looks like the interface came up
171 # Print newline if standard input is a TTY
172 tty
-s && $ECHO " Connected!"
176 if test -n "$FORCEPING" ; then
177 printf "%s" "$FORCEPING"
179 tty
-s && printf "%s" "$PING"
182 TIME
=`expr $TIME + $CONNECT_POLL`
183 if [ $TIME -gt $CONNECT_TIMEOUT ] ; then
188 $ECHO "TIMED OUT" >& 2
189 # Timed out! Kill the pppoe-connect process and quit
190 kill $CONNECT_PID > /dev
/null
2>&1
192 # Clean up PIDFILE(s)
193 rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start"