2 #***********************************************************************
6 # All-purpose slicing/dicing shell script to configure rp-pppoe.
10 # Copyright (C) 2000 Roaring Penguin Software Inc.
13 #***********************************************************************
17 exec_prefix
=@exec_prefix@
20 IFCONFIG
=/sbin
/ifconfig
24 LOGGER
="/usr/bin/logger -t `basename $0`"
26 # Set to "C" locale so we can parse messages from commands
30 CONFIG
=/etc
/ppp
/pppoe.conf
32 # Protect created files
37 if [ "$?" != 0 ] ; then
38 $ECHO "*** Error copying $1 to $2"
44 $ECHO "Welcome to the Roaring Penguin PPPoE client setup. First, I will run"
45 $ECHO "some checks on your system to make sure the PPPoE client is installed"
50 if [ "`@ID@ -u`" != 0 ] ; then
51 $ECHO "$0: Sorry, you must be root to run this script"
55 # Prototype config file must exist
56 if [ ! -r "$CONFIG" ] ; then
57 $ECHO "Oh, dear, I don't see the file '$CONFIG' anywhere. Please"
58 $ECHO "re-install the PPPoE client."
63 if [ ! -x $PPPD ] ; then
64 $ECHO "Oops, I can't execute the program '$PPPD'. You"
65 $ECHO "must install the PPP software suite, version 2.3.10 or later."
71 if [ "$DEMAND" = "" ] ; then
76 if [ ! -x "$PPPOE" ] ; then
77 $ECHO "Oh, dear, I can't execute the program '$PPPOE'. Please"
78 $ECHO "re-install the rp-pppoe client."
82 $ECHO "Looks good! Now, please enter some information:"
88 printf "%s" ">>> Enter your PPPoE user name (default $USER): "
91 if [ "$U" = "" ] ; then
95 # Under Linux, "fix" the default interface if eth1 is not available
96 if test `uname -s` = "Linux" ; then
97 $IFCONFIG $ETH > /dev
/null
2>&1 || ETH
=eth0
102 $ECHO ">>> Enter the Ethernet interface connected to the DSL modem"
103 $ECHO "For Solaris, this is likely to be something like /dev/hme0."
104 $ECHO "For Linux, it will be ethn, where 'n' is a number."
105 printf "%s" "(default $ETH): "
108 if [ "$E" = "" ] ; then
113 $ECHO "Do you want the link to come up on demand, or stay up continuously?"
114 $ECHO "If you want it to come up on demand, enter the idle time in seconds"
115 $ECHO "after which the link should be dropped. If you want the link to"
116 $ECHO "stay up permanently, enter 'no' (two letters, lower-case.)"
117 $ECHO "NOTE: Demand-activated links do not interact well with dynamic IP"
118 $ECHO "addresses. You may have some problems with demand-activated links."
119 printf "%s" ">>> Enter the demand value (default $DEMAND): "
121 if [ "$D" = "" ] ; then
128 $ECHO "Please enter the IP address of your ISP's primary DNS server."
129 $ECHO "If your ISP claims that 'the server will provide DNS addresses',"
130 $ECHO "enter 'server' (all lower-case) here."
131 $ECHO "If you just press enter, I will assume you know what you are"
132 $ECHO "doing and not modify your DNS setup."
133 printf "%s" ">>> Enter the DNS information here: "
138 if [ "$DNS1" != "" ] ; then
139 if [ "$DNS1" != "server" ] ; then
140 $ECHO "Please enter the IP address of your ISP's secondary DNS server."
141 $ECHO "If you just press enter, I will assume there is only one DNS server."
142 printf "%s" ">>> Enter the secondary DNS server address here: "
152 printf "%s" ">>> Please enter your PPPoE password: "
155 printf "%s" ">>> Please re-enter your PPPoE password: "
159 if [ "$PWD1" = "$PWD2" ] ; then
163 printf "%s" ">>> Sorry, the passwords do not match. Try again? (y/n)"
166 N|No|NO|Non|n|no|non
)
167 $ECHO "OK, quitting. Bye."
176 if test `uname -s` != "Linux" ; then
177 $ECHO "Sorry, firewalling is only supported under Linux. Consult"
178 $ECHO "your operating system manuals for details on setting up"
179 $ECHO "packet filters for your system."
182 $ECHO "Please choose the firewall rules to use. Note that these rules are"
183 $ECHO "very basic. You are strongly encouraged to use a more sophisticated"
184 $ECHO "firewall setup; however, these will provide basic security. If you"
185 $ECHO "are running any servers on your machine, you must choose 'NONE' and"
186 $ECHO "set up firewalling yourself. Otherwise, the firewall rules will deny"
187 $ECHO "access to all standard servers like Web, e-mail, ftp, etc. If you"
188 $ECHO "are using SSH, the rules will block outgoing SSH connections which"
189 $ECHO "allocate a privileged source port."
192 $ECHO "The firewall choices are:"
193 $ECHO "0 - NONE: This script will not set any firewall rules. You are responsible"
194 $ECHO " for ensuring the security of your machine. You are STRONGLY"
195 $ECHO " recommended to use some kind of firewall rules."
196 $ECHO "1 - STANDALONE: Appropriate for a basic stand-alone web-surfing workstation"
197 $ECHO "2 - MASQUERADE: Appropriate for a machine acting as an Internet gateway"
199 printf "%s" ">>> Choose a type of firewall (0-2): "
201 if [ "$a" = 0 -o "$a" = 1 -o "$a" = 2 ] ; then
204 $ECHO "Please enter a number from 0 to 2"
221 $ECHO "** Summary of what you entered **"
223 $ECHO "Ethernet Interface: $E"
224 $ECHO "User name: $U"
225 if [ "$D" = "no" ] ; then
226 $ECHO "Activate-on-demand: No"
228 $ECHO "Activate-on-demand: Yes; idle timeout = $D seconds"
231 if [ "$DNS1" != "" ] ; then
232 if [ "$DNS1" = "server" ] ; then
233 $ECHO "DNS addresses: Supplied by ISP's server"
235 $ECHO "Primary DNS: $DNS1"
236 if [ "$DNS2" != "" ] ; then
237 $ECHO "Secondary DNS: $DNS2"
241 $ECHO "DNS: Do not adjust"
243 $ECHO "Firewalling: $FIREWALL"
246 printf "%s" '>>> Accept these settings and adjust configuration files (y/n)? '
256 if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then
260 if [ "$ANS" = "y" ] ; then
265 # Adjust configuration files. First to $CONFIG
267 $ECHO "Adjusting $CONFIG"
269 copy
$CONFIG $CONFIG-bak
270 if [ "$DNS1" = "server" ] ; then
276 if [ "$DNS1" = "" ] ; then
283 # Where is pppd likely to put its pid?
284 if [ -d /var
/run
] ; then
290 # Some #$(*& ISP's use a slash in the user name...
291 sed -e "s&^USER=.*&USER='$U'&" \
292 -e "s&^ETH=.*Ð='$E'&" \
293 -e "s&^PIDFILE=.*&PIDFILE=\"$VARRUN/\$CF_BASE-pppoe.pid\"&" \
294 -e "s/^FIREWALL=.*/FIREWALL=$FIREWALL/" \
295 -e "s/^DEMAND=.*/DEMAND=$D/" \
296 -e "s/^DNSTYPE=.*/DNSTYPE=$DNSTYPE/" \
297 -e "s/^DNS1=.*/DNS1=$DNS1/" \
298 -e "s/^DNS2=.*/DNS2=$DNS2/" \
299 -e "s/^PEERDNS=.*/PEERDNS=$PEERDNS/" \
300 < $CONFIG-bak > $CONFIG
302 if [ $?
!= 0 ] ; then
303 $ECHO "** Error modifying $CONFIG"
308 if [ "$DNS1" != "" ] ; then
309 if [ "$DNS1" != "server" ] ; then
310 $ECHO "Adjusting /etc/resolv.conf"
311 if [ -r /etc
/resolv.conf
] ; then
312 grep -s "MADE-BY-RP-PPPOE" /etc
/resolv.conf
> /dev
/null
2>&1
313 if [ "$?" != 0 ] ; then
314 $ECHO " (But first backing it up to /etc/resolv.conf-bak)"
315 copy
/etc
/resolv.conf
/etc
/resolv.conf-bak
318 $ECHO "# MADE-BY-RP-PPPOE" > /etc
/resolv.conf
319 $ECHO "nameserver $DNS1" >> /etc
/resolv.conf
320 if [ "$DNS2" != "" ] ; then
321 $ECHO "nameserver $DNS2" >> /etc
/resolv.conf
326 $ECHO "Adjusting /etc/ppp/pap-secrets and /etc/ppp/chap-secrets"
327 if [ -r /etc
/ppp
/pap-secrets
] ; then
328 $ECHO " (But first backing it up to /etc/ppp/pap-secrets-bak)"
329 copy
/etc
/ppp
/pap-secrets
/etc
/ppp
/pap-secrets-bak
331 cp /dev
/null
/etc
/ppp
/pap-secrets-bak
333 if [ -r /etc
/ppp
/chap-secrets
] ; then
334 $ECHO " (But first backing it up to /etc/ppp/chap-secrets-bak)"
335 copy
/etc
/ppp
/chap-secrets
/etc
/ppp
/chap-secrets-bak
337 cp /dev
/null
/etc
/ppp
/chap-secrets-bak
340 egrep -v "^$U|^\"$U\"" /etc
/ppp
/pap-secrets-bak
> /etc
/ppp
/pap-secrets
341 $ECHO "\"$U\" * \"$PWD1\"" >> /etc
/ppp
/pap-secrets
342 egrep -v "^$U|^\"$U\"" /etc
/ppp
/chap-secrets-bak
> /etc
/ppp
/chap-secrets
343 $ECHO "\"$U\" * \"$PWD1\"" >> /etc
/ppp
/chap-secrets
348 $ECHO "Congratulations, it should be all set up!"
350 $ECHO "Type 'pppoe-start' to bring up your PPPoE link and 'pppoe-stop' to bring"
351 $ECHO "it down. Type 'pppoe-status' to see the link status."