#!/bin/sh # (c) 2005 Miklos Vajna # Copyright (C) 2000 Roaring Penguin Software Inc. # adslconfig for Frugalware # distributed under GPL License TEXTDOMAIN=adslconfig TEXTDOMAINDIR=/usr/share/locale/ # From AUTOCONF prefix=/usr exec_prefix=${prefix} # Paths to programs IFCONFIG=/sbin/ifconfig PPPD=/usr/sbin/pppd PPPOE=${exec_prefix}/sbin/pppoe ECHO=/bin/echo LOGGER="/usr/bin/logger -t `basename $0`" # Set to "C" locale so we can parse messages from commands LANG=C export LANG CONFIG=/etc/ppp/pppoe.conf # Protect created files umask 077 setadsl=$"ADSL configuration" setup=$"Setup" backtitle="$setadsl - Frugalware `cat /etc/frugalware-release |sed 's/[^ ]* \(.*\) (.*/\1/'` $setup" copy() { cp $1 $2 if [ "$?" != 0 ] ; then $ECHO "*** Error copying $1 to $2" $ECHO "*** Quitting." exit 1 fi } msg() { dialog --backtitle "$backtitle" --title "$1" --aspect 20 --msgbox "$2" 0 0 } # usage: title, content, default value, variable ask() { afile=`mktemp /tmp/tmp.XXXXXX` dialog --backtitle "$backtitle" --title "$1" \ --inputbox "$2" 0 0 \ "$3" 2>$afile || return 1 eval $4=`cat $afile` rm $afile } # usage: title, content yesno() { dialog --backtitle "$backtitle" --title "$1" --yesno "$2" 0 0 return $? } msg $"Welcome" $"Welcome to the Frugalware PPPoE client setup. First, I will run some checks on your system to make sure the PPPoE client is installed properly..." if [ "`/usr/bin/id -u`" != 0 ] ; then msg $"Must be root" $"Sorry, you must be root to run this script" exit 1 fi if [ ! -r "$CONFIG" ] ; then msg $"Prototype config file must exist" $"Oh, dear, I don't see the file '$CONFIG' anywhere. Please re-install the PPPoE client with pacman -S rp-pppoe." exit 1 fi if [ ! -x $PPPD ] ; then msg $"Must have pppd" $"Oops, I can't execute the program '$PPPD'. You must install the PPP software suite, version 2.3.10 or later with pacman -S ppp." exit 1 fi export CONFIG . $CONFIG if [ "$DEMAND" = "" ] ; then DEMAND=no fi # pppoe must exist if [ ! -x "$PPPOE" ] ; then msg $"pppoe must exist" $"Oh, dear, I can't execute the program '$PPPOE'. Please re-install the rp-pppoe client with pacman -S rp-pppoe." exit 1 fi while [ true ] ; do ask $"User name" $"Enter your PPPoE user name" "$USER" U # "fix" the default interface if eth1 is not available $IFCONFIG $ETH > /dev/null 2>&1 || ETH=eth0 ask $"Interface" $"Enter the Ethernet interface connected to the DSL modem. It will be ethn, where 'n' is a number." "$ETH" E # ISPs usually claims that "the server will provide DNS addresses" DNS1=server clear while [ true ] do $ECHO "" $ECHO $"PASSWORD" $ECHO "" stty -echo printf ">>> %s: " $"Please enter your PPPoE password" read PWD1 $ECHO "" printf ">>> %s: " $"Please re-enter your PPPoE password" read PWD2 $ECHO "" stty echo if [ "$PWD1" = "$PWD2" ] ; then break fi printf ">>> %s (y/n)" $"Sorry, the passwords do not match. Try again?" read ANS case "$ANS" in N|No|NO|Non|n|no|non) $ECHO $"OK, quitting. Bye." exit 1 esac done # firewall configuration is not pppoe's buisness FIREWALL=NONE if yesno $"Adjust configuration files" $"Accept these settings and adjust configuration files?"; then break fi done # Adjust configuration files. First to $CONFIG copy $CONFIG $CONFIG-bak if [ "$DNS1" = "server" ] ; then DNSTYPE=SERVER DNS1="" PEERDNS=yes else PEERDNS=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-pppoe.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/^PEERDNS=.*/PEERDNS=$PEERDNS/" \ < $CONFIG-bak > $CONFIG if [ $? != 0 ] ; then $ECHO "** Error modifying $CONFIG" $ECHO "** Quitting" exit 1 fi if [ "$DNS1" != "" ] ; then if [ "$DNS1" != "server" ] ; then if [ -r /etc/resolv.conf ] ; then grep -s "MADE-BY-RP-PPPOE" /etc/resolv.conf > /dev/null 2>&1 if [ "$?" != 0 ] ; then 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 if [ -r /etc/ppp/pap-secrets ] ; then 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 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 if [ "$1" != "--fast" ]; then if yesno $"Connect on startup" $"Do you want to bring up your PPPoE link on startup?"; then /usr/sbin/chkconfig --add rc.adsl else /usr/sbin/chkconfig --del rc.adsl fi msg $"Congratulations, it should be all set up!" $"Type 'service adsl start' to bring up your PPPoE link and 'service adsl stop' to bring it down. Type 'pppoe-status' to see the link status." fi exit 0