diff options
author | Guillaume Cottenceau <gc@mandriva.com> | 2001-06-11 13:49:39 +0000 |
---|---|---|
committer | Guillaume Cottenceau <gc@mandriva.com> | 2001-06-11 13:49:39 +0000 |
commit | 0a121a8ecd6de894c14d60daf9da2022ec47405c (patch) | |
tree | 3705a0c51f96ffdd2a0594ef43a5677c926eb0cc /mdk-stage1/rp-pppoe/scripts | |
parent | ab5559aaabd1167a18ac882e64d97c5adc0e7d03 (diff) | |
download | drakx-0a121a8ecd6de894c14d60daf9da2022ec47405c.tar drakx-0a121a8ecd6de894c14d60daf9da2022ec47405c.tar.gz drakx-0a121a8ecd6de894c14d60daf9da2022ec47405c.tar.bz2 drakx-0a121a8ecd6de894c14d60daf9da2022ec47405c.tar.xz drakx-0a121a8ecd6de894c14d60daf9da2022ec47405c.zip |
Initial revision
Diffstat (limited to 'mdk-stage1/rp-pppoe/scripts')
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-connect.in | 278 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-init-suse.in | 62 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-init-turbolinux.in | 62 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-init.in | 64 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-setup.in | 346 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-start.in | 186 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-status | 82 | ||||
-rwxr-xr-x | mdk-stage1/rp-pppoe/scripts/adsl-stop.in | 84 |
8 files changed, 1164 insertions, 0 deletions
diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-connect.in b/mdk-stage1/rp-pppoe/scripts/adsl-connect.in new file mode 100755 index 000000000..85dfb3d8d --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-connect.in @@ -0,0 +1,278 @@ +#!/bin/sh +# @configure_input@ +#*********************************************************************** +# +# adsl-connect +# +# Shell script to connect to an ADSL provider using PPPoE +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: adsl-connect [config_file] +# adsl-connect interface user [config_file] +# Second form overrides USER and ETH from config file. +# If config_file is omitted, defaults to /etc//ppp/pppoe.conf +# +#*********************************************************************** + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ +localstatedir=/var + +# Paths to programs +IFCONFIG=/sbin/ifconfig +PPPD=@PPPD@ +SETSID=@SETSID@ +PPPOE=@sbindir@/pppoe +LOGGER="/usr/bin/logger -t `basename $0`" + +# Must be root +if test "`@ID@ -u`" != 0 ; then + echo "$0: You must be root to run this script" >& 2 + exit 1 +fi + +if test "$SETSID" != "" -a ! -x "$SETSID"; then + SETSID="" +fi + +CONFIG=/etc//ppp/pppoe.conf +USER="" +ETH="" + +# Sort out command-line arguments +case "$#" in + 1) + CONFIG="$1" + ;; + 3) + CONFIG="$3" + ;; +esac + +if test ! -f "$CONFIG" -o ! -r "$CONFIG" ; then + echo "$0: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +. $CONFIG + +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" + +# Check for command-line overriding of ETH and USER +case "$#" in + 2|3) + ETH="$1" + USER="$2" + ;; +esac + +# Check that config file is sane +if test "$USER" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for USER" >& 2 + exit 1 +fi +if test "$ETH" = "" ; then + echo "$0: Check '$CONFIG' -- no setting for ETH" >& 2 + exit 1 +fi + +PPPD_PID=0 + +# Catch common error +if test "$DEBUG" = "1" ; then + echo "*** If you want to use DEBUG, invoke adsl-start, not adsl-connect." + exit 1 +fi + +if test "$DEBUG" != "" ; then + if test "$LINUX_PLUGIN" != "" ; then + echo "Cannot use DEBUG mode and LINUX_PLUGIN at the same time." + echo "Kernel-mode PPPoE is experimental and unsupported." + exit 1 + fi + echo "* The following section identifies your Ethernet interface" >> $DEBUG + echo "* and user name. Some ISP's need 'username'; others" >> $DEBUG + echo "* need 'username@isp.com'. Try both" >> $DEBUG + echo "ETH=$ETH; USER=$USER" >> $DEBUG + echo "---------------------------------------------" >> $DEBUG +fi + +# MTU of Ethernet card attached to modem MUST be 1500. This apparently +# fails on some *BSD's, so we'll only do it under Linux + +if test `uname -s` = Linux ; then + $IFCONFIG $ETH up mtu 1500 + # For 2.4 kernels. Will fail on 2.2.x, but who cares? + modprobe ppp_generic > /dev/null 2>&1 + modprobe ppp_async > /dev/null 2>&1 + modprobe ppp_synctty > /dev/null 2>&1 + if test -n "$LINUX_PLUGIN" ; then + modprobe pppox > /dev/null 2>&1 + modprobe pppoe > /dev/null 2>&1 + fi +fi + +if test "$SYNCHRONOUS" = "yes" ; then + PPPOE_SYNC=-s + PPPD_SYNC=sync + # Increase the chances of it working on Linux... + if test `uname -s` = Linux ; then + modprobe n_hdlc > /dev/null 2>&1 + fi +else + PPPOE_SYNC="" + PPPD_SYNC="" +fi + +if test -n "$ACNAME" ; then + ACNAME="-C $ACNAME" +fi + +if test -n "$SERVICENAME" ; then + SERVICENAME="-S $SERVICENAME" +fi + +if test "$CLAMPMSS" = "no" ; then + CLAMPMSS="" +else + CLAMPMSS="-m $CLAMPMSS" +fi + +# If DNSTYPE is SERVER, we must use "usepeerdns" option to pppd. +if test "$DNSTYPE" = "SERVER" ; then + USEPEERDNS=yes +fi + +if test "$USEPEERDNS" = "yes" ; then + USEPEERDNS="usepeerdns" +else + USEPEERDNS="" +fi + +# Backward config file compatibility +if test "$DEMAND" = "" ; then + DEMAND=no +fi + +if test "$DEMAND" = "no" ; then + DEMAND="" +else + DEMAND="demand persist idle $DEMAND 10.112.112.112:10.112.112.113 ipcp-accept-remote ipcp-accept-local connect true noipdefault ktune" +fi + +case "$FIREWALL" in + STANDALONE) + . /etc/ppp/firewall-standalone + ;; + MASQUERADE) + . /etc/ppp/firewall-masq + ;; +esac + +# If we're using kernel-mode PPPoE on Linux... +if test "$LINUX_PLUGIN" != "" ; then + PLUGIN_OPTS="plugin $LINUX_PLUGIN $ETH" + modprobe pppoe > /dev/null 2>&1 +fi + +# Standard PPP options we always use +PPP_STD_OPTIONS="$PLUGIN_OPTS noipdefault noauth default-asyncmap defaultroute hide-password nodetach $USEPEERDNS local mtu 1492 mru 1492 noaccomp noccp nobsdcomp nodeflate nopcomp novj novjccomp user $USER lcp-echo-interval $LCP_INTERVAL lcp-echo-failure $LCP_FAILURE $PPPD_EXTRA" + +# Jigger DNS if required... +if test "$DNSTYPE" = "SERVER" ; then + # Sorry, dude... + rm -f /etc/resolv.conf + ln -s /etc/ppp/resolv.conf /etc/resolv.conf +elif test "$DNSTYPE" = "SPECIFY" ; then + # Sorry, dude... + rm -f /etc/resolv.conf + echo "nameserver $DNS1" > /etc/resolv.conf + if test -n "$DNS2" ; then + echo "nameserver $DNS2" >> /etc/resolv.conf + fi +fi + +# PPPoE invocation +PPPOE_CMD="$PPPOE -p $PPPOE_PIDFILE -I $ETH -T $PPPOE_TIMEOUT -U $PPPOE_SYNC $CLAMPMSS $ACNAME $SERVICENAME $PPPOE_EXTRA" +if test "$DEBUG" != "" ; then + if test "$DEMAND" != "" ; then + echo "(Turning off DEMAND for debugging purposes)" + DEMAND="" + fi + echo "* The following section shows the pppd command we will invoke" >> $DEBUG + echo "pppd invocation" >> $DEBUG + echo "$SETSID $PPPD pty '$PPPOE_CMD' $PPP_STD_OPTIONS $PPPD_SYNC debug" >> $DEBUG + echo "---------------------------------------------" >> $DEBUG + $SETSID $PPPD pty "$PPPOE_CMD -D $DEBUG-0" \ + $PPP_STD_OPTIONS \ + $PPPD_SYNC \ + debug >> $DEBUG 2>&1 + echo "---------------------------------------------" >> $DEBUG + echo "* The following section is an extract from your log." >> $DEBUG + echo "* Look for error messages from pppd, such as" >> $DEBUG + echo "* a lack of kernel support for PPP, authentication failure" >> $DEBUG + echo "* etc." >> $DEBUG + echo "Extract from /var/log/messages" >> $DEBUG + grep 'ppp' /var/log/messages | tail -150 >> $DEBUG + date >> $DEBUG + echo "---------------------------------------------" >> $DEBUG + echo "* The following section is a dump of the packets" >> $DEBUG + echo "* sent and received by rp-pppoe. If you don't see" >> $DEBUG + echo "* any output, it's an Ethernet driver problem. If you only" >> $DEBUG + echo "* see three PADI packets and nothing else, check your cables" >> $DEBUG + echo "* and modem. Make sure the modem lights flash when you try" >> $DEBUG + echo "* to connect. Check that your Ethernet card is in" >> $DEBUG + echo "* half-duplex, 10Mb/s mode. If all else fails," >> $DEBUG + echo "* try using pppoe-sniff." >> $DEBUG + echo "rp-pppoe debugging dump" >> $DEBUG + cat $DEBUG-0 >> $DEBUG + rm -f $DEBUG-0 + for i in 1 2 3 4 5 6 7 8 9 10 ; do + echo "" + echo "" + echo "" + done + echo "*** Finished debugging run. Please review the file" + echo "*** '$DEBUG' and try to" + echo "*** figure out what is going on." + echo "***" + echo "*** Unfortunately, we can NO LONGER accept debugging" + echo "*** output for analysis. Please do not send this to" + echo "*** Roaring Penguin; it is too time-consuming for" + echo "*** us to deal with all the analyses we have been sent." + exit 0 +fi + +echo $$ > $PIDFILE + +while [ true ] ; do + if test "$LINUX_PLUGIN" != "" ; then + $SETSID $PPPD $PPP_STD_OPTIONS $DEMAND & + echo "$!" > $PPPD_PIDFILE + else + $SETSID $PPPD pty "$PPPOE_CMD" \ + $PPP_STD_OPTIONS \ + $DEMAND \ + $PPPD_SYNC & + echo "$!" > $PPPD_PIDFILE + fi + wait + + # Run /etc/ppp/adsl-lost if it exists + test -x /etc/ppp/adsl-lost && /etc/ppp/adsl-lost + + # Re-establish the connection + $LOGGER -p daemon.notice \ + "ADSL connection lost; attempting re-connection." + + # Wait a bit in case a problem causes tons of log messages :-) + sleep 5 +done diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-init-suse.in b/mdk-stage1/rp-pppoe/scripts/adsl-init-suse.in new file mode 100755 index 000000000..936f5fba7 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-init-suse.in @@ -0,0 +1,62 @@ +#!/bin/sh +# +# adsl This script starts or stops an ADSL connection +# +# chkconfig: 2345 99 01 +# description: Connects to ADSL provider +# +# Copyright (C) 2000 Roaring Penguin Software Inc. This software may +# be distributed under the terms of the GNU General Public License, version +# 2 or any later version. +# Modifed to work with SuSE 6.4 linux by Gary Cameron. +# +# Source function library. +#. /etc/rc.d/init.d/functions # For red hat? +. /etc/rc.config # For SuSE, enables setting from /etc/rc.config + +#Tweak this +restart_time=120 + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# Paths to programs +START=@sbindir@/adsl-start +STOP=@sbindir@/adsl-stop +STATUS=@sbindir@/adsl-status + +test "$ADSL_START" = "yes" || exit 0 + +# The echo return value for success (defined in /etc/rc.config). +return=$rc_done +case "$1" in + start) + echo -n "Bringing up ADSL link" + $START > /dev/null 2>&1 || return=$rc_failed + echo -e "$return" + ;; + + stop) + echo -n "Shutting down ADSL link" + $STOP > /dev/null 2>&1 || return=$rc_failed + echo -e "$return" + ;; + + restart) + $0 stop + echo "Waiting" $restart_time "seconds for the host to reset itself" + sleep $restart_time #Note: Need time for host to reset itself + $0 start + ;; + + status) + $STATUS + ;; + + *) + echo "Usage: adsl {start|stop|restart|status}" + exit 1 +esac + +exit 0 diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-init-turbolinux.in b/mdk-stage1/rp-pppoe/scripts/adsl-init-turbolinux.in new file mode 100755 index 000000000..3b22f1345 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-init-turbolinux.in @@ -0,0 +1,62 @@ +#!/bin/sh +# +# adsl This script starts or stops an ADSL connection +# +# chkconfig: 2345 99 01 +# description: Connects to ADSL provider +# +# Copyright (C) 2000 Roaring Penguin Software Inc. This software may +# be distributed under the terms of the GNU General Public License, version +# 2 or any later version. + +# Source function library if it exists +test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# Paths to programs +START=@sbindir@/adsl-start +STOP=@sbindir@/adsl-stop +STATUS=@sbindir@/adsl-status +case "$1" in + start) + echo -n "Bringing up ADSL link: " + + $START + if [ $? = 0 ] ; then + echo success + touch /var/lock/subsys/adsl + else + echo failure + fi + ;; + + stop) + echo -n "Shutting down ADSL link: " + + $STOP > /dev/null 2>&1 + if [ $? = 0 ] ; then + echo success + rm -f /var/lock/subsys/adsl + else + echo failure + fi + ;; + + restart) + $0 stop + $0 start + ;; + + status) + $STATUS + ;; + + *) + echo "Usage: adsl {start|stop|restart|status}" + exit 1 +esac + +exit 0 diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-init.in b/mdk-stage1/rp-pppoe/scripts/adsl-init.in new file mode 100755 index 000000000..ab9146fd3 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-init.in @@ -0,0 +1,64 @@ +#!/bin/sh +# +# adsl This script starts or stops an ADSL connection +# +# chkconfig: 2345 99 01 +# description: Connects to ADSL provider +# +# Copyright (C) 2000 Roaring Penguin Software Inc. This software may +# be distributed under the terms of the GNU General Public License, version +# 2 or any later version. + +# Source function library if it exists +test -r /etc/rc.d/init.d/functions && . /etc/rc.d/init.d/functions + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# Paths to programs +START=@sbindir@/adsl-start +STOP=@sbindir@/adsl-stop +STATUS=@sbindir@/adsl-status +case "$1" in + start) + echo -n "Bringing up ADSL link" + + $START + if [ $? = 0 ] ; then + touch /var/lock/subsys/adsl + echo_success + else + echo_failure + fi + echo "" + ;; + + stop) + echo -n "Shutting down ADSL link" + + $STOP > /dev/null 2>&1 + if [ $? = 0 ] ; then + rm -f /var/lock/subsys/adsl + echo_success + else + echo_failure + fi + echo "" + ;; + + restart) + $0 stop + $0 start + ;; + + status) + $STATUS + ;; + + *) + echo "Usage: adsl {start|stop|restart|status}" + exit 1 +esac + +exit 0 diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-setup.in b/mdk-stage1/rp-pppoe/scripts/adsl-setup.in new file mode 100755 index 000000000..a8c7fa039 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-setup.in @@ -0,0 +1,346 @@ +#!/bin/sh +#*********************************************************************** +# +# adsl-setup +# +# All-purpose slicing/dicing shell script to configure rp-pppoe. +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +#*********************************************************************** + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# Paths to programs +IFCONFIG=/sbin/ifconfig +PPPD=@PPPD@ +PPPOE=@sbindir@/pppoe +ECHO=@ECHO@ +LOGGER="/usr/bin/logger -t `basename $0`" + +CONFIG=/etc/ppp/pppoe.conf + +# Protect created files +umask 077 + +copy() { + cp $1 $2 + if [ "$?" != 0 ] ; then + $ECHO "*** Error copying $1 to $2" + $ECHO "*** Quitting." + exit 1 + fi +} + +$ECHO "Welcome to the Roaring Penguin ADSL client setup. First, I will run" +$ECHO "some checks on your system to make sure the PPPoE client is installed" +$ECHO "properly..." +$ECHO "" + +# Must be root +if [ "`@ID@ -u`" != 0 ] ; then + $ECHO "$0: Sorry, you must be root to run this script" + exit 1 +fi + +# Prototype config file must exist +if [ ! -r "$CONFIG" ] ; then + $ECHO "Oh, dear, I don't see the file '$CONFIG' anywhere. Please" + $ECHO "re-install the PPPoE client." + exit 1 +fi + +# Must have pppd +if [ ! -x $PPPD ] ; then + $ECHO "Oops, I can't execute the program '$PPPD'. You" + $ECHO "must install the PPP software suite, version 2.3.10 or later." + exit 1 +fi + +. $CONFIG + +if [ "$DEMAND" = "" ] ; then + DEMAND=no +fi + +# pppoe must exist +if [ ! -x "$PPPOE" ] ; then + $ECHO "Oh, dear, I can't execute the program '$PPPOE'. Please" + $ECHO "re-install the rp-pppoe client." + exit 1 +fi + +$ECHO "Looks good! Now, please enter some information:" + +while [ true ] ; do + $ECHO "" + $ECHO "USER NAME" + $ECHO "" + $ECHO -n ">>> Enter your PPPoE user name (default $USER): " + read U + + if [ "$U" = "" ] ; then + U="$USER" + fi + + # Under Linux, "fix" the default interface if eth1 is not available + if test `uname -s` = "Linux" ; then + $IFCONFIG $ETH > /dev/null 2>&1 || ETH=eth0 + fi + $ECHO "" + $ECHO "INTERFACE" + $ECHO "" + $ECHO ">>> Enter the Ethernet interface connected to the ADSL modem" + $ECHO "For Solaris, this is likely to be something like /dev/hme0." + $ECHO "For Linux, it will be ethn, where 'n' is a number." + $ECHO -n "(default $ETH): " + read E + + if [ "$E" = "" ] ; then + E="$ETH" + fi + + $ECHO "" + $ECHO "Do you want the link to come up on demand, or stay up continuously?" + $ECHO "If you want it to come up on demand, enter the idle time in seconds" + $ECHO "after which the link should be dropped. If you want the link to" + $ECHO "stay up permanently, enter 'no' (two letters, lower-case.)" + $ECHO "NOTE: Demand-activated links do not interact well with dynamic IP" + $ECHO "addresses. You may have some problems with demand-activated links." + $ECHO -n ">>> Enter the demand value (default $DEMAND): " + read D + if [ "$D" = "" ] ; then + D=$DEMAND + fi + + $ECHO "" + $ECHO "DNS" + $ECHO "" + $ECHO "Please enter the IP address of your ISP's primary DNS server." + $ECHO "If your ISP claims that 'the server will provide DNS addresses'," + $ECHO "enter 'server' (all lower-case) here." + $ECHO "If you just press enter, I will assume you know what you are" + $ECHO "doing and not modify your DNS setup." + $ECHO -n ">>> Enter the DNS information here: " + + read DNS1 + + + if [ "$DNS1" != "" ] ; then + if [ "$DNS1" != "server" ] ; then + $ECHO "Please enter the IP address of your ISP's secondary DNS server." + $ECHO "If you just press enter, I will assume there is only one DNS server." + $ECHO -n ">>> Enter the secondary DNS server address here: " + read DNS2 + fi + fi + + while [ true ] ; do + $ECHO "" + $ECHO "PASSWORD" + $ECHO "" + stty -echo + $ECHO -n ">>> Please enter your PPPoE password: " + read PWD1 + $ECHO "" + $ECHO -n ">>> Please re-enter your PPPoE password: " + read PWD2 + $ECHO "" + stty echo + if [ "$PWD1" = "$PWD2" ] ; then + break + fi + + $ECHO -n ">>> Sorry, the passwords do not match. Try again? (y/n)" + read ANS + case "$ANS" in + N|No|NO|Non|n|no|non) + $ECHO "OK, quitting. Bye." + exit 1 + esac + done + + # Firewalling + $ECHO "" + $ECHO "FIREWALLING" + $ECHO "" + if test `uname -s` != "Linux" ; then + $ECHO "Sorry, firewalling is only supported under Linux. Consult" + $ECHO "your operating system manuals for details on setting up" + $ECHO "packet filters for your system." + FIREWALL=NONE + else + $ECHO "Please choose the firewall rules to use. Note that these rules are" + $ECHO "very basic. You are strongly encouraged to use a more sophisticated" + $ECHO "firewall setup; however, these will provide basic security. If you" + $ECHO "are running any servers on your machine, you must choose 'NONE' and" + $ECHO "set up firewalling yourself. Otherwise, the firewall rules will deny" + $ECHO "access to all standard servers like Web, e-mail, ftp, etc. If you" + $ECHO "are using SSH, the rules will block outgoing SSH connections which" + $ECHO "allocate a privileged source port." + $ECHO "" + while [ true ] ; do + $ECHO "The firewall choices are:" + $ECHO "0 - NONE: This script will not set any firewall rules. You are responsible" + $ECHO " for ensuring the security of your machine. You are STRONGLY" + $ECHO " recommended to use some kind of firewall rules." + $ECHO "1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation" + $ECHO "2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway" + $ECHO " for a LAN" + $ECHO -n ">>> Choose a type of firewall (0-2): " + read a + if [ "$a" = 0 -o "$a" = 1 -o "$a" = 2 ] ; then + break + fi + $ECHO "Please enter a number from 0 to 2" + done + + case "$a" in + 0) + FIREWALL=NONE + ;; + 1) + FIREWALL=STANDALONE + ;; + 2) + FIREWALL=MASQUERADE + ;; + esac + fi + + $ECHO "" + $ECHO "** Summary of what you entered **" + $ECHO "" + $ECHO "Ethernet Interface: $E" + $ECHO "User name: $U" + if [ "$D" = "no" ] ; then + $ECHO "Activate-on-demand: No" + else + $ECHO "Activate-on-demand: Yes; idle timeout = $D seconds" + fi + + if [ "$DNS1" != "" ] ; then + if [ "$DNS1" = "server" ] ; then + $ECHO "DNS addresses: Supplied by ISP's server" + else + $ECHO "Primary DNS: $DNS1" + if [ "$DNS2" != "" ] ; then + $ECHO "Secondary DNS: $DNS2" + fi + fi + else + $ECHO "DNS: Do not adjust" + fi + $ECHO "Firewalling: $FIREWALL" + $ECHO "" + while [ true ] ; do + $ECHO -n '>>> Accept these settings and adjust configuration files (y/n)? ' + read ANS + case "ANS" in + Y|y|yes|Yes|oui|Oui) + ANS=y + ;; + N|n|no|No|non|Non) + ANS=n + ;; + esac + if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then + break + fi + done + if [ "$ANS" = "y" ] ; then + break + fi +done + +# Adjust configuration files. First to $CONFIG + +$ECHO "Adjusting $CONFIG" + +copy $CONFIG $CONFIG-bak +if [ "$DNS1" = "server" ] ; then + DNSTYPE=SERVER + DNS1="" + USEPEERDNS=yes +else + USEPEERDNS=no + if [ "$DNS1" = "" ] ; then + DNSTYPE=NOCHANGE + else + DNSTYPE=SPECIFY + fi +fi + +# Where is pppd likely to put its pid? +if [ -d /var/run ] ; then + VARRUN=/var/run +else + VARRUN=/etc/ppp +fi + +# Some #$(*& ISP's use a slash in the user name... +sed -e "s&^USER=.*&USER='$U'&" \ + -e "s&^ETH=.*Ð='$E'&" \ + -e "s&^PIDFILE=.*&PIDFILE=\"$VARRUN/\$CF_BASE-adsl.pid\"&" \ + -e "s/^FIREWALL=.*/FIREWALL=$FIREWALL/" \ + -e "s/^DEMAND=.*/DEMAND=$D/" \ + -e "s/^DNSTYPE=.*/DNSTYPE=$DNSTYPE/" \ + -e "s/^DNS1=.*/DNS1=$DNS1/" \ + -e "s/^DNS2=.*/DNS2=$DNS2/" \ + -e "s/^USEPEERDNS=.*/USEPEERDNS=$USEPEERDNS/" \ + < $CONFIG-bak > $CONFIG + +if [ $? != 0 ] ; then + $ECHO "** Error modifying $CONFIG" + $ECHO "** Quitting" + exit 1 +fi + +if [ "$DNS1" != "" ] ; then + if [ "$DNS1" != "server" ] ; then + $ECHO "Adjusting /etc/resolv.conf" + if [ -r /etc/resolv.conf ] ; then + grep -s "MADE-BY-RP-PPPOE" /etc/resolv.conf > /dev/null 2>&1 + if [ "$?" != 0 ] ; then + $ECHO " (But first backing it up to /etc/resolv.conf-bak)" + copy /etc/resolv.conf /etc/resolv.conf-bak + fi + fi + $ECHO "# MADE-BY-RP-PPPOE" > /etc/resolv.conf + $ECHO "nameserver $DNS1" >> /etc/resolv.conf + if [ "$DNS2" != "" ] ; then + $ECHO "nameserver $DNS2" >> /etc/resolv.conf + fi + fi +fi + +$ECHO "Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets" +if [ -r /etc/ppp/pap-secrets ] ; then + $ECHO " (But first backing it up to /etc/ppp/pap-secrets-bak)" + copy /etc/ppp/pap-secrets /etc/ppp/pap-secrets-bak +else + cp /dev/null /etc/ppp/pap-secrets-bak +fi +if [ -r /etc/ppp/chap-secrets ] ; then + $ECHO " (But first backing it up to /etc/ppp/chap-secrets-bak)" + copy /etc/ppp/chap-secrets /etc/ppp/chap-secrets-bak +else + cp /dev/null /etc/ppp/chap-secrets-bak +fi + +egrep -v "^$U|^\"$U\"" /etc/ppp/pap-secrets-bak > /etc/ppp/pap-secrets +$ECHO "\"$U\" * \"$PWD1\"" >> /etc/ppp/pap-secrets +egrep -v "^$U|^\"$U\"" /etc/ppp/chap-secrets-bak > /etc/ppp/chap-secrets +$ECHO "\"$U\" * \"$PWD1\"" >> /etc/ppp/chap-secrets + +$ECHO "" +$ECHO "" +$ECHO "" +$ECHO "Congratulations, it should be all set up!" +$ECHO "" +$ECHO "Type 'adsl-start' to bring up your ADSL link and 'adsl-stop' to bring" +$ECHO "it down. Type 'adsl-status' to see the link status." +exit 0 diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-start.in b/mdk-stage1/rp-pppoe/scripts/adsl-start.in new file mode 100755 index 000000000..33251a851 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-start.in @@ -0,0 +1,186 @@ +#!/bin/sh +# @configure_input@ +#*********************************************************************** +# +# adsl-start +# +# Shell script to bring up an ADSL connection +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: adsl-start [config_file] +# adsl-start interface user [config_file] +# Second form overrides USER and ETH from config file. +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +# From AUTOCONF +prefix=@prefix@ +exec_prefix=@exec_prefix@ + +# Paths to programs +CONNECT=@sbindir@/adsl-connect +ECHO=@ECHO@ +IFCONFIG=/sbin/ifconfig + +# Defaults +CONFIG=/etc/ppp/pppoe.conf +USER="" +ETH="" +ME=`basename $0` +# Must be root +if [ "`@ID@ -u`" != 0 ] ; then + $ECHO "$ME: You must be root to run this script" >& 2 + exit 1 +fi + +# Debugging +if [ "$DEBUG" = "1" ] ; then + $ECHO "*** Running in debug mode... please be patient..." + DEBUG=/tmp/pppoe-debug-$$ + export DEBUG + mkdir $DEBUG + if [ "$?" != 0 ] ; then + $ECHO "Could not create directory $DEBUG... exiting" + exit 1 + fi + DEBUG=$DEBUG/pppoe-debug.txt + + # Initial debug output + $ECHO "---------------------------------------------" > $DEBUG + $ECHO "* The following section contains information about your system" >> $DEBUG + date >> $DEBUG + $ECHO "Output of uname -a" >> $DEBUG + uname -a >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "* The following section contains information about your network" >> $DEBUG + $ECHO "* interfaces. The one you chose for PPPoE should contain the words:" >> $DEBUG + $ECHO "* 'UP' and 'RUNNING'. If it does not, you probably have an Ethernet" >> $DEBUG + $ECHO "* driver problem." >> $DEBUG + $ECHO "Output of ifconfig -a" >> $DEBUG + $IFCONFIG -a >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + if [ "`uname -s`" = "Linux" ] ; then + $ECHO "* The following section contains information about kernel modules" >> $DEBUG + $ECHO "* If the module for your Ethernet card is 'tulip', you might" >> $DEBUG + $ECHO "* want to look for an updated version at http://www.scyld.com" >> $DEBUG + $ECHO "Output of lsmod" >> $DEBUG + lsmod >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + fi + $ECHO "* The following section lists your routing table." >> $DEBUG + $ECHO "* If you have an entry which starts with '0.0.0.0', you probably" >> $DEBUG + $ECHO "* have defined a default route and gateway, and pppd will" >> $DEBUG + $ECHO "* not create a default route using your ISP. Try getting" >> $DEBUG + $ECHO "* rid of this route." >> $DEBUG + $ECHO "Output of netstat -n -r" >> $DEBUG + netstat -n -r >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "Contents of /etc/resolv.conf" >> $DEBUG + $ECHO "* The following section lists DNS setup." >> $DEBUG + $ECHO "* If you can browse by IP address, but not name, suspect" >> $DEBUG + $ECHO "* a DNS problem." >> $DEBUG + cat /etc/resolv.conf >> $DEBUG + $ECHO "---------------------------------------------" >> $DEBUG + $ECHO "* The following section lists /etc/ppp/options." >> $DEBUG + $ECHO "* You should have NOTHING in that file." >> $DEBUG + $ECHO "Contents of /etc/ppp/options" >> $DEBUG + cat /etc/ppp/options >> $DEBUG 2>/dev/null + $ECHO "---------------------------------------------" >> $DEBUG +else + DEBUG="" +fi + +# Sort out command-line arguments +case "$#" in + 1) + CONFIG="$1" + ;; + 3) + CONFIG="$3" + ;; +esac + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + $ECHO "$ME: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +. $CONFIG + +# Check for command-line overriding of ETH and USER +case "$#" in + 2|3) + ETH="$1" + USER="$2" + ;; +esac + +# Check for pidfile +if [ -r "$PIDFILE" ] ; then + PID=`cat "$PIDFILE"` + # Check if still running + kill -0 $PID > /dev/null 2>&1 + if [ $? = 0 ] ; then + $ECHO "$ME: There already seems to be an ADSL connection up (PID $PID)" >& 2 + exit 1 + fi + # Delete bogus PIDFILE + rm -f "$PIDFILE" "$PIDFILE.pppd" "$PIDFILE.pppoe" "$PIDFILE.start" +fi + +echo $$ > $PIDFILE.start + +# Start the connection in the background unless we're debugging +if [ "$DEBUG" != "" ] ; then + $CONNECT "$@" + exit 0 +fi + +$CONNECT "$@" > /dev/null 2>&1 & +CONNECT_PID=$! + +if [ "$CONNECT_TIMEOUT" = "" -o "$CONNECT_TIMEOUT" = 0 ] ; then + exit 0 +fi + +# Don't monitor connection if dial-on-demand +if [ "$DEMAND" != "" -a "$DEMAND" != "no" ] ; then + exit 0 +fi + +# Monitor connection +TIME=0 +while [ true ] ; do + @sbindir@/adsl-status $CONFIG > /dev/null 2>&1 + + # Looks like the interface came up + if [ $? = 0 ] ; then + # Print newline if standard input is a TTY + tty -s && $ECHO " Connected!" + exit 0 + fi + + if test -n "$FORCEPING" ; then + $ECHO -n "$FORCEPING" + else + tty -s && $ECHO -n "$PING" + fi + sleep $CONNECT_POLL + TIME=`expr $TIME + $CONNECT_POLL` + if [ $TIME -gt $CONNECT_TIMEOUT ] ; then + break + fi +done + +$ECHO "TIMED OUT" >& 2 +# Timed out! Kill the adsl-connect process and quit +kill $CONNECT_PID > /dev/null 2>&1 +exit 1 + diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-status b/mdk-stage1/rp-pppoe/scripts/adsl-status new file mode 100755 index 000000000..18b100ab2 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-status @@ -0,0 +1,82 @@ +#!/bin/sh +#*********************************************************************** +# +# adsl-status +# +# Shell script to report on status of ADSL connection +# +# Copyright (C) 2000-2001 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: adsl-status [config_file] +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +# Defaults +CONFIG=/etc/ppp/pppoe.conf + +case "$#" in + 1) + CONFIG="$1" + ;; +esac + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + echo "$0: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +. $CONFIG + +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" + +if [ "$DEMAND" != "no" ] ; then + echo "Note: You have enabled demand-connection; adsl-status may be inaccurate." +fi + +# If no PPPOE_PIDFILE, connection is down, unless we're using the Linux plugin +if [ "$LINUX_PLUGIN" = "" ] ; then + if [ ! -r "$PPPOE_PIDFILE" ] ; then + echo "adsl-status: Link is down (can't read pppoe PID file $PPPOE_PIDFILE)" + exit 1 + fi +fi + +# If no PPPD_PIDFILE, something fishy! +if [ ! -r "$PPPD_PIDFILE" ] ; then + echo "adsl-status: Link is down (can't read pppd PID file $PPPD_PIDFILE)" + exit 1 +fi + +PPPD_PID=`cat "$PPPD_PIDFILE"` + +# Sigh. Some versions of pppd put PID files in /var/run; others put them +# in /etc/ppp. Since it's too messy to figure out what pppd does, we +# try both locations. +for i in /etc/ppp/ppp*.pid /var/run/ppp*.pid ; do + if [ -r $i ] ; then + PID=`cat $i` + if [ "$PID" = "$PPPD_PID" ] ; then + IF=`basename $i .pid` + netstat -rn | grep " ${IF}\$" > /dev/null + # /sbin/ifconfig $IF | grep "UP.*POINTOPOINT" > /dev/null + if [ "$?" != "0" ] ; then + echo "adsl-status: Link is attached to $IF, but $IF is down" + exit 1 + fi + echo "adsl-status: Link is up and running on interface $IF" + /sbin/ifconfig $IF + exit 0 + fi + fi +done + +echo "adsl-status: Link is down -- could not find interface corresponding to" +echo "pppd pid $PPPD_PID" +exit 1
\ No newline at end of file diff --git a/mdk-stage1/rp-pppoe/scripts/adsl-stop.in b/mdk-stage1/rp-pppoe/scripts/adsl-stop.in new file mode 100755 index 000000000..af0867573 --- /dev/null +++ b/mdk-stage1/rp-pppoe/scripts/adsl-stop.in @@ -0,0 +1,84 @@ +#!/bin/sh +# @configure_input@ +#*********************************************************************** +# +# adsl-stop +# +# Shell script to bring down an ADSL connection +# +# Copyright (C) 2000 Roaring Penguin Software Inc. +# +# $Id$ +# +# This file may be distributed under the terms of the GNU General +# Public License. +# +# Usage: adsl-stop [config_file] +# If config_file is omitted, defaults to /etc/ppp/pppoe.conf +# +#*********************************************************************** + +ME="`basename $0`" +LOGGER="/usr/bin/logger -t $ME" +CONFIG="$1" +if [ "$CONFIG" = "" ] ; then + CONFIG=/etc/ppp/pppoe.conf +fi + +if [ ! -f "$CONFIG" -o ! -r "$CONFIG" ] ; then + echo "$ME: Cannot read configuration file '$CONFIG'" >& 2 + exit 1 +fi + +. $CONFIG + +PPPOE_PIDFILE="$PIDFILE.pppoe" +PPPD_PIDFILE="$PIDFILE.pppd" +STARTPID="$PIDFILE.start" + +# Backward config file compatibility +if test "$DEMAND" = "" ; then + DEMAND=no +fi + +# Ignore SIGTERM +trap "" 15 + +# Check for pidfile +if [ -r "$PIDFILE" ] ; then + PID=`cat $PIDFILE` + + # Check if still running + kill -0 $PID > /dev/null 2>&1 + if [ $? != 0 ] ; then + echo "$ME: The adsl-connect script (PID $PID) appears to have died" >& 2 + fi + + # Kill pppd, which should in turn kill pppoe + if [ -r "$PPPD_PIDFILE" ] ; then + PPPD_PID=`cat "$PPPD_PIDFILE"` + $LOGGER -p daemon.notice "Killing pppd" + echo "Killing pppd ($PPPD_PID)" + kill $PPPD_PID > /dev/null 2>&1 || exit 1 + fi + + # Kill adsl-start + PIDS=`cat $STARTPID` + kill -0 $PIDS > /dev/null 2>&1 + if [ $? = 0 ] ; then + $LOGGER -p daemon.notice "Killing adsl-connect" + kill $PIDS > /dev/null 2>&1 + fi + + # Kill adsl-connect + $LOGGER -p daemon.notice "Killing adsl-connect" + echo "Killing adsl-connect ($PID)" + kill $PID > /dev/null 2>&1 + + rm -f "$PIDFILE" "$PPPD_PIDFILE" "$PPPOE_PIDFILE" "$STARTPID" +else + echo "$ME: No ADSL connection appears to be running" >&2 + exit 1 +fi + +exit 0 |