Initial import from FreeBSD RELENG_4:
[dragonfly.git] / release / picobsd / dial / lang / dialup.en
1 #!/bin/sh
2 # $FreeBSD: src/release/picobsd/dial/lang/dialup.en,v 1.5 1999/08/28 01:33:20 peter Exp $
3 set_resolv() {
4         echo "\e[H\e[J"
5         echo "\e[1m                       Default Domain Name\e[m"
6         echo ""
7         echo "Here you should enter your default Internet domain. If your"
8         echo "provider uses something like 'www.big.isp.com', this should"
9         echo "be most probably 'big.isp.com'."
10         echo ""
11         echo "If you simply press enter here, you will have a 'mydomain.edu',"
12         echo "which is not the best idea, but may suffice for now..."
13         echo ""
14         read -p "Please enter the default domain name: " domain
15         if [ "X${domain}" = "X" ]
16         then
17                 echo ""
18                 echo "Fine, your domain will be 'mydomain.edu', but be aware"
19                 echo "that it probably doesn't exist."
20                 echo ""
21                 read -p "Press any key to continue." junk
22                 domain="mydomain.edu"
23         fi
24         echo "\e[H\e[J"
25         echo "\e[1m                      DNS Server Address\e[m"
26         echo ""
27         echo "Here you should enter the numeric address of your domain name"
28         echo "server. It is needed for resolving human-readable host names"
29         echo "(such as www.freebsd.org) to machine readable IP numbers. If"
30         echo "it's not set properly, you will have to use numeric IP addresses"
31         echo "when connecting to other hosts, which is highly inconvenient."
32         echo ""
33         echo "If you simply press Enter here, we'll set it to one of root"
34         echo "DNS servers. This may not always work."
35         echo ""
36         read -p "Please enter the DNS server address in form A.B.C.D: " dns
37         if [ "X${dns}" = "X" ]
38         then
39                 echo ""
40                 echo "Fine, your DNS server will be 192.33.4.12, but be aware"
41                 echo "that this may not always work ok."
42                 echo ""
43                 read -p "Press any key to continue." junk
44                 dns="192.33.4.12"
45         fi
46 }
47
48 set_phone() {
49 while [ "X${phone}" = "X" ]
50 do
51         echo "\e[H\e[J"
52         echo "\e[1m                        Phone Number\e[m"
53         echo ""
54         echo "Here you should enter the full phone number you normally"
55         echo "use to connect to your provider, with all necessary prefixes"
56         echo "attached, e.g.: 01122334455"
57         echo ""
58         read -p "Please enter the phone number: " phone
59 done
60 }
61
62 set_port() {
63 while [ "X${dev}" = "X" ]
64 do
65         echo "\e[H\e[J"
66         echo "\e[1m                        Port Number\e[m"
67         echo ""
68         echo "Here you should enter the port number, to which your modem is"
69         echo "attached. REMEMBER: COM1 is port 0 in FreeBSD, COM2 - port 1,"
70         echo "and so on. You should enter only the number, not the full name"
71         echo "of the device."
72         echo ""
73         read -p "Please enter the port number (0,1,2): " dev
74 done
75 }
76
77 set_speed() {
78 while [ "X${speed}" = "X" ]
79 do
80         echo "\e[H\e[J"
81         echo "\e[1m                        Port Speed\e[m"
82         echo ""
83         echo "Here you should choose the serial port speed."
84         echo ""
85         echo "NOTICE: port speed is NOT the same as modem speed - these are"
86         echo "different things. If your modem is capable of V.42 or MNP"
87         echo "compression, the actual speed of serial port should be set much"
88         echo "higher. E.g. for 14.4 kbps modem with compression you should"
89         echo "choose 38400, for 28.8 kbps modem with compression you should"
90         echo "choose 115200."
91         echo ""
92         echo "  1.      9600   bps"
93         echo "  2.      14400  bps"
94         echo "  3.      28800  bps"
95         echo "  4.      38400  bps (14.4 kbps modem with compression)"
96         echo "  5.      57600  bps"
97         echo "  6.      115200 bps (28.8 kbps modem with compression)"
98         echo ""
99         read -p "Please choose the port speed (1-6): " ans
100         case ${ans} in
101         1)
102                 speed=9600
103                 ;;
104         2)
105                 speed=14400
106                 ;;
107         3)
108                 speed=28800
109                 ;;
110         4)
111                 speed=38400
112                 ;;
113         5)
114                 speed=57600
115                 ;;
116         6)
117                 speed=115200
118                 ;;
119         *)
120                 read -p "\aBad value! Press enter to continue..." junk
121                 unset speed
122                 ;;
123         esac
124 done
125 }
126
127 set_timeout() {
128 while [ "X${timo}" = "X" ]
129 do
130         echo "\e[H\e[J"
131         echo "\e[1m                        Idle Timeout\e[m"
132         echo ""
133         echo "Here you should enter timeout (in seconds). After this time, if"
134         echo "the connection is idle, it's disconnected (to save your money :-)"
135         echo ""
136         read -p "Please enter the timeout value: " timo
137 done
138 }
139
140 set_login() {
141 while [ "X${user}" = "X" ]
142 do
143         echo "\e[H\e[J"
144         echo "\e[1m                        Login Name\e[m"
145         echo ""
146         echo "Here you should enter your login name that you normally use"
147         echo "to log in to your provider's terminal server."
148         echo ""
149         read -p "Please enter your login name: " user
150 done
151 }
152
153 set_password() {
154 while [ "X${pass}" = "X" ]
155 do
156         echo "\e[H\e[J"
157         echo "\e[1m                        Password\e[m"
158         echo ""
159         echo "Here you enter the password that you use to log in to the"
160         echo "terminal server."
161         echo ""
162         echo "\e[31mWARNING: your password will be stored in readable form on the"
163         echo "floppy!!! If you don't like it... well, you must dial in manually."
164         echo "In that case abort this script (Ctrl-C). Otherwise, continue.\e[37m"
165         echo ""
166         stty -echo
167         read -p "Please enter your password: " pass
168         echo ""
169         read -p "Enter again your password: " pass1
170         stty echo
171         echo ""
172         if [ "X${pass}" != "X${pass1}" ]
173         then
174                 echo "\aPasswords didn't match! Press Enter to continue..."
175                 read junk
176                 pass=""
177                 set_password
178         fi
179 done
180 }
181
182 set_chat() {
183 echo "\e[H\e[J"
184 while [ "X${chat}" = "X" ]
185 do
186         echo "\e[1m                     Type of Login Dialog\e[m"
187         echo ""
188         echo "What type of login dialog do you expect from the terminal server?"
189         echo ""
190         echo "1)        \e[32m......login:\e[37m ${user}"
191         echo "  \e[32m...password:\e[37m ********"
192         echo "          \e[36m(terminal server starts PPP here)\e[37m"
193         echo "2)        \e[32m......login:\e[37m ${user}"
194         echo "  \e[32m...password:\e[37m ********"
195         echo "  \e[32m...protocol:\e[37m ppp"
196         echo "          \e[36m(terminal server starts PPP here)\e[37m"
197         echo "3)        \e[32m......username:\e[37m ${user}"
198         echo "  \e[32m......password:\e[37m ********"
199         echo "          \e[36m(terminal server starts PPP here)\e[37m"
200         echo "4)        \e[32m......username:\e[37m ${user}"
201         echo "  \e[32m......password:\e[37m ********"
202         echo "  \e[32mportX/..xxx...:\e[37m ppp"
203         echo "          \e[36m(terminal server starts PPP here)\e[37m"
204         echo "5)        \e[32mUse CHAP to log in.\e[37m"
205         echo "6)        \e[32mUse PAP to log in.\e[37m"
206         echo ""
207         read -p "Choose 1,2,3,4,5 or 6: " chat
208         case ${chat} in
209         1)
210                 chat1="TIMEOUT 10 ogin:--ogin: ${user} word: \\\\P"
211                 chat2="login/password"
212                 ;;
213         2)
214                 chat1="TIMEOUT 10 ogin:--ogin: ${user} word: \\\\P otocol: ppp"
215                 chat2="login/password/protocol"
216                 ;;
217         3)
218                 chat1="TIMEOUT 10 ername:--ername: ${user} word: \\\\P"
219                 chat2="username/password"
220                 ;;
221         4)
222                 chat1="TIMEOUT 10 ername:--ername: ${user} word: \\\\P port ppp"
223                 chat2="username/password/port"
224                 ;;
225         5)      chat1="-"
226                 chat2="CHAP"
227                 ;;
228         6)      chat1="-"
229                 chat2="PAP"
230                 ;;
231         *)      echo "\aBad value! Please choose 1,2,3 or 4."
232                 echo ""
233                 unset chat
234                 unset chat2
235                 ;;
236         esac
237 done
238 }
239
240 # Main entry of the script
241
242 echo "\e[H\e[J"
243 echo "\e[1m              Welcome to The Simplest PPP Configurator! :-)\e[m"
244 echo ""
245 echo "    Your PPP is already preconfigured, so that you can dial manually."
246 echo "However, you probably noticed that it requires chatting with your modem"
247 echo "and logging in every time you want to connect. It's simple and it works,"
248 echo "but it's also annoying."
249 echo ""
250 echo "This script will try to configure your PPP so that you can run it in"
251 echo "background (thus freeing the console), and log in automatically."
252 echo ""
253 echo "If you want to continue, press \e[1mEnter\e[m, otherwise press \e[1mCtrl-C\e[m."
254 echo ""
255 read junk
256
257 # Step through the options.
258 set_phone
259 set_port
260 set_speed
261 set_timeout
262 set_login
263 set_password
264 set_chat
265 set_resolv
266
267 ans="loop_it"
268 while [ "X${ans}" != "X" ]
269 do
270
271 echo "\e[H\e[J"
272 echo "\e[1m     Ok. You assigned the following values:\e[m"
273 echo ""
274 echo "  1.      Phone number:   ${phone}"
275 echo "  2.      Port number:    cuaa${dev}"
276 echo "  3.      Port speed:     ${speed} baud"
277 echo "  4.      Timeout:        ${timo} s"
278 echo "  5.      Login name:     ${user}"
279 echo "  6.      Password:       ${pass}"
280 echo "  7.      Chat pattern:   ${chat} (${chat2})"
281 echo "  8.      Default domain: ${domain}"
282 echo "          DNS Server:     ${dns}"
283 echo ""
284 echo "If you're satisfied with these values, just press \e[1mEnter\e[m."
285 read -p "Otherwise, enter the number of the option you want to change (1-8): " ans
286 a="X${ans}"
287 case ${a} in
288 X1)
289         unset phone
290         set_phone
291         ;;
292 X2)
293         unset dev
294         set_port
295         ;;
296 X3)
297         unset speed
298         set_speed
299         ;;
300 X4)
301         unset timo
302         set_timeout
303         ;;
304 X5)
305         unset user
306         set_login
307         ;;
308 X6)
309         unset pass
310         set_password
311         ;;
312 X7)
313         unset chat
314         set_chat
315         ;;
316 X8)
317         unset dns
318         unset domain
319         set_resolv
320         ;;
321 X)      ;;
322 *)
323         read -p "Unknown option: ${ans}. Press enter to continue..."
324         ;;
325 esac
326
327 done
328
329 echo ""
330 echo -n "Generating /etc/ppp/ppp.conf file..."
331 rm -f /etc/ppp/ppp.conf
332 cp /etc/ppp/ppp.conf.template /etc/ppp/ppp.conf
333 echo "" >>/etc/ppp/ppp.conf
334 echo "# This part was generated with $0" >>/etc/ppp/ppp.conf
335 echo "dialup:" >>/etc/ppp/ppp.conf
336 echo " set line /dev/cuaa${dev}" >>/etc/ppp/ppp.conf
337 echo " set speed ${speed}" >>/etc/ppp/ppp.conf
338 echo " set phone ${phone}" >>/etc/ppp/ppp.conf
339 echo " set authkey ${pass}" >>/etc/ppp/ppp.conf
340 echo " set timeout ${timo}" >>/etc/ppp/ppp.conf
341 if [ "X${chat1}" = "-" ]
342 then
343         echo " set authname ${user}" >>/etc/ppp/ppp.conf
344 else
345         echo " set login \"${chat1}\"" >>/etc/ppp/ppp.conf
346 fi
347 echo " set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0" >>/etc/ppp/ppp.conf
348
349 echo " Done."
350 echo -n "Generating /etc/resolv.conf..."
351 echo "# This file was generated with $0">/etc/resolv.conf
352 echo "domain ${domain}" >>/etc/resolv.conf
353 echo "nameserver ${dns}">>/etc/resolv.conf
354 echo "hostname=\"pico.${domain}\"">>/etc/rc.conf
355
356 echo " Done."
357
358 echo ""
359 echo "REMEMBER to run /stand/update! Otherwise these changes will be lost!"
360 echo ""
361 echo "Please check the contents of /etc/ppp/ppp.conf, and edit it if"
362 echo "necessary. When you're satisfied with it, run ppp in background:"
363 echo ""
364 echo "  \e[1mppp -background dialup\e[m"
365 echo ""
366 echo "Now, if you're sure that your /etc/ppp/ppp.conf file is ok (which is"
367 echo -n "probable :-) would you like to start the dialup connection now? (y/n) "
368 read ans
369 opts=""
370 while [ "X${ans}" = "Xy" ]
371 do
372         echo "\e[H\e[J"
373         if [ "X${opts}" = "X" ]
374         then
375                 echo "We'll use the following arguments to 'ppp':"
376                 echo ""
377                 echo "          ppp -background dialup"
378                 echo ""
379                 echo -n "Would you like to change them? (y/n) "
380                 read oo
381                 if [ "X${oo}" = "Xy" ]
382                 then
383                         read -p "Enter ppp arguments here: " opts
384                 else
385                         opts="-background dialup"
386                 fi
387                 echo ""
388                 echo ""
389         fi
390         echo "Starting dialup connection. Wait until you see a 'PPP Enabled' message..."
391         echo ""
392         ppp ${opts}
393         if [ "X$?" != "X0" ]
394         then
395                 echo ""
396                 echo -n "Hmmm... Command failed. Try again? (y/n) "
397                 read ans
398                 if [ "X${ans}" != "Xy" ]
399                 then
400                         echo ""
401                         echo "Try again later. Check also your config file (/etc/ppp/ppp.conf)"
402                         echo ""
403                 fi
404         else
405                 echo ""
406                 echo "Congratulations! You're on-line now."
407                 echo ""
408                 exit 0
409         fi
410 done