wok view rp-pppoe/stuff/pppoe-setup @ rev 20310

syslinux/isohybrid.sh: resize EFI partition (again)
author Pascal Bellard <pascal.bellard@slitaz.org>
date Mon May 14 17:12:15 2018 +0200 (2018-05-14)
parents 580279b0298b
children
line source
1 #!/bin/sh
2 #***********************************************************************
3 #
4 # pppoe-setup
5 #
6 # All-purpose slicing/dicing shell script to configure rp-pppoe.
7 #
8 # LIC: GPL
9 #
10 # Copyright (C) 2000 Roaring Penguin Software Inc.
11 #
12 # $Id: pppoe-setup.in,v 1.2 2005/08/10 00:25:18 dfs Exp $
13 #***********************************************************************
15 # From AUTOCONF
16 prefix=/usr
17 exec_prefix=${prefix}
19 # Paths to programs
20 IFCONFIG=/sbin/ifconfig
21 PPPD=/usr/sbin/pppd
22 PPPOE=${exec_prefix}/sbin/pppoe
23 ECHO=/bin/echo
24 LOGGER="/usr/bin/logger -t `basename $0`"
26 # Set to "C" locale so we can parse messages from commands
27 LANG=C
28 export LANG
30 CONFIG=/etc/ppp/pppoe.conf
32 # Protect created files
33 umask 077
35 copy() {
36 cp $1 $2
37 if [ "$?" != 0 ] ; then
38 $ECHO "*** Error copying $1 to $2"
39 $ECHO "*** Quitting."
40 exit 1
41 fi
42 }
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"
46 $ECHO "properly..."
47 $ECHO ""
49 # Must be root
50 if [ "`/bin/id -u`" != 0 ] ; then
51 $ECHO "$0: Sorry, you must be root to run this script"
52 exit 1
53 fi
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."
59 exit 1
60 fi
62 # Must have pppd
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."
66 exit 1
67 fi
68 export CONFIG
69 . $CONFIG
71 if [ "$DEMAND" = "" ] ; then
72 DEMAND=no
73 fi
75 # pppoe must exist
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."
79 exit 1
80 fi
82 $ECHO "Looks good! Now, please enter some information:"
84 while [ true ] ; do
85 $ECHO ""
86 $ECHO "USER NAME"
87 $ECHO ""
88 printf "%s" ">>> Enter your PPPoE user name (default $USER): "
89 read U
91 if [ "$U" = "" ] ; then
92 U="$USER"
93 fi
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
98 fi
99 $ECHO ""
100 $ECHO "INTERFACE"
101 $ECHO ""
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): "
106 read E
108 if [ "$E" = "" ] ; then
109 E="$ETH"
110 fi
112 $ECHO ""
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): "
120 read D
121 if [ "$D" = "" ] ; then
122 D=$DEMAND
123 fi
125 $ECHO ""
126 $ECHO "DNS"
127 $ECHO ""
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: "
135 read DNS1
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: "
143 read DNS2
144 fi
145 fi
147 while [ true ] ; do
148 $ECHO ""
149 $ECHO "PASSWORD"
150 $ECHO ""
151 stty -echo
152 printf "%s" ">>> Please enter your PPPoE password: "
153 read PWD1
154 $ECHO ""
155 printf "%s" ">>> Please re-enter your PPPoE password: "
156 read PWD2
157 $ECHO ""
158 stty echo
159 if [ "$PWD1" = "$PWD2" ] ; then
160 break
161 fi
163 printf "%s" ">>> Sorry, the passwords do not match. Try again? (y/n)"
164 read ANS
165 case "$ANS" in
166 N|No|NO|Non|n|no|non)
167 $ECHO "OK, quitting. Bye."
168 exit 1
169 esac
170 done
172 # Firewalling
173 $ECHO ""
174 $ECHO "FIREWALLING"
175 $ECHO ""
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."
180 FIREWALL=NONE
181 else
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."
190 $ECHO ""
191 while [ true ] ; do
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"
198 $ECHO " for a LAN"
199 printf "%s" ">>> Choose a type of firewall (0-2): "
200 read a
201 if [ "$a" = 0 -o "$a" = 1 -o "$a" = 2 ] ; then
202 break
203 fi
204 $ECHO "Please enter a number from 0 to 2"
205 done
207 case "$a" in
208 0)
209 FIREWALL=NONE
210 ;;
211 1)
212 FIREWALL=STANDALONE
213 ;;
214 2)
215 FIREWALL=MASQUERADE
216 ;;
217 esac
218 fi
220 $ECHO ""
221 $ECHO "** Summary of what you entered **"
222 $ECHO ""
223 $ECHO "Ethernet Interface: $E"
224 $ECHO "User name: $U"
225 if [ "$D" = "no" ] ; then
226 $ECHO "Activate-on-demand: No"
227 else
228 $ECHO "Activate-on-demand: Yes; idle timeout = $D seconds"
229 fi
231 if [ "$DNS1" != "" ] ; then
232 if [ "$DNS1" = "server" ] ; then
233 $ECHO "DNS addresses: Supplied by ISP's server"
234 else
235 $ECHO "Primary DNS: $DNS1"
236 if [ "$DNS2" != "" ] ; then
237 $ECHO "Secondary DNS: $DNS2"
238 fi
239 fi
240 else
241 $ECHO "DNS: Do not adjust"
242 fi
243 $ECHO "Firewalling: $FIREWALL"
244 $ECHO ""
245 while [ true ] ; do
246 printf "%s" '>>> Accept these settings and adjust configuration files (y/n)? '
247 read ANS
248 case "ANS" in
249 Y|y|yes|Yes|oui|Oui)
250 ANS=y
251 ;;
252 N|n|no|No|non|Non)
253 ANS=n
254 ;;
255 esac
256 if [ "$ANS" = "y" -o "$ANS" = "n" ] ; then
257 break
258 fi
259 done
260 if [ "$ANS" = "y" ] ; then
261 break
262 fi
263 done
265 # Adjust configuration files. First to $CONFIG
267 $ECHO "Adjusting $CONFIG"
269 copy $CONFIG $CONFIG-bak
270 if [ "$DNS1" = "server" ] ; then
271 DNSTYPE=SERVER
272 DNS1=""
273 PEERDNS=yes
274 else
275 PEERDNS=no
276 if [ "$DNS1" = "" ] ; then
277 DNSTYPE=NOCHANGE
278 else
279 DNSTYPE=SPECIFY
280 fi
281 fi
283 # Where is pppd likely to put its pid?
284 if [ -d /var/run ] ; then
285 VARRUN=/var/run
286 else
287 VARRUN=/etc/ppp
288 fi
290 # Some #$(*& ISP's use a slash in the user name...
291 sed -e "s&^USER=.*&USER='$U'&" \
292 -e "s&^ETH=.*&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"
304 $ECHO "** Quitting"
305 exit 1
306 fi
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
316 fi
317 fi
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
322 fi
323 fi
324 fi
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
330 else
331 cp /dev/null /etc/ppp/pap-secrets-bak
332 fi
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
336 else
337 cp /dev/null /etc/ppp/chap-secrets-bak
338 fi
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
345 $ECHO ""
346 $ECHO ""
347 $ECHO ""
348 $ECHO "Congratulations, it should be all set up!"
349 $ECHO ""
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."
352 exit 0