home *** CD-ROM | disk | FTP | other *** search
/ PC Welt 2006 March / PCWELT_3_2006.ISO / base / 05_common.mo / usr / sbin / pppsetup < prev    next >
Encoding:
Text File  |  2004-02-26  |  57.2 KB  |  1,718 lines

  1. #!/bin/bash 
  2. #    PPPSETUP  --  Script to set up pppd
  3. #      History:
  4. #      7/21/95 RSL         Script created (v1.0)
  5. #         9/15/96 RSL         Added code to get the ISP's domainname (v1.1)
  6. #         9/19/96 RSL         Revamped interface to use the 'dialog' 
  7. #                             program. (v1.2)
  8. #         2/22/98 KR          Added pap, chap, ms-chap, callback, & 
  9. #                             modem init string options. (v1.98)
  10. #                             Creates /etc/ppp/options, & pap, chap, 
  11. #                  secrets files.
  12. #                             More guidance.
  13. #                             Monitor connection with tail & syslogd.
  14. #                             Demand dialing setup with ppp-2.3.0 or later.        
  15. #          4/4/98 PJV         Fixed massive /tmp-related security problems
  16. #                             Switched to a default init string that's more
  17. #                             likely to work
  18. #                             Increased TIMEOUTs
  19. #                             fixed bad flags given to chat -- caused dialout
  20. #                             to fail
  21. #          2/6/1999 PJV       Changed all occurances of /dev/cua* to /dev/ttyS*
  22. #          5/3/1999 PJV       Commented 'debug' in /etc/ppp/options
  23. #                             Add commented 'noauth' in /etc/ppp/options so
  24. #                             people who want to use ppp but already have a
  25. #                             default route have an easier time figuring out
  26. #                             what to do. :)
  27. #          6/18/2000 PJV      Added code to check for "ppp-stop" and "ppp-on"
  28. #                             symlinks, and make them if they don't exist.
  29. #          5/19/2002 PJV      Added support for more devices.
  30.  
  31. TMP=/var/log/setup/tmp
  32.  
  33. if [ ! "$UID" = "0" ]; then
  34. echo
  35. echo "NOTICE: * $LOGNAME * You need to be 'root' to run this script."
  36. echo "You could login: root"
  37. echo "You could also try this: # sudo pppsetup"
  38. echo "You could also try this: # su -c pppsetup"
  39. echo "This assumes the permissions on 'sudo' and 'su' are 4111."
  40. echo "To give 'su' or 'sudo' these permissions, you have to be root."
  41. echo "~# chown root.root sudo ; chmod 4111 sudo"
  42. echo "You also need a /etc/sudoers file for 'sudo'."
  43. echo
  44. exit 1
  45. fi
  46.  
  47. if ! type -all "dialog" >/dev/null 2>&1 ; then
  48. echo
  49. echo "Can't find 'dialog', i can't run without 'dialog' on your system."
  50. echo "You can get a compiled ELF version of 'dialog' from here."
  51. echo "http://www.tux.org/pub/people/kent-robotti/index.html"
  52. echo "ftp://ftp.tux.org/pub/people/kent-robotti   'dialog-0.9a.ELF.tar.gz'"
  53. echo
  54. exit 1
  55. fi
  56.  
  57. if [ -s /usr/lib/setup/hdsetup ]; then
  58. SYS="on SLACKWARE."
  59. fi
  60.  
  61. VERSION="1.98"
  62.  
  63. stty erase ^? 2>/dev/null 
  64.  
  65. if [ ! -r /usr/sbin/ppp-stop ]; then
  66.   ( cd /usr/sbin ; ln -sf ppp-off ppp-stop )
  67. fi
  68. if [ ! -r /usr/sbin/ppp-on ]; then
  69.   ( cd /usr/sbin ; ln -sf ppp-go ppp-on )
  70. fi
  71.  
  72. echo "PPPSETUP $VERSION $SYS" > $TMP/txtTEMP01
  73. echo >> $TMP/txtTEMP01
  74. echo "Written by Robert S. Liesenfeld <xunil@bitstream.net> <IRC:Xunil>" >> $TMP/txtTEMP01
  75. echo "Changes for 1.98 by Kent Robotti <robotti@erols.com>" >> $TMP/txtTEMP01
  76. echo "Patched for Slackware by Patrick Volkerding <volkerdi@slackware.com>" >> $TMP/txtTEMP01
  77. echo >> $TMP/txtTEMP01
  78. echo "You should get these docs if you don't already have them:" >> $TMP/txtTEMP01
  79. echo >> $TMP/txtTEMP01
  80. echo "ftp://metalab.unc.edu/pub/Linux/docs/howto/PPP-HOWTO" >> $TMP/txtTEMP01
  81. echo "ftp://metalab.unc.edu/pub/Linux/docs/faqs/PPP-FAQ" >> $TMP/txtTEMP01
  82. echo >> $TMP/txtTEMP01
  83. echo "Press [Enter] to continue with pppsetup..." >> $TMP/txtTEMP01
  84.  
  85. dialog --backtitle "PPPSETUP $VERSION/Slackware" --textbox "$TMP/txtTEMP01" 16 73 
  86.  
  87. while [ -z "$PHONENUM" ]
  88. do
  89. echo "To begin setting up your PPP connection, i need to know a few things." > $TMP/txtTEMP$$
  90. echo "For starters, what is the phone number of your (I)nternet (S)ervice" >> $TMP/txtTEMP$$ 
  91. echo "(P)rovider?" >> $TMP/txtTEMP$$ 
  92. echo  >> $TMP/txtTEMP$$ 
  93. echo "Example: atdt6661776   <-For (t)one dialing.)" >> $TMP/txtTEMP$$ 
  94. echo "Example: atdp6661776   <-For (p)ulse dialing.)" >> $TMP/txtTEMP$$ 
  95. echo  >> $TMP/txtTEMP$$ 
  96. echo "Include the: atd?  It's usally just: atdtphonenumber" >> $TMP/txtTEMP$$ 
  97. echo  >> $TMP/txtTEMP$$ 
  98. echo "(Note: in the USA, use atdt*70,6661776 [comma required!] to turn" >> $TMP/txtTEMP$$ 
  99. echo " off call waiting.)" >> $TMP/txtTEMP$$ 
  100. echo  >> $TMP/txtTEMP$$ 
  101.     
  102. dialog --title "PHONE NUMBER ..." --inputbox "`cat $TMP/txtTEMP$$`" 18 75 2> $TMP/rspTEMP$$   
  103.  
  104. if [ $? = 1 ]; then
  105. rm -f $TMP/*TEMP*
  106. clear 2>/dev/null || echo
  107. echo "PPP configuration cancelled."
  108. exit
  109. fi 
  110.  
  111. PHONENUM="`cat $TMP/rspTEMP$$`"
  112.  
  113. if [ -z "$PHONENUM" ]; then
  114. clear 2>/dev/null || echo
  115. rm -f $TMP/*TEMP*
  116. echo "PPP configuration cancelled."
  117. echo "No phone number."
  118. exit
  119. fi
  120. done
  121.  
  122. echo "Where is your modem /dev/ttyS?" > $TMP/txtTEMP$$ 
  123. dialog --backtitle "MODEM DEVICE ..." --menu "`cat $TMP/txtTEMP$$`" 17 60 10 \
  124. modem "= use whatever /dev/modem is linked to" \
  125. ttyS0 "= (COM1: under DOS)" \
  126. ttyS1 "= (COM2: under DOS)" \
  127. ttyS2 "= (COM3: under DOS)" \
  128. ttyS3 "= (COM4: under DOS)" \
  129. ttyS4 "= PCI modem" \
  130. ttyS5 "= PCI modem" \
  131. ttyS6 "= PCI modem" \
  132. ttyS7 "= PCI modem" \
  133. ttyS8 "= PCI modem" \
  134. ttyS9 "= PCI modem" \
  135. ttyS10 "= PCI modem" \
  136. ttyS11 "= PCI modem" \
  137. ttyS12 "= PCI modem" \
  138. ttyS13 "= PCI modem" \
  139. ttyS14 "= PCI modem" \
  140. ttyS15 "= PCI modem" \
  141. 2> $TMP/rspTEMP$$
  142.  
  143. MODEM="`cat $TMP/rspTEMP$$`"
  144.  
  145. if [ ! "$MODEM" = "modem" ]; then
  146.   if [ -z $MODEM ]; then
  147.     clear 2>/dev/null || echo
  148.     rm -f $TMP/*TEMP*
  149.     echo "PPP configuration cancelled."
  150.     exit 
  151.   elif [ ! -c "/dev/$MODEM" ]; then
  152.     /dev/MAKEDEV $MODEM >/dev/null 2>&1 || MODERROR="YES"
  153.   else
  154.     rm -f /dev/modem 2>/dev/null
  155.     ln -sf /dev/$MODEM /dev/modem 2>/dev/null
  156.   fi
  157. fi
  158.  
  159. echo "What baud rate is your modem?" > $TMP/txtTEMP$$
  160. dialog --backtitle "MODEM BAUD RATE ..." --menu "`cat $TMP/txtTEMP$$`" 14 72 7 \
  161. 460800 "460KBps  - ISDN modem..." \
  162. 230400 "230KBps  - 56Kbps modem... or ISDN modem..." \
  163. 115200 "115KBps  - 28.8, 33.6, or 56Kbps modem..." \
  164. 57600  "57.6KBps - 28.8, 33.6, or 56Kbps modem..." \
  165. 38400  "38.4KBps - Hangin ten on the net! 28.8 or 33.6..." \
  166. 19200  "19.2KBps - Better known as 14.4..." \
  167. 9600   "9600bps  - No comment..." 2> $TMP/rspTEMP$$
  168.  
  169. BAUDRATE="`cat $TMP/rspTEMP$$`"
  170.  
  171. if [ -z $BAUDRATE ]; then
  172. clear 2>/dev/null || echo
  173. rm -f $TMP/*TEMP*
  174. echo "PPP configuration cancelled."
  175. exit 
  176. fi
  177.  
  178. echo "Does your service provider use CALLBACK?" > $TMP/txtTEMP$$
  179. echo >> $TMP/txtTEMP$$
  180. echo "CALLBACK is when you call your service provider and give them" >> $TMP/txtTEMP$$
  181. echo "your phone number so they can call you back, then when they" >> $TMP/txtTEMP$$
  182. echo "call you back you give them your login name and password." >> $TMP/txtTEMP$$
  183. echo >> $TMP/txtTEMP$$
  184. echo "Most service providers don't use CALLBACK, so the answer is" >> $TMP/txtTEMP$$
  185. echo "probably No, unless you know otherwise." >> $TMP/txtTEMP$$
  186. echo >> $TMP/txtTEMP$$
  187.  
  188. dialog --backtitle "CALLBACK YES or NO? ..." --menu "`cat $TMP/txtTEMP$$`" 16 70 2 "NO" "Most Internet providers do not use callback" "YES" "Use callback support (I know what I'm doing)" 2> $TMP/replyTEMP$$
  189.  
  190. if [ "`cat $TMP/replyTEMP$$`" = "YES" ]; then
  191. echo "Put your phone number in the box below, so your service provider" > $TMP/txtTEMP$$
  192. echo "can call you back." >> $TMP/txtTEMP$$
  193. echo >> $TMP/txtTEMP$$
  194. echo "Example: 7771818" >> $TMP/txtTEMP$$
  195. echo >> $TMP/txtTEMP$$
  196.  
  197. dialog --backtitle "CALLBACK Your Phone Number? ..." --inputbox "`cat $TMP/txtTEMP$$`" 11 72 2> $TMP/cb1TEMP$$
  198.  
  199. if [ $? = 1 ]; then
  200. clear 2>/dev/null || echo
  201. rm -f $TMP/*TEMP*
  202. echo "PPP configuration cancelled."
  203. exit 
  204. elif [ ! -s $TMP/cb1TEMP$$ ]; then
  205. clear 2>/dev/null || echo
  206. rm -f $TMP/*TEMP*
  207. echo "PPP configuration cancelled."
  208. echo "No Phone Number for Callback."
  209. exit
  210. fi 
  211. fi
  212.  
  213. if [ -s $TMP/cb1TEMP$$ ]; then
  214. CBPN="`cat $TMP/cb1TEMP$$`"
  215. echo "I have your phone number: $CBPN" > $TMP/txtTEMP$$
  216. echo >> $TMP/txtTEMP$$
  217. echo "Do you have to give a Username or Login for the initial connection" >> $TMP/txtTEMP$$
  218. echo "to $PHONENUM before you're called back." >> $TMP/txtTEMP$$
  219. echo >> $TMP/txtTEMP$$
  220. echo "Example: jerry" >> $TMP/txtTEMP$$
  221. echo >> $TMP/txtTEMP$$
  222. echo "If NO, just press [Enter] on a empty box and skip this." >> $TMP/txtTEMP$$
  223.  
  224. dialog --backtitle "CALLBACK INITIAL LOGIN? ..." --inputbox "`cat $TMP/txtTEMP$$`" 15 74 2> $TMP/cb1.1TEMP$$
  225.  
  226. if [ $? = 1 ]; then
  227. rm -f $TMP/*TEMP*
  228. clear 2>/dev/null || echo
  229. echo "PPP configuration cancelled."
  230. exit 
  231. else
  232. CBMODLOGIN="`cat $TMP/cb1.1TEMP$$`"
  233. fi 
  234. fi
  235.  
  236. if [ -s $TMP/cb1TEMP$$ ]; then
  237. echo "I have your phone number: $CBPN" > $TMP/txtTEMP$$
  238. if [ -s $TMP/cb1.1TEMP$$ ]; then
  239. echo "I see you have to give a Username or Login: $CBMODLOGIN" >> $TMP/txtTEMP$$
  240. echo "for the initial connection to: $PHONENUM" >> $TMP/txtTEMP$$
  241. fi
  242. echo >> $TMP/txtTEMP$$
  243. echo "Do you have to give a Password for the initial connection" >> $TMP/txtTEMP$$
  244. echo "to $PHONENUM before you're called back." >> $TMP/txtTEMP$$
  245. echo >> $TMP/txtTEMP$$
  246. echo "Example: Zoy85mWc" >> $TMP/txtTEMP$$
  247. echo >> $TMP/txtTEMP$$
  248. echo "If NO, just press [Enter] on a empty box and skip this." >> $TMP/txtTEMP$$
  249.  
  250. dialog --backtitle "CALLBACK INITIAL PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP$$`" 17 68 2> $TMP/cb2TEMP$$
  251.  
  252. if [ $? = 1 ]; then
  253. rm -f $TMP/*TEMP*
  254. clear 2>/dev/null || echo
  255. echo "PPP configuration cancelled."
  256. exit 
  257. else
  258. CBMODPASS="`cat $TMP/cb2TEMP$$`"
  259. fi
  260. fi
  261.  
  262. if [ ! -z "$CBPN" ]; then
  263. echo "Are they using PAP or CHAP for AUTHENTICATION? If so answer YES." > $TMP/txtTEMP$$
  264. echo "Do they present you with a Username: or Login: and Password: prompt" >> $TMP/txtTEMP$$
  265. echo "when they call you back, if so they're probably not using PAP or" >> $TMP/txtTEMP$$
  266. echo "CHAP, so you can answer NO here." >> $TMP/txtTEMP$$
  267. echo "If you're not sure, you'll have to ask you're service provider." >> $TMP/txtTEMP$$
  268.  
  269. dialog --backtitle "CALLBACK PAP-CHAP YES or NO? ..." --yesno "`cat $TMP/txtTEMP$$`" 9 72 
  270.  
  271. if [ $? = 1 ]; then
  272. echo "What is your Username or Login to your service provider?" > $TMP/txtTEMP$$
  273. echo >> $TMP/txtTEMP$$
  274. echo "This is the information you'll give them when they call" >> $TMP/txtTEMP$$
  275. echo "you back at: $CBPN" >> $TMP/txtTEMP$$
  276. echo >> $TMP/txtTEMP$$
  277. echo "Example: jerry" >> $TMP/txtTEMP$$
  278.  
  279. dialog --backtitle "CALLBACK LOGIN? ..." --inputbox "`cat $TMP/txtTEMP$$`" 13 72 2> $TMP/cb3TEMP$$
  280.  
  281. if [ $? = 1 ]; then
  282. rm -f $TMP/*TEMP*
  283. clear 2>/dev/null || echo
  284. echo "PPP configuration cancelled."
  285. exit 
  286. fi
  287.  
  288. CBLOGIN="`cat $TMP/cb3TEMP$$`"
  289.  
  290. if [ -z "$CBLOGIN" ]; then
  291. rm -f $TMP/*TEMP*
  292. clear 2>/dev/null || echo
  293. echo "PPP configuration cancelled."
  294. echo "No Login for Callback."
  295. exit 
  296. fi
  297. fi
  298. fi
  299.  
  300. if [ ! -z "$CBLOGIN" ]; then
  301. echo "What is the Password for: $CBLOGIN" > $TMP/txtTEMP$$
  302. echo >> $TMP/txtTEMP$$
  303. echo "Example: Ziy79Kie" >> $TMP/txtTEMP$$
  304. echo >> $TMP/txtTEMP$$
  305.  
  306. dialog --backtitle "CALLBACK PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP$$`" 10 64 2> $TMP/cb4TEMP$$
  307.  
  308. if [ $? = 1 ]; then
  309. rm -f $TMP/*TEMP*
  310. clear 2>/dev/null || echo
  311. echo "PPP configuration cancelled."
  312. exit 1 
  313. fi
  314.  
  315. CBPASS="`cat $TMP/cb4TEMP$$`"
  316.  
  317. if [ -z "$CBPASS" ]; then
  318. rm -f $TMP/*TEMP*
  319. clear 2>/dev/null || echo
  320. echo "PPP configuration cancelled."
  321. echo "No Password for Callback."
  322. exit 1
  323. fi
  324. fi
  325.  
  326. callback1() {
  327.  cat << EOF
  328. TIMEOUT         60
  329. ABORT         BUSY                
  330. ABORT         ERROR                
  331. ABORT         VOICE                
  332. ABORT         "NO CARRIER"           
  333. ABORT         "NO DIALTONE"           
  334. ""         "AT\&FS0=1H0"          
  335. OK         "ATDT$PHONENUM"            
  336. TIMEOUT         60
  337. CONNECT         ""                
  338. ogin:--name: "$CBMODLOGIN"                    
  339. word:--word: "$CBMODPASS"
  340. CLR_ABORT "NO CARRIER"
  341. HANGUP OFF            
  342. TIMEOUT         90
  343. CONNECT         ""
  344. HANGUP 0N
  345. ABORT         "NO CARRIER"           
  346. ogin:--name: "$CBLOGIN"                    
  347. word:--word: "$CBPASS"
  348.  
  349. EOF
  350. }
  351.  
  352. callback2() {
  353.  cat << EOF
  354. TIMEOUT 60
  355. ABORT    BUSY                
  356. ABORT    ERROR                
  357. ABORT    VOICE                
  358. ABORT    "NO CARRIER"           
  359. ABORT    "NO DIALTONE"           
  360. ""    "AT\&FS0=1H0"          
  361. OK    "ATDT$PHONENUM"            
  362. TIMEOUT    60
  363. CONNECT    ""                
  364. CLR_ABORT "NO CARRIER"
  365. HANGUP OFF            
  366. TIMEOUT    90
  367. CONNECT    "\c"
  368. HANGUP 0N
  369. ABORT   "NO CARRIER"           
  370.  
  371. EOF
  372. }
  373.  
  374. callback3() {
  375.  cat << EOF
  376. TIMEOUT         60
  377. ABORT         BUSY                
  378. ABORT         ERROR                
  379. ABORT         VOICE                
  380. ABORT         "NO CARRIER"           
  381. ABORT         "NO DIALTONE"           
  382. ""         "AT\&FS0=1H0"          
  383. OK         "ATDT$PHONENUM"            
  384. TIMEOUT         60
  385. CONNECT         ""                
  386. CLR_ABORT "NO CARRIER"
  387. HANGUP OFF            
  388. TIMEOUT         90
  389. CONNECT         ""
  390. HANGUP 0N
  391. ABORT         "NO CARRIER"           
  392. ogin:--name: "$CBLOGIN"                    
  393. word:--word: "$CBPASS"
  394.  
  395. EOF
  396. }
  397.  
  398. callback4() {
  399.  cat << EOF
  400. TIMEOUT         60
  401. ABORT         BUSY                
  402. ABORT         ERROR                
  403. ABORT         VOICE                
  404. ABORT         "NO CARRIER"           
  405. ABORT         "NO DIALTONE"           
  406. ""         "AT\&FS0=1H0"          
  407. OK         "ATDT$PHONENUM"            
  408. TIMEOUT         60
  409. CONNECT         ""                
  410. word:--word: "$CBMODPASS"            
  411. CLR_ABORT "NO CARRIER"
  412. HANGUP OFF            
  413. TIMEOUT         90
  414. CONNECT         ""
  415. HANGUP 0N
  416. ABORT         "NO CARRIER"           
  417. ogin:--name: "$CBLOGIN"                    
  418. word:--word: "$CBPASS"
  419.  
  420. EOF
  421. }
  422.  
  423. callback5() {
  424.  cat << EOF
  425. TIMEOUT         60
  426. ABORT         BUSY                
  427. ABORT         ERROR                
  428. ABORT         VOICE                
  429. ABORT         "NO CARRIER"           
  430. ABORT         "NO DIALTONE"           
  431. ""         "AT\&FS0=1H0"          
  432. OK         "ATDT$PHONENUM"            
  433. TIMEOUT         60
  434. CONNECT         ""                
  435. ogin:--name: "$CBMODLOGIN"                    
  436. word:--word: "$CBMODPASS"            
  437. CLR_ABORT "NO CARRIER"
  438. HANGUP OFF            
  439. TIMEOUT         90
  440. CONNECT      "\c"           
  441. HANGUP 0N
  442. ABORT         "NO CARRIER"           
  443.  
  444. EOF
  445. }
  446.  
  447. callback6() {
  448.  cat << EOF
  449. TIMEOUT         60
  450. ABORT         BUSY                
  451. ABORT         ERROR                
  452. ABORT         VOICE                
  453. ABORT         "NO CARRIER"           
  454. ABORT         "NO DIALTONE"           
  455. ""         "AT\&FS0=1H0"          
  456. OK         "ATDT$PHONENUM"            
  457. TIMEOUT         60
  458. CONNECT         ""                
  459. ogin:--name: "$CBMODLOGIN"                    
  460. CLR_ABORT "NO CARRIER"
  461. HANGUP OFF            
  462. TIMEOUT         90
  463. CONNECT      "\c"           
  464. HANGUP 0N
  465. ABORT         "NO CARRIER"           
  466.  
  467. EOF
  468. }
  469.  
  470. callback7() {
  471.  cat << EOF
  472. TIMEOUT         60
  473. ABORT         BUSY                
  474. ABORT         ERROR                
  475. ABORT         VOICE                
  476. ABORT         "NO CARRIER"           
  477. ABORT         "NO DIALTONE"           
  478. ""         "AT\&FS0=1H0"          
  479. OK         "ATDT$PHONENUM"            
  480. TIMEOUT         60
  481. CONNECT         ""                
  482. word:--word: "$CBMODPASS"            
  483. CLR_ABORT "NO CARRIER"
  484. HANGUP OFF            
  485. TIMEOUT         90
  486. CONNECT      "\c"           
  487. HANGUP 0N
  488. ABORT         "NO CARRIER"           
  489.  
  490. EOF
  491. }
  492.  
  493. if [ ! -d /etc/ppp ]; then 
  494. mkdir -p /etc/ppp
  495. fi
  496.  
  497. if [ -s $TMP/cb1TEMP$$ ]; then
  498. if [ -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
  499. callback1 > /etc/ppp/callback
  500. elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
  501. callback2 > /etc/ppp/callback
  502. elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
  503. callback3 > /etc/ppp/callback
  504. elif [ ! -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ -s $TMP/cb3TEMP$$ ] && [ -s $TMP/cb4TEMP$$ ]; then
  505. callback4 > /etc/ppp/callback
  506. elif [ -s $TMP/cb1.1TEMP$$ ] && [ -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
  507. callback5 > /etc/ppp/callback
  508. elif [ -s $TMP/cb1.1TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
  509. callback6 > /etc/ppp/callback
  510. elif [ -s $TMP/cb2TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ ! -s $TMP/cb4TEMP$$ ]; then
  511. callback7 > /etc/ppp/callback
  512. fi
  513. fi
  514.  
  515. if [ -s /etc/ppp/callback ]; then
  516. chown root.root /etc/ppp/callback 2>/dev/null
  517. chmod 600 /etc/ppp/callback 2>/dev/null
  518. fi
  519.  
  520. if [ ! -s $TMP/cb1TEMP$$ ]; then    
  521. echo 'The default modem init string will be: "AT&FH0" OK' > $TMP/txtTEMP$$
  522. echo >> $TMP/txtTEMP$$
  523. echo "If you want to change it, put your init string in the box below." >> $TMP/txtTEMP$$
  524. echo >> $TMP/txtTEMP$$
  525. echo "If you use \ in the init string, put it twice." >> $TMP/txtTEMP$$
  526. echo 'Example: "AT\&F\\K3\\N3H0" OK' >> $TMP/txtTEMP$$
  527. echo "M = No sound.  S95=46 = Show CARRIER speed: 28800 etc." >> $TMP/txtTEMP$$
  528. echo 'Put "" around each init string with "&" in it.' >> $TMP/txtTEMP$$
  529. echo 'Put OK after each init string. Example: ATZ OK "AT\&F1MH0" OK' >> $TMP/txtTEMP$$
  530. echo >> $TMP/txtTEMP$$
  531. echo "Just press [Enter] on a empty box to accept the default above." >> $TMP/txtTEMP$$
  532.  
  533. dialog --backtitle "MODEM INIT STRING ..." --inputbox "`cat $TMP/txtTEMP$$`" 18 74 2> $TMP/rspTEMP$$
  534.  
  535. if [ $? = 1 ]; then
  536. rm -f $TMP/*TEMP*
  537. clear 2>/dev/null || echo
  538. echo "PPP configuration cancelled."
  539. exit 
  540. fi 
  541.  
  542. if [ -s $TMP/rspTEMP$$ ]; then
  543. INIT="`cat $TMP/rspTEMP$$`"
  544. else
  545. INIT="below"
  546. fi
  547. fi
  548.  
  549. echo "What is your (I)nternet (S)ervice (P)rovider's domain name?" > $TMP/txtTEMP$$
  550. echo >> $TMP/txtTEMP$$
  551. echo "This is usually something like..." >> $TMP/txtTEMP$$
  552. echo "Examples: something.edu something.net something.com something.org" >> $TMP/txtTEMP$$
  553. echo >> $TMP/txtTEMP$$
  554.  
  555. dialog --backtitle "DOMAIN NAME ..." --inputbox "`cat $TMP/txtTEMP$$`" 11 74 2> $TMP/rspTEMP$$
  556.  
  557. if [ $? = 1 ]; then
  558. rm -f $TMP/*TEMP*
  559. clear 2>/dev/null || echo
  560. echo "PPP configuration cancelled."
  561. exit 
  562. fi 
  563.  
  564. DOMAINNAME="`cat $TMP/rspTEMP$$`"
  565.  
  566. echo "What is the IP address of your Internet provider's nameserver?" > $TMP/txtTEMP$$
  567. echo >> $TMP/txtTEMP$$
  568. echo "It's important that these IP numbers be correct." >> $TMP/txtTEMP$$
  569. echo "The IP numbers should not be: 0.0.0.0" >> $TMP/txtTEMP$$
  570. echo >> $TMP/txtTEMP$$
  571. echo "Note: Your service provider's technical support can provide you" >> $TMP/txtTEMP$$
  572. echo "with this information.   Example: 207.132.116.5" >> $TMP/txtTEMP$$
  573. echo >> $TMP/txtTEMP$$
  574.  
  575. dialog --backtitle "DNS IP ADDRESS ..." --inputbox "`cat $TMP/txtTEMP$$`" 14 74 2> $TMP/rspTEMP$$
  576.  
  577. if [ $? = 1 ]; then
  578. rm -f $TMP/*TEMP*
  579. clear 2>/dev/null || echo
  580. echo "PPP configuration cancelled."
  581. exit 
  582. fi 
  583.  
  584. DNSIP="`cat $TMP/rspTEMP$$`"
  585.  
  586. if [ ! -s $TMP/cb3TEMP$$ ]; then   
  587. echo "Does your service provider use PAP or CHAP?" > $TMP/txtTEMP$$
  588. echo "If you're presented with a Username: or Login: and Password:" >> $TMP/txtTEMP$$
  589. echo "prompt when you connect to your service provider, they're" >> $TMP/txtTEMP$$
  590. echo "'probably' not using PAP or CHAP, so you can answer SCRIPT." >> $TMP/txtTEMP$$
  591. echo "I said 'probably', the only way to know for sure is to ask you're" >> $TMP/txtTEMP$$
  592. echo "service provider, this could save you a lot of wasted time." >> $TMP/txtTEMP$$
  593.  
  594. dialog --backtitle "PAP, CHAP, or SCRIPT? ..." --menu "`cat $TMP/txtTEMP$$`" 16 72 4 \
  595. PAP  "AUTHENTICATION" \
  596. CHAP "AUTHENTICATION" \
  597. MS-CHAP-80 "is microsoft's version of CHAP." \
  598. SCRIPT     "Create Chat Script For Login." 2> $TMP/papTEMP
  599.  
  600. if [ $? = 1 ]; then
  601. rm -f $TMP/*TEMP*
  602. clear 2>/dev/null || echo
  603. echo "PPP configuration cancelled."
  604. exit 
  605. else
  606. PAP="`cat $TMP/papTEMP`"
  607. fi
  608. fi
  609.  
  610. RAS() {
  611. cat << EOF
  612. If your RAS server is not the 'domain controller' and is not a 
  613. 'stand-alone' server, then it must make a query to the domain 
  614. controller for your domain.
  615.  
  616. In other words, your account is not on the NT server you first 
  617. connect to, so it needs to know the name of the domain you have 
  618. your account on, so it can query that domain about you. 
  619.  
  620. If not sure chose Stand-alone, then try Queries if Stand-alone 
  621. doesn't work.
  622. EOF
  623. }
  624.  
  625. if [ "$PAP" = "MS-CHAP-80" ]; then   
  626. if [ ! -z "$DOMAINNAME" ]; then
  627. echo > $TMP/txtTEMP$$
  628. echo "You gave $DOMAINNAME for domain name, this will be the" >> $TMP/txtTEMP$$
  629. echo "NT server you connect to when you dial: $PHONENUM" >> $TMP/txtTEMP$$
  630. echo >> $TMP/txtTEMP$$
  631. else
  632. echo > $TMP/txtTEMP$$
  633. fi
  634. RAS >> $TMP/txtTEMP$$
  635.  
  636. dialog --title "MS-CHAP NT server, Stand-alone or ? ..." --menu "`cat $TMP/txtTEMP$$`" 22 72 2 \
  637. MS-CHAP-SERVER-1 "Stand-alone..." \
  638. MS-CHAP-SERVER-2 "Queries domain controller..." 2> $TMP/mschapTEMP
  639.  
  640. if [ $? = 1 ]; then
  641. rm -f $TMP/*TEMP*
  642. clear 2>/dev/null || echo
  643. echo "PPP configuration cancelled."
  644. exit 
  645. fi 
  646.  
  647. MSCHAP="`cat $TMP/mschapTEMP`"
  648.  
  649. if [ "$MSCHAP" = "MS-CHAP-SERVER-2" ]; then   
  650. echo "Put the name of the domain you have your account on." > $TMP/txtTEMP0
  651. echo "Example: fooboo" >> $TMP/txtTEMP0
  652. echo >> $TMP/txtTEMP0
  653.  
  654. dialog --backtitle "MS-CHAP QUERY DOMAIN? ..." --inputbox "`cat $TMP/txtTEMP0`" 9 64 2> $TMP/rspTEMP0
  655.  
  656. if [ $? = 1 ]; then
  657. rm -f $TMP/*TEMP*
  658. clear 2>/dev/null || echo
  659. echo "PPP configuration cancelled."
  660. exit 
  661. fi 
  662.  
  663. MSDOMAIN="`cat $TMP/rspTEMP0`"
  664.  
  665. if [ ! -s $TMP/rspTEMP0 ]; then   
  666. rm -f $TMP/*TEMP*
  667. clear 2>/dev/null || echo
  668. echo "PPP configuration cancelled."
  669. echo "No ms-chap query domain name given."
  670. exit
  671. fi 
  672. fi
  673. fi
  674.  
  675. if [ ! "$PAP" = "SCRIPT" ] && [ ! -s $TMP/cb3TEMP$$ ]; then   
  676. echo "Put your Login = Username in the box below." > $TMP/txtTEMP1
  677. echo >> $TMP/txtTEMP1
  678. echo "Sometimes they want your username or number followed" >> $TMP/txtTEMP1
  679. echo "by their @domain name like this below." >> $TMP/txtTEMP1
  680. echo "Example: jerry@foo.boo.com" >> $TMP/txtTEMP1
  681. echo "Example: 1234567@foo.boo.com" >> $TMP/txtTEMP1
  682. echo >> $TMP/txtTEMP1
  683. echo "Sometimes the username is two words." >> $TMP/txtTEMP1
  684. echo "Example: jerry donut" >> $TMP/txtTEMP1
  685. echo >> $TMP/txtTEMP1
  686. echo "Usally it's just your username like this below." >> $TMP/txtTEMP1
  687. echo "Example: jerry" >> $TMP/txtTEMP1
  688. echo >> $TMP/txtTEMP1
  689.  
  690. dialog --backtitle "PAP or CHAP LOGIN? ..." --inputbox "`cat $TMP/txtTEMP1`" 19 64 2> $TMP/rspTEMP1
  691.  
  692. if [ $? = 1 ]; then
  693. rm -f $TMP/*TEMP*
  694. clear 2>/dev/null || echo
  695. echo "PPP configuration cancelled."
  696. exit 
  697. fi
  698.  
  699. if [ ! -s $TMP/rspTEMP1 ]; then   
  700. rm -f $TMP/*TEMP*
  701. clear 2>/dev/null || echo
  702. echo "PPP configuration cancelled."
  703. echo "No username for pap, chap, or ms-chap given."
  704. exit
  705. fi 
  706. fi
  707.  
  708. if [ -s $TMP/rspTEMP1 ]; then 
  709. AUTH1="`cat $TMP/rspTEMP1`"
  710. echo "$AUTH1" > $TMP/txtTEMP2
  711. echo "What's the password for the username above?" >> $TMP/txtTEMP2
  712. echo "Example: Xpi9u87T" >> $TMP/txtTEMP2
  713. dialog --backtitle "PAP or CHAP PASSWORD? ..." --inputbox "`cat $TMP/txtTEMP2`" 10 64 2> $TMP/rspTEMP2
  714.  
  715. AUTH2="`cat $TMP/rspTEMP2`"
  716. END=""
  717.  
  718. elif [ ! -s $TMP/cb1TEMP$$ ] && [ "$PAP" = "SCRIPT" ]; then  
  719. END='""'
  720. echo "If you reached this part of the script, it should be because you" > $TMP/txtTEMP$$
  721. echo "skipped the PAP or CHAP? and CALLBACK? parts of this script." >> $TMP/txtTEMP$$
  722. echo "In other words, your service provider is not using PAP, CHAP, or" >> $TMP/txtTEMP$$
  723. echo "CALLBACK." >> $TMP/txtTEMP$$
  724. echo >> $TMP/txtTEMP$$
  725. echo "Now comes the tough part. :) I need to know what your" >> $TMP/txtTEMP$$
  726. echo "service provider prints to your screen when you dial in," >> $TMP/txtTEMP$$
  727. echo "and what you respond with." >> $TMP/txtTEMP$$
  728. echo >> $TMP/txtTEMP$$
  729. echo "Usally when you connect to your service provider you see a" >> $TMP/txtTEMP$$
  730. echo "Username: or Login: prompt, and you respond with your name." >> $TMP/txtTEMP$$
  731. echo "Then there's a Password: prompt and you respond with your" >> $TMP/txtTEMP$$
  732. echo "password." >> $TMP/txtTEMP$$
  733. echo >> $TMP/txtTEMP$$
  734. echo "If you're not sure if it's Login: or login:, just put ogin:" >> $TMP/txtTEMP$$
  735. echo "you don't have to spell the whole thing out, the end part of" >> $TMP/txtTEMP$$
  736. echo "what to wait for should be enough." >> $TMP/txtTEMP$$
  737. echo >> $TMP/txtTEMP$$
  738. echo 'If they put this for example "foobar fooboo ID:", you could just' >> $TMP/txtTEMP$$
  739. echo 'put ID: or you could spell the whole thing out & put "" around it.' >> $TMP/txtTEMP$$
  740. echo >> $TMP/txtTEMP$$
  741. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  742. echo "ID:" >> $TMP/txtTEMP$$
  743. echo "What text should I send?" >> $TMP/txtTEMP$$
  744. echo "jerry" >> $TMP/txtTEMP$$
  745. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  746. echo '"foobar fooboo ID:"' >> $TMP/txtTEMP$$
  747. echo "What text should I send?" >> $TMP/txtTEMP$$
  748. echo "jerry" >> $TMP/txtTEMP$$
  749. echo >> $TMP/txtTEMP$$
  750. echo "Sometimes you may want to wait for nothing, but send something." >> $TMP/txtTEMP$$
  751. echo >> $TMP/txtTEMP$$
  752. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  753. echo '""' >> $TMP/txtTEMP$$
  754. echo "What text should I send?" >> $TMP/txtTEMP$$
  755. echo "something" >> $TMP/txtTEMP$$
  756. echo >> $TMP/txtTEMP$$
  757. echo '"" = wait for nothing.' >> $TMP/txtTEMP$$
  758. echo >> $TMP/txtTEMP$$
  759. echo "If you don't want your password printed out put \q in front of it." >> $TMP/txtTEMP$$
  760. echo >> $TMP/txtTEMP$$
  761. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  762. echo "Password:" >> $TMP/txtTEMP$$
  763. echo "What text should I send?" >> $TMP/txtTEMP$$
  764. echo "\qsecret" >> $TMP/txtTEMP$$
  765. echo >> $TMP/txtTEMP$$
  766. echo "ogin: = Login:   name: = Username:   word: = Password:" >> $TMP/txtTEMP$$
  767. echo >> $TMP/txtTEMP$$
  768. echo "This below would end up looking like this in the /etc/ppp/pppscript" >> $TMP/txtTEMP$$
  769. echo "file created by pppsetup when you're done." >> $TMP/txtTEMP$$
  770. echo >> $TMP/txtTEMP$$
  771. echo "ogin: jerry" >> $TMP/txtTEMP$$
  772. echo "word: secret" >> $TMP/txtTEMP$$
  773. echo >> $TMP/txtTEMP$$
  774. echo "For example..." >> $TMP/txtTEMP$$
  775. echo >> $TMP/txtTEMP$$
  776. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  777. echo "ogin:" >> $TMP/txtTEMP$$
  778. echo "And what text should I send?" >> $TMP/txtTEMP$$
  779. echo "jerry" >> $TMP/txtTEMP$$
  780. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  781. echo "word:" >> $TMP/txtTEMP$$
  782. echo "And what text should I send?" >> $TMP/txtTEMP$$
  783. echo "secret" >> $TMP/txtTEMP$$
  784. echo "What text should I wait for?" >> $TMP/txtTEMP$$
  785. echo >> $TMP/txtTEMP$$
  786. echo "( End by pressing Enter on an empty = blank wait for? box. )" >> $TMP/txtTEMP$$
  787.  
  788. dialog --title "CHAT SCRIPT" --textbox "$TMP/txtTEMP$$" 22 72
  789.  
  790. MESSAGE=' '
  791. YOUSAY=' '
  792. while [ ! "$MESSAGE" = "" -a ! "$YOUSAY" = "" ]
  793. do
  794.  
  795. echo "     End by pressing Enter on a empty = blank box." > $TMP/txtTEMP$$
  796. echo "            What text should I wait for?" >> $TMP/txtTEMP$$
  797. dialog --backtitle "EXPECT ..." --inputbox "`cat $TMP/txtTEMP$$`" 9 60 2> $TMP/rspTEMP$$    
  798.  
  799. MESSAGE="`cat $TMP/rspTEMP$$`"
  800.  
  801. if [ -z "$MESSAGE" ]; then
  802. continue
  803. fi
  804.  
  805. dialog --backtitle "SEND ..." --inputbox "And what text should I send?" 8 60 2> $TMP/rspTEMP$$
  806.  
  807. if [ $? = 1 ]; then
  808. rm -f $TMP/*TEMP*
  809. clear 2>/dev/null || echo
  810. echo "PPP configuration cancelled."
  811. exit 
  812. fi
  813.  
  814. YOUSAY="`cat $TMP/rspTEMP$$`"
  815.  
  816. echo "$MESSAGE $YOUSAY" >> $TMP/sayTEMP1
  817.     
  818. if [ -z "$YOUSAY" ]; then
  819. clear 2>/dev/null || echo
  820. rm -f $TMP/*TEMP*
  821. echo "PPP configuration cancelled."
  822. echo "Nothing to send."
  823. exit 
  824. else    
  825. continue
  826. fi
  827. done
  828. fi
  829.  
  830. if [ ! -s $TMP/cb3TEMP$$ ]; then
  831. if [ -s $TMP/cb1TEMP$$ ] && [ ! -s $TMP/cb3TEMP$$ ] && [ "$PAP" = "SCRIPT" ]; then
  832. clear 2>/dev/null || echo
  833. rm -f $TMP/*TEMP*
  834. echo "PPP configuration cancelled."
  835. echo "You chose callback with PAP or CHAP, but answered SCRIPT to PAP or CHAP?."
  836. exit 
  837. elif [ ! -s $TMP/rspTEMP2 ] && [ -s $TMP/rspTEMP1 ]; then
  838. clear 2>/dev/null || echo
  839. rm -f $TMP/*TEMP*
  840. echo "PPP configuration cancelled."
  841. echo "No password for: $AUTH1"
  842. exit     
  843. elif [ ! -s $TMP/sayTEMP1 ] && [ ! -s $TMP/rspTEMP2 ]; then
  844. clear 2>/dev/null || echo
  845. rm -f $TMP/*TEMP*
  846. echo "PPP configuration cancelled."
  847. echo "Nothing to wait for."
  848. exit 
  849. fi
  850. fi
  851.  
  852. if dmesg 2>/dev/null | grep "PPP: version" >/dev/null 2>&1 ; then
  853. MSG1=YES
  854. fi
  855. if [ -s /lib/modules/`uname -r 2>/dev/null`/net/ppp.o ]; then
  856. MSG2=YES
  857. fi
  858.  
  859. if [ ! -s /etc/host.conf ]; then
  860. echo "order hosts,bind" > /etc/host.conf
  861. echo "multi on" >> /etc/host.conf
  862. fi
  863.  
  864. if [ ! -z $DOMAINNAME ]; then
  865. # backup file
  866. cp -a /etc/resolv.conf /etc/resolv.conf.$$ 2> /dev/null
  867. echo "search $DOMAINNAME" > /etc/resolv.conf
  868. else
  869. rm -f /etc/resolv.conf 2>/dev/null
  870. DOMAINNAME="unknown.com"
  871. fi
  872.  
  873. if [ -z $DNSIP ]; then
  874. echo "nameserver 207.132.116.5" >> /etc/resolv.conf
  875. else
  876. echo "nameserver $DNSIP" >> /etc/resolv.conf
  877. fi
  878.  
  879. if [ ! -s /etc/hosts ]; then
  880. # backup file
  881. cp -a /etc/hosts /etc/hosts.bak.$$ 2> /dev/null
  882. echo "127.0.0.1    localhost" > /etc/hosts
  883. if [ "$DOMAINNAME" = "unknown.com" ]; then
  884. echo "0.0.0.0     `hostname 2>/dev/null`.localnet `hostname 2>/dev/null`" >> /etc/hosts
  885. else
  886. echo "0.0.0.0     `hostname 2>/dev/null`.$DOMAINNAME `hostname 2>/dev/null`" >> /etc/hosts
  887. fi
  888. fi
  889.  
  890. if [ -x /usr/sbin/pppd ]; then
  891. PATH1="/usr/sbin/pppd"
  892. elif [ -x /usr/bin/pppd ]; then
  893. PATH1="/usr/bin/pppd"
  894. elif [ -x /usr/local/bin/pppd ]; then
  895. PATH1="/usr/local/bin/pppd"
  896. elif [ -x /bin/pppd ]; then
  897. PATH1="/bin/pppd"
  898. elif [ -x /sbin/pppd ]; then
  899. PATH1="/sbin/pppd"
  900. else
  901. PATH1="pppd"
  902. fi
  903.  
  904. #if [ "$PATH1" != "pppd" ]; then
  905. #chmod 4755 $PATH1 2>/dev/null
  906. #fi
  907.  
  908. if [ -x /usr/sbin/chat ]; then
  909. PATH2="/usr/sbin/chat"
  910. elif [ -x /usr/bin/chat ]; then
  911. PATH2="/usr/bin/chat"
  912. elif [ -x /usr/local/bin/chat ]; then
  913. PATH2="/usr/local/bin/chat"
  914. elif [ -x /bin/chat ]; then
  915. PATH2="/bin/chat"
  916. elif [ -x /sbin/chat ]; then
  917. PATH2="/sbin/chat"
  918. else
  919. PATH2="chat"
  920. fi
  921.  
  922. if [ ! -s $TMP/cb1TEMP$$ ]; then
  923. echo "TIMEOUT 60" > /etc/ppp/pppscript
  924. echo "ABORT ERROR" >> /etc/ppp/pppscript 
  925. echo "ABORT BUSY" >> /etc/ppp/pppscript 
  926. echo 'ABORT "NO CARRIER"' >> /etc/ppp/pppscript
  927. echo 'ABORT "NO DIALTONE"' >> /etc/ppp/pppscript
  928. if [ "$INIT" = "below" ]; then
  929. echo '"" "AT&FH0"' >> /etc/ppp/pppscript
  930. echo 'OK "'$PHONENUM'"' >> /etc/ppp/pppscript
  931. else
  932. echo '"" '$INIT'' >> /etc/ppp/pppscript
  933. echo '"'$PHONENUM'"' >> /etc/ppp/pppscript
  934. fi
  935. echo "TIMEOUT 75" >> /etc/ppp/pppscript
  936. echo 'CONNECT '$END'' >> /etc/ppp/pppscript
  937. chown root.root /etc/ppp/pppscript 2>/dev/null
  938. chmod 600 /etc/ppp/pppscript 2>/dev/null
  939. fi
  940.  
  941. if [ -s $TMP/sayTEMP1 ]; then
  942. cat $TMP/sayTEMP1 >> /etc/ppp/pppscript
  943. echo >> /etc/ppp/pppscript 
  944. else
  945. echo >> /etc/ppp/pppscript 
  946. fi
  947.  
  948. if [ -s /etc/ppp/ip-up ]; then
  949. mv /etc/ppp/ip-up /etc/ppp/ip-up.OLD
  950. fi
  951.  
  952. echo "#!/bin/sh" > /etc/ppp/ip-up
  953.  
  954. echo "#" >> /etc/ppp/ip-up
  955. echo "# This file /etc/ppp/ip-up is run by pppd when there's a" >> /etc/ppp/ip-up
  956. echo "# successful ppp connection." >> /etc/ppp/ip-up
  957. echo "#" >> /etc/ppp/ip-up
  958. echo "# Put any commands you want run after a successful connection" >> /etc/ppp/ip-up
  959. echo "# in this file." >> /etc/ppp/ip-up
  960. echo "#" >> /etc/ppp/ip-up
  961. echo "# Any commands you want printed to the screen should be directed" >> /etc/ppp/ip-up
  962. echo "# to: >/dev/tty0" >> /etc/ppp/ip-up
  963. echo "#" >> /etc/ppp/ip-up
  964. echo "# Other commands should not be directed to: >/dev/tty0" >> /etc/ppp/ip-up
  965. echo "#" >> /etc/ppp/ip-up
  966. echo "# The companion file is /etc/ppp/ip-down, it's run when the PPP" >> /etc/ppp/ip-up
  967. echo "# connection ends." >> /etc/ppp/ip-up
  968. echo "#" >> /etc/ppp/ip-up
  969. echo "# This file is created when you run pppsetup: `date 2>/dev/null`" >> /etc/ppp/ip-up
  970. echo "#" >> /etc/ppp/ip-up
  971. echo "# The environment is cleared before executing this script" >> /etc/ppp/ip-up
  972. echo "# so the path must be reset." >> /etc/ppp/ip-up
  973. echo "#" >> /etc/ppp/ip-up
  974. echo "PATH=/usr/bin:/usr/sbin:/usr/local/bin:/sbin:/bin" >> /etc/ppp/ip-up
  975. echo "export PATH" >> /etc/ppp/ip-up
  976.  
  977. echo >> /etc/ppp/ip-up
  978. echo "# This will print to the screen the local & remote IP address when you" >> /etc/ppp/ip-up
  979. echo '# make a successful ppp connection.  $4 = Local IP $5 = Remote IP' >> /etc/ppp/ip-up
  980. echo "#" >> /etc/ppp/ip-up
  981. echo "# The CARRIER speed at which you connected will be reported, if it's in" >> /etc/ppp/ip-up
  982. echo '# the /var/log/messages file.  You also need the programs "tail" "cut"' >> /etc/ppp/ip-up
  983. echo '# "tr" "grep" and "syslogd" running for this to work.' >> /etc/ppp/ip-up
  984. echo "# You may have to add S95=46 to your modem init string" >> /etc/ppp/ip-up
  985. echo "# to get your modem to report the DCE = CARRIER speed." >> /etc/ppp/ip-up
  986. echo "# Example: AT&FS95=46" >> /etc/ppp/ip-up
  987.  
  988. echo >> /etc/ppp/ip-up
  989. echo "if [ -s /var/log/messages ] && ( ps xc 2>/dev/null | grep -q syslogd 2>/dev/null ); then" >> /etc/ppp/ip-up
  990. echo 'S=`tail -n 30 /var/log/messages 2>/dev/null | grep "CARRIER[^)]" 2>/dev/null | tr -d "^M" 2>/dev/null | cut -d: -f4 2>/dev/null`' >> /etc/ppp/ip-up
  991. echo 'echo -n "$S" >/dev/tty0' >> /etc/ppp/ip-up
  992. echo 'echo " Local: $4 -> Remote: $5 $1" >/dev/tty0' >> /etc/ppp/ip-up
  993. echo "else" >> /etc/ppp/ip-up
  994. echo 'echo " Local: $4 -> Remote: $5 $1" >/dev/tty0' >> /etc/ppp/ip-up
  995. echo "fi" >> /etc/ppp/ip-up
  996.  
  997. echo >> /etc/ppp/ip-up
  998. echo "# If you want to ping the other end to keep the connection open." >> /etc/ppp/ip-up
  999. echo "# The output from ping will goto >/dev/null, you won't see it." >> /etc/ppp/ip-up
  1000. echo '# Ping -i 60 = send ping every 60 seconds to remote = $5.' >> /etc/ppp/ip-up
  1001.  
  1002. echo >> /etc/ppp/ip-up
  1003. echo '#(ping -i 60 $5 &) >/dev/null 2>&1' >> /etc/ppp/ip-up
  1004.  
  1005. echo >> /etc/ppp/ip-up
  1006. echo "# If you want sendmail to send any mail in /var/spool/mqueue when" >> /etc/ppp/ip-up
  1007. echo "# you connect, remove the # below." >> /etc/ppp/ip-up
  1008.  
  1009. echo >> /etc/ppp/ip-up
  1010. echo "#sendmail -q" >> /etc/ppp/ip-up
  1011.  
  1012. echo >> /etc/ppp/ip-up
  1013. echo "# If you want fetchmail to get your mail when you connect and check" >> /etc/ppp/ip-up
  1014. echo "# every 300 seconds = 5 minutes for mail, remove the # below." >> /etc/ppp/ip-up
  1015.  
  1016. echo >> /etc/ppp/ip-up
  1017. echo "#fetchmail -d 300" >> /etc/ppp/ip-up
  1018.  
  1019. echo >> /etc/ppp/ip-up
  1020. echo "# End..." >> /etc/ppp/ip-up
  1021.  
  1022. #chmod 4755 /etc/ppp/ip-up 2>/dev/null
  1023. chmod 755 /etc/ppp/ip-up 2>/dev/null
  1024.  
  1025. if [ -s /etc/ppp/ip-down ]; then
  1026. mv /etc/ppp/ip-down /etc/ppp/ip-down.OLD
  1027. fi
  1028.  
  1029. ipdown() {
  1030. cat <<EOF
  1031. #!/bin/sh
  1032. #
  1033. # This script is run by pppd after the PPP connection is ended.
  1034. #
  1035. # The companion file is /etc/ppp/ip-up, it's run when the PPP
  1036. # connection is started.
  1037. #
  1038. # This file is created when you run pppsetup: `date 2>/dev/null`
  1039. #
  1040. # The environment is cleared before executing this script
  1041. # so the path must be reset.
  1042. #
  1043. PATH=/usr/sbin:/sbin:/usr/bin:/usr/local/bin:/bin
  1044. export PATH
  1045.  
  1046. # Stop ping if you started it in /etc/ppp/ip-up.
  1047.  
  1048. #killall ping 2>/dev/null
  1049.  
  1050. # Stop the fetchmail daemon if you started it in /etc/ppp/ip-up
  1051. # with 'fetchmail -d 300'.
  1052.  
  1053. #fetchmail -q
  1054.  
  1055. # Send "ath" = hangup etc. to modem when ppp connection ends.
  1056. # You'll see the modem reponse OK and date in the /etc/ppp/modem.cua?, 
  1057. # modem.ttyS?, or modem.modem file.
  1058. # You need the 'modem-stats' program for this below to work.
  1059. # ftp://metalab.unc.edu/pub/apps/serialcomm/modem 
  1060. # modem-stats-1.0.1.src.elf.tar.gz
  1061. # Remove the ##### from the lines below.
  1062.  
  1063. EOF
  1064. }
  1065.  
  1066. ipdown > /etc/ppp/ip-down
  1067. #chmod 4755 /etc/ppp/ip-down 2>/dev/null
  1068. chmod 755 /etc/ppp/ip-down 2>/dev/null
  1069.  
  1070. echo "#sleep 2   # Make sure the modem is really down." >> /etc/ppp/ip-down
  1071. echo '#DEV=`echo $2 | sed -e "s./dev/.."`' >> /etc/ppp/ip-down
  1072. echo '#echo "--------------------------" >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
  1073. echo '#date                              >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
  1074. echo '#modem-stats -c "ath" $2           >> /etc/ppp/modem.$DEV' >> /etc/ppp/ip-down
  1075. echo >> /etc/ppp/ip-down
  1076. echo "# End..." >> /etc/ppp/ip-down
  1077.  
  1078. echo "#!/bin/bash" > /usr/sbin/ppp-go
  1079.  
  1080. echo >> /usr/sbin/ppp-go
  1081. echo "ifconnect() {" >> /usr/sbin/ppp-go
  1082. echo >> /usr/sbin/ppp-go
  1083. echo 'if ! ( ifconfig | grep "P-t-P" >/dev/null ); then' >> /usr/sbin/ppp-go 
  1084. echo 'echo "* NO! not PPP connected. *"' >> /usr/sbin/ppp-go
  1085. echo "echo" >> /usr/sbin/ppp-go
  1086. echo "else" >> /usr/sbin/ppp-go
  1087. echo "exit 0" >> /usr/sbin/ppp-go
  1088. echo "fi" >> /usr/sbin/ppp-go
  1089.  
  1090. echo >> /usr/sbin/ppp-go
  1091. echo "if [ -s /var/log/debug ] && ( ps xc 2>/dev/null | grep -q syslogd 2>/dev/null ); then" >> /usr/sbin/ppp-go
  1092. echo 'echo "Look at /var/log/messages and or debug for more info."' >> /usr/sbin/ppp-go
  1093. echo "echo" >> /usr/sbin/ppp-go
  1094. echo "else" >> /usr/sbin/ppp-go
  1095. echo "exit 0" >> /usr/sbin/ppp-go
  1096. echo "fi" >> /usr/sbin/ppp-go
  1097.  
  1098. echo >> /usr/sbin/ppp-go
  1099. echo 'echo "Do you want to see /var/log/messages & debug?"' >> /usr/sbin/ppp-go
  1100. echo 'echo "The PAGER less or more will be used: Q = Quit!"' >> /usr/sbin/ppp-go
  1101. echo 'echo "The last 30 lines of each file will be shown, there"' >> /usr/sbin/ppp-go
  1102. echo 'echo -n "may be some overlap from previous attempts: (N/y) : "' >> /usr/sbin/ppp-go
  1103. echo "read ans" >> /usr/sbin/ppp-go
  1104.  
  1105. echo >> /usr/sbin/ppp-go
  1106. echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
  1107. echo 'tail -n 30 /var/log/messages /var/log/debug 2>/dev/null | less -aCMrsi || more -ds || echo "No PAGER found, no more or less."' >> /usr/sbin/ppp-go
  1108. echo "grepauth" >> /usr/sbin/ppp-go
  1109. echo "else" >> /usr/sbin/ppp-go
  1110. echo "grepauth" >> /usr/sbin/ppp-go
  1111. echo "fi" >> /usr/sbin/ppp-go
  1112. echo "}" >> /usr/sbin/ppp-go
  1113.  
  1114. auth() {
  1115. cat <<EOF
  1116. grepauth() {
  1117.  
  1118. tail -n 30 /var/log/debug 2>/dev/null | grep -i -s "rcvd" > $TMP/grep.tmp
  1119.  
  1120. if ( grep -i -q "auth pap" $TMP/grep.tmp ); then
  1121. echo
  1122. echo "They seem to be requesting PAP = <auth pap> for authentication."
  1123. echo "I don't know if you're setup for 'PAP' or not."
  1124. echo "Did you answer 'PAP' when you ran pppsetup?"
  1125. echo
  1126. elif ( grep -E -i -q "auth chap msoft|auth chap 80" $TMP/grep.tmp ); then
  1127. echo
  1128. echo "They seem to be requesting MS-CHAP-80 = <auth chap 80> for authentication."
  1129. echo "I don't know if you're setup for 'MS-CHAP' or not."
  1130. echo "Did you answer 'MS-CHAP' when you ran pppsetup?"
  1131. echo
  1132. elif ( grep -i -q "auth chap" $TMP/grep.tmp ); then
  1133. echo "They seem to be requesting CHAP = <auth chap> for authentication."
  1134. echo "I don't know if you're setup for 'CHAP' or not."
  1135. echo "Did you answer 'CHAP' when you ran pppsetup?"
  1136. echo
  1137. else
  1138. rm -f $TMP/grep.tmp
  1139. exit 0
  1140. fi
  1141.  
  1142. if ( grep -i -q "callback" $TMP/grep.tmp ); then
  1143. echo "They seem to be requesting CALLBACK."
  1144. echo "I don't know if you're setup for 'callback' or not."
  1145. echo "Did you answer 'CALLBACK' when you ran pppsetup?"
  1146. echo
  1147. fi
  1148.  
  1149. rm -f $TMP/grep.tmp
  1150. }
  1151. EOF
  1152. }
  1153.  
  1154. echo >> /usr/sbin/ppp-go
  1155. auth >> /usr/sbin/ppp-go
  1156.  
  1157. echo >> /usr/sbin/ppp-go
  1158. echo 'if [ "$1" = "" ]; then' >> /usr/sbin/ppp-go
  1159. echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
  1160. echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go
  1161.  
  1162. if [ -s $TMP/cb1TEMP$$ ]; then
  1163. echo '('$PATH1' -detach connect "'$PATH2' -v -f /etc/ppp/callback" &) || exit 1' >> /usr/sbin/ppp-go
  1164. else
  1165. echo '('$PATH1' -detach connect "'$PATH2' -v -f /etc/ppp/pppscript" &) || exit 1' >> /usr/sbin/ppp-go
  1166. fi
  1167.  
  1168. echo "#read" >> /usr/sbin/ppp-go
  1169. echo "#ifconnect" >> /usr/sbin/ppp-go
  1170. echo "exit 0" >> /usr/sbin/ppp-go
  1171. echo "fi" >> /usr/sbin/ppp-go
  1172.  
  1173. echo >> /usr/sbin/ppp-go
  1174. echo 'if [ "$1" = "-q" ]; then' >> /usr/sbin/ppp-go
  1175. echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
  1176. echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go
  1177.  
  1178. if [ -s $TMP/cb1TEMP$$ ]; then
  1179. echo '('$PATH1' connect "'$PATH2' -v -f /etc/ppp/callback" 1> /dev/null 2> /dev/null ) || exit 1' >> /usr/sbin/ppp-go
  1180. else
  1181. echo '('$PATH1' connect "'$PATH2' -v -f /etc/ppp/pppscript" 1> /dev/null 2> /dev/null ) || exit 1' >> /usr/sbin/ppp-go
  1182. fi
  1183.  
  1184. echo "exit 0" >> /usr/sbin/ppp-go
  1185. echo "fi" >> /usr/sbin/ppp-go
  1186.  
  1187. echo >> /usr/sbin/ppp-go
  1188. echo 'if [ "$1" = "-d" ]; then' >> /usr/sbin/ppp-go
  1189. echo "killall -INT pppd 2>/dev/null" >> /usr/sbin/ppp-go
  1190. echo "rm -f /var/lock/LCK* /var/run/ppp*.pid" >> /usr/sbin/ppp-go
  1191. echo '('$PATH1' file "/etc/ppp/options.demand" &) || exit 1' >> /usr/sbin/ppp-go
  1192. echo 'echo "Demand Dialing Started."' >> /usr/sbin/ppp-go
  1193. echo "exit 0" >> /usr/sbin/ppp-go
  1194. echo "fi" >> /usr/sbin/ppp-go
  1195.  
  1196. echo >> /usr/sbin/ppp-go
  1197. echo 'if [ "$1" = "-h" ]; then' >> /usr/sbin/ppp-go
  1198. echo 'echo "USAGE: ppp-go    <Make PPP connection, print messages to screen.>"' >> /usr/sbin/ppp-go
  1199. echo 'echo "USAGE: ppp-go -q <Make PPP connection, do not print messages to screen.>"' >> /usr/sbin/ppp-go
  1200. echo 'echo "USAGE: ppp-go -r <Remove contents of /var/log/messages & debug files.>"' >> /usr/sbin/ppp-go
  1201. echo 'echo "USAGE: ppp-go -d <Put pppd in demand dialing mode.>"' >> /usr/sbin/ppp-go
  1202. echo 'echo "USAGE: ppp-go -h <Help>"' >> /usr/sbin/ppp-go
  1203. echo "exit 0" >> /usr/sbin/ppp-go
  1204. echo "fi" >> /usr/sbin/ppp-go
  1205.  
  1206. echo >> /usr/sbin/ppp-go
  1207. echo 'if [ "$1" = "-r" ]; then' >> /usr/sbin/ppp-go
  1208. echo 'echo -n "Remove contents of /var/log/messages file? (N/y) : "' >> /usr/sbin/ppp-go
  1209. echo "read ans" >> /usr/sbin/ppp-go
  1210. echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
  1211. echo "cat /dev/null >/var/log/messages" >> /usr/sbin/ppp-go
  1212. echo 'echo "Contents of /var/log/messages file removed."' >> /usr/sbin/ppp-go
  1213. echo "else" >> /usr/sbin/ppp-go
  1214. echo 'echo "Cancelled."' >> /usr/sbin/ppp-go
  1215. echo "fi" >> /usr/sbin/ppp-go
  1216. echo 'echo -n "Remove contents of /var/log/debug file? (N/y) : "' >> /usr/sbin/ppp-go
  1217. echo "read ans" >> /usr/sbin/ppp-go
  1218. echo 'if [ "$ans" = "y" -o "$ans" = "Y" ]; then' >> /usr/sbin/ppp-go
  1219. echo "cat /dev/null >/var/log/debug" >> /usr/sbin/ppp-go
  1220. echo 'echo "Contents of /var/log/debug file removed."' >> /usr/sbin/ppp-go
  1221. echo "exit 0" >> /usr/sbin/ppp-go
  1222. echo "else" >> /usr/sbin/ppp-go
  1223. echo 'echo "Cancelled."' >> /usr/sbin/ppp-go
  1224. echo "exit 0" >> /usr/sbin/ppp-go
  1225. echo "fi" >> /usr/sbin/ppp-go
  1226. echo "fi" >> /usr/sbin/ppp-go
  1227.  
  1228. echo >> /usr/sbin/ppp-go
  1229. echo 'echo "USAGE: ppp-go -h <Help>"' >> /usr/sbin/ppp-go
  1230. echo "exit 1" >> /usr/sbin/ppp-go
  1231.  
  1232. #chmod 4755 /usr/sbin/ppp-go 2>/dev/null 
  1233. chmod 755 /usr/sbin/ppp-go 2>/dev/null 
  1234.     
  1235. cat << EOF > /etc/ppp/options
  1236. # General configuration options for PPPD:
  1237. lock
  1238. defaultroute
  1239. noipdefault
  1240. modem
  1241. /dev/$MODEM
  1242. $BAUDRATE
  1243. crtscts
  1244. # Uncomment the line below for more verbose error reporting:
  1245. #debug
  1246. # If you have a default route already, pppd may require the other side
  1247. # to authenticate itself, which most ISPs will not do.  To work around this,
  1248. # uncomment the line below.  Note that this may have negative side effects
  1249. # on system security if you allow PPP dialins.  See the docs in /usr/doc/ppp*
  1250. # for more information.
  1251. #noauth
  1252. passive
  1253. asyncmap 0
  1254. EOF
  1255.  
  1256. if [ ! -z "$CBPN" ]; then
  1257. echo 'callback "'$CBPN'"' >> /etc/ppp/options
  1258. fi
  1259.   
  1260. if  [ "$MSCHAP" = "MS-CHAP-SERVER-2" ] && [ -s $TMP/rspTEMP2 ]; then
  1261. echo 'name "'$MSDOMAIN\\\\$AUTH1'"' >> /etc/ppp/options
  1262. elif [ -s $TMP/rspTEMP2 ]; then
  1263. echo 'name "'$AUTH1'"' >> /etc/ppp/options
  1264. fi
  1265.  
  1266. if [ ! -z $DOMAINNAME ] && [ "$PAP" = "MS-CHAP-80" ]; then        
  1267. echo 'remotename "'$DOMAINNAME'"' >> /etc/ppp/options
  1268. elif [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then        
  1269. echo 'remotename "unknown.com"' >> /etc/ppp/options
  1270. fi
  1271.  
  1272. chown root.root /etc/ppp/options 2>/dev/null
  1273. chmod 600 /etc/ppp/options 2>/dev/null
  1274.  
  1275. if [ "$PAP" = "PAP" ]; then
  1276. echo "# PAP authentication file: /etc/ppp/pap-secrets" > /etc/ppp/pap-secrets
  1277. echo "# This file should have a permission of 600." >> /etc/ppp/pap-secrets
  1278. echo "# ~# chmod 600 /etc/ppp/pap-secrets" >> /etc/ppp/pap-secrets
  1279. echo "# Username      Server      Password      IP addresses" >> /etc/ppp/pap-secrets
  1280. echo '"'$AUTH1'"   *   "'$AUTH2'"' >> /etc/ppp/pap-secrets
  1281.  
  1282. chown root.root /etc/ppp/pap-secrets 2>/dev/null
  1283. chmod 600 /etc/ppp/pap-secrets 2>/dev/null
  1284.         
  1285. elif [ "$PAP" = "CHAP" ]; then
  1286. echo "# CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
  1287. echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
  1288. echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
  1289. echo "# Username      Server      Password      IP addresses" >> /etc/ppp/chap-secrets
  1290. echo '"'$AUTH1'"   *   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1291. echo '*   "'$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1292.  
  1293. chown root.root /etc/ppp/chap-secrets 2>/dev/null
  1294. chmod 600 /etc/ppp/chap-secrets 2>/dev/null
  1295.  
  1296. elif [ "$PAP" = "MS-CHAP-80" ] && [ "$MSCHAP" = "MS-CHAP-SERVER-2" ]; then
  1297. echo "# MS-CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
  1298. echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
  1299. echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
  1300. echo "# Username      RemoteHost      Password" >> /etc/ppp/chap-secrets
  1301. echo '"'$MSDOMAIN\\\\$AUTH1'"   "'$DOMAINNAME'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1302. echo '"'$DOMAINNAME'"   "'$MSDOMAIN\\\\$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1303.  
  1304. chown root.root /etc/ppp/chap-secrets 2>/dev/null
  1305. chmod 600 /etc/ppp/chap-secrets 2>/dev/null
  1306.  
  1307. elif [ "$PAP" = "MS-CHAP-80" ]; then
  1308. echo "# MS-CHAP authentication file: /etc/ppp/chap-secrets" > /etc/ppp/chap-secrets
  1309. echo "# This file should have a permission of 600." >> /etc/ppp/chap-secrets
  1310. echo "# ~# chmod 600 /etc/ppp/chap-secrets" >> /etc/ppp/chap-secrets
  1311. echo "# Username      RemoteHost      Password" >> /etc/ppp/chap-secrets
  1312. echo '"'$AUTH1'"   "'$DOMAINNAME'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1313. echo '"'$DOMAINNAME'"   "'$AUTH1'"   "'$AUTH2'"' >> /etc/ppp/chap-secrets
  1314.  
  1315. chown root.root /etc/ppp/chap-secrets 2>/dev/null
  1316. chmod 600 /etc/ppp/chap-secrets 2>/dev/null
  1317. fi
  1318.  
  1319. cp /etc/ppp/options /etc/ppp/options.demand
  1320.  
  1321. echo "ipcp-accept-local" >> /etc/ppp/options.demand
  1322. echo "ipcp-accept-remote" >> /etc/ppp/options.demand
  1323. echo "0.0.0.0:10.10.10.10" >> /etc/ppp/options.demand
  1324. echo "demand" >> /etc/ppp/options.demand
  1325.  
  1326. if [ -s $TMP/cb1TEMP$$ ]; then
  1327. echo 'connect "'$PATH2' -v -f /etc/ppp/callback"' >> /etc/ppp/options.demand
  1328. else
  1329. echo 'connect "'$PATH2' -v -f /etc/ppp/pppscript"' >> /etc/ppp/options.demand
  1330. fi
  1331.  
  1332. chown root.root /etc/ppp/options.demand 2>/dev/null
  1333. chmod 600 /etc/ppp/options.demand 2>/dev/null
  1334.  
  1335. if [ -f $HOME/.ppprc ]; then
  1336. mv $HOME/.ppprc $HOME/.ppprc.off
  1337. PPPRC="YES"
  1338. fi
  1339.  
  1340. demand() {
  1341.  cat <<EOF
  1342. PPP-2.3.0 and later has a demand dialing option, you can use it this way,
  1343. the options file for demand dialing will be /etc/ppp/options.demand.
  1344.  
  1345. Start ppp-go -d, pppd will just stay in the background until you try to 
  1346. connect to some site, then pppd will dial your service provider and make 
  1347. the ppp connection.
  1348.  
  1349. ~# ppp-go -d        <-Start pppd this way for demand dialing.)
  1350.  #                  <-It should drop you back to #.)
  1351.            
  1352. ~# ftp ftp.funet.fi               <-Pppd will start dialing.)             
  1353.  # lynx http://www.foo.com        <-Pppd will start dialing etc.)
  1354.  # ppp-off -d       <-To end and restart pppd in demand dialing mode.)
  1355.  # ppp-off                        <-To end the ppp connection.)
  1356.  
  1357. End...
  1358. =========================================================================
  1359. EOF
  1360. }
  1361.  
  1362. other() {
  1363.  cat <<EOF
  1364. These are some other ways to make a PPP connection.
  1365.  
  1366. The best way to make a PPP connection is to create a chat script, if
  1367. you're having trouble with the chat script you can use these methods
  1368. below to make the PPP connection.
  1369.  
  1370. You can also use these methods below to see what's going on when you
  1371. connect to your service provider, i.e. what do they require, do they
  1372. present you with a Login: or Username: and Password: prompt etc.
  1373.  
  1374. What steps do you have to go through before they start PPP at there
  1375. end?
  1376.  
  1377. First make sure the IP address of your service providers nameserver  
  1378. is in the /etc/resolv.conf file.
  1379.  
  1380. nameserver 205.117.312.56   <-For example.)
  1381.  
  1382. =========================================================================
  1383. Using 'dip' to make the PPP connection.
  1384. =========================================================================
  1385.  
  1386. ~# dip -tv
  1387. Host name lookup failure
  1388.  
  1389. If you get the above messgae when you start 'dip', it's because you
  1390. don't have your hostname in the /etc/hosts file.
  1391.  
  1392. ~# hostname
  1393. foobar
  1394.  
  1395. If your hostname were 'foobar' you should put it in the /etc/hosts file.
  1396.  
  1397. 127.0.0.1   localhost
  1398. 0.0.0.0     foobar.localnet foobar
  1399.  
  1400. ~# dip -tv
  1401. dip> port /dev/ttyS1
  1402. can't open - problems with locking ttyS1
  1403.  
  1404. If you get the above message after "port /dev/modem", it means you have a
  1405. lock file in /var/lock/LCK..ttyS1, remove the lock file and kill dip.
  1406.  
  1407. ~# rm /var/lock/LCK*
  1408.  # killall -9 dip
  1409.  
  1410. ~# dip -tv
  1411.  
  1412. dip> port /dev/ttyS1    <-Where's the modem? ttyS0 = com1 ttyS1 = com2 etc.)
  1413. dip> speed 115200      <-Modem speed: 19200 38400 57600
  1414. dip> term
  1415.  
  1416. at&fw2                 <-Modem init string.)
  1417. atdt1234567            <-Replace 1234567 with the phone number.)
  1418.  
  1419. Usally you give your username and password then ppp is started, if
  1420. they use PAP or CHAP you probably won't be asked for a username and
  1421. password, they will just say that PPP has been started or nothing.
  1422.  
  1423. Press Ctrl ] to exit dip term mode when PPP is started at their end.
  1424.  
  1425. dip> default              <-Use default route.)
  1426. dip> mode ppp             <-Start PPP at your end.)
  1427.  
  1428. ~# ping metalab.unc.edu   <-To see if you're connected.)
  1429.  
  1430. ~# dip -k                 <-To kill dip and the PPP connection.)
  1431.  
  1432. =========================================================================
  1433. Using 'minicom' to make the PPP connection.
  1434. =========================================================================
  1435.  
  1436. Keep the /etc/ppp/options file that was created by pppsetup, it should 
  1437. have at least these options in it.
  1438.  
  1439. lock
  1440. defaultroute
  1441. noipdefault
  1442. /dev/ttyS1         <- ttyS0 = com1 ttyS1 = com2 ttyS2 = com3 ttyS3 = com4           
  1443. 57600
  1444. modem
  1445. crtscts
  1446. debug
  1447. asyncmap 0
  1448.  
  1449. ~# minicom -m -s
  1450.  
  1451. at&fw2
  1452. atdt1234567
  1453.  
  1454. Press Alt Q to exit minicom without reset after PPP is started at 
  1455. the other end.
  1456.  
  1457. ~# pppd                <-Start PPP at your end.)
  1458.  
  1459. ~# ppp-off             <-To end the PPP connection.)
  1460.  # killall -INT pppd   <-If you don't have 'ppp-off' end it this way.)
  1461.  
  1462. End...
  1463. =========================================================================
  1464. EOF
  1465. }
  1466.  
  1467. echo "=========================================================================" > /etc/ppp/pppsetup.txt
  1468. cat $TMP/txtTEMP01 >> /etc/ppp/pppsetup.txt
  1469.  
  1470. echo "=========================================================================" > $TMP/txtTEMP$$
  1471. echo "These are your PPP configuration files and instructions..." >> $TMP/txtTEMP$$
  1472. echo "=========================================================================" >> $TMP/txtTEMP$$
  1473. echo >> $TMP/txtTEMP$$
  1474.  
  1475. if [ ! -s $TMP/cb1TEMP$$ ] && [ ! -s $TMP/sayTEMP1 ]; then
  1476. echo "# This is your /etc/ppp/pppscript." >> $TMP/txtTEMP$$
  1477. echo >> $TMP/txtTEMP$$
  1478. cat /etc/ppp/pppscript >> $TMP/txtTEMP$$
  1479. elif [ ! -s $TMP/cb1TEMP$$ ] && [ -s $TMP/sayTEMP1 ]; then
  1480. echo "# This is your /etc/ppp/pppscript." >> $TMP/txtTEMP$$
  1481. echo >> $TMP/txtTEMP$$
  1482. echo "Look at /etc/ppp/pppscript." >> $TMP/txtTEMP$$
  1483. echo >> $TMP/txtTEMP$$
  1484. fi
  1485.  
  1486. if [ -s $TMP/cb1TEMP$$ ]; then
  1487. echo "# This is your /etc/ppp/callback script." >> $TMP/txtTEMP$$
  1488. echo >> $TMP/txtTEMP$$
  1489. echo "Look at /etc/ppp/callback." >> $TMP/txtTEMP$$
  1490. echo >> $TMP/txtTEMP$$
  1491. fi
  1492.  
  1493. echo "# This is your /etc/ppp/options file." >> $TMP/txtTEMP$$
  1494. echo >> $TMP/txtTEMP$$
  1495. cat /etc/ppp/options >> $TMP/txtTEMP$$
  1496.  
  1497. if [ "$MODERROR" = "YES" ]; then
  1498. echo >> $TMP/txtTEMP$$
  1499. echo "WARNING: I could not find the modem device: '/dev/$MODEM'" >> $TMP/txtTEMP$$
  1500. echo "ttyS0 = com1 ttyS1 = com2 ttyS2 = com3  ttyS3 = com4" >> $TMP/txtTEMP$$
  1501. echo "# MAKEDEV $MODEM   # /dev/MAKEDEV $MODEM" >> $TMP/txtTEMP$$
  1502. fi
  1503.  
  1504. if [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then        
  1505. echo >> $TMP/txtTEMP$$
  1506. echo "The remotename option is required for microsoft's ms-chap-80." >> $TMP/txtTEMP$$
  1507. echo "You didn't give a DOMAIN NAME so i put unknown.com, you should" >> $TMP/txtTEMP$$
  1508. echo "change that to your service providers domain name." >> $TMP/txtTEMP$$
  1509. fi
  1510.  
  1511. if [ ! "$MODERROR" = "YES" ]; then
  1512. echo >> $TMP/txtTEMP$$
  1513. echo "I created the symbolic link: /dev/modem -> /dev/$MODEM" >> $TMP/txtTEMP$$
  1514. fi
  1515.  
  1516. echo >> $TMP/txtTEMP$$
  1517. echo "# This is your /etc/ppp/options.demand dialing file." >> $TMP/txtTEMP$$
  1518. echo >> $TMP/txtTEMP$$
  1519. cat /etc/ppp/options.demand >> $TMP/txtTEMP$$
  1520.  
  1521. echo >> $TMP/txtTEMP$$
  1522. echo "If you have a ethernet connection you should change the local:remote" >> $TMP/txtTEMP$$
  1523. echo "IP addresses in the options.demand file, to your actual local and" >> $TMP/txtTEMP$$
  1524. echo "remote address.  Example: 215.346.117.89:312.217.187.96" >> $TMP/txtTEMP$$
  1525.  
  1526. echo >> $TMP/txtTEMP$$
  1527. echo "# This in your /etc/resolv.conf file." >> $TMP/txtTEMP$$
  1528. echo >> $TMP/txtTEMP$$
  1529. cat /etc/resolv.conf >> $TMP/txtTEMP$$
  1530.  
  1531. echo >> $TMP/txtTEMP$$
  1532. if [ -z $DNSIP ]; then
  1533. echo "207.132.116.5   <-IMPORTANT: This should be the IP address of" >> $TMP/txtTEMP$$
  1534. echo "                             your service providers nameserver." >> $TMP/txtTEMP$$
  1535. else
  1536. echo "$DNSIP   <-IMPORTANT: This should be the IP address of" >> $TMP/txtTEMP$$
  1537. echo "                    your service providers nameserver." >> $TMP/txtTEMP$$
  1538. fi
  1539.  
  1540. if [ -z $DNSIP ]; then
  1541. echo >> $TMP/txtTEMP$$
  1542. echo "WARNING: You didn't give a IP address for your internet service" >> $TMP/txtTEMP$$
  1543. echo "providers nameserver, i put '207.132.116.5' but this may not work." >> $TMP/txtTEMP$$
  1544. fi
  1545.  
  1546. if [ "$PAP" = "CHAP" ] || [ "$PAP" = "MS-CHAP-80" ]; then
  1547. echo >> $TMP/txtTEMP$$
  1548. echo "# This is your /etc/ppp/chap-secrets file." >> $TMP/txtTEMP$$
  1549. echo >> $TMP/txtTEMP$$
  1550. echo "Look at /etc/ppp/chap-secrets." >> $TMP/txtTEMP$$
  1551. fi
  1552.  
  1553. if [ "$DOMAINNAME" = "unknown.com" ] && [ "$PAP" = "MS-CHAP-80" ]; then
  1554. echo >> $TMP/txtTEMP$$
  1555. echo "You didn't give a DOMAIN NAME that's why i put unknown.com in" >> $TMP/txtTEMP$$
  1556. echo "the /etc/ppp/chap-secrets file." >> $TMP/txtTEMP$$
  1557. echo "You should change that to your service providers domain name." >> $TMP/txtTEMP$$
  1558. fi
  1559.  
  1560. if [ "$PAP" = "PAP" ]; then
  1561. echo >> $TMP/txtTEMP$$
  1562. echo "# This is your /etc/ppp/pap-secrets file." >> $TMP/txtTEMP$$
  1563. echo >> $TMP/txtTEMP$$
  1564. echo "Look at /etc/ppp/pap-secrets." >> $TMP/txtTEMP$$
  1565. fi
  1566.  
  1567. if [ "$PATH1" = "pppd" ]; then
  1568. echo >> $TMP/txtTEMP$$
  1569. echo "ATENTION: I couldn't find <pppd> on your system." >> $TMP/txtTEMP$$
  1570. echo "You need <pppd> on your system to make the PPP connection." >> $TMP/txtTEMP$$
  1571. fi
  1572.  
  1573. if [ "$PATH2" = "chat" ]; then
  1574. echo >> $TMP/txtTEMP$$
  1575. echo "ATENTION: I couldn't find <chat> on your system." >> $TMP/txtTEMP$$
  1576. echo "You need <chat> on your system to make the PPP connection." >> $TMP/txtTEMP$$
  1577. fi
  1578.  
  1579. if [ ! "$MSG1" = "YES" ] && [ ! "$MSG2" = "YES" ]; then
  1580. echo >> $TMP/txtTEMP$$
  1581. echo "ATENTION: I couldn't find 'PPP' in the kernel or as a module." >> $TMP/txtTEMP$$
  1582. echo "You'll need 'PPP' in the kernel or as a module to make a PPP connection." >> $TMP/txtTEMP$$
  1583. fi
  1584.  
  1585. if [ "$PPPRC" = "YES" ]; then
  1586. echo >> $TMP/txtTEMP$$
  1587. echo "ATENTION: I found a $HOME/.ppprc file and moved it to" >> $TMP/txtTEMP$$
  1588. echo ".ppprc.off, it might interfere with the PPP connection." >> $TMP/txtTEMP$$
  1589. fi
  1590.  
  1591. echo >> $TMP/txtTEMP$$
  1592. echo "Does everything look correct? if not, run 'pppsetup' again..." >> $TMP/txtTEMP$$
  1593.  
  1594. echo >> $TMP/txtTEMP$$
  1595. echo "=========================================================================" >> $TMP/txtTEMP$$
  1596. echo "To connect to your service provider." >> $TMP/txtTEMP$$
  1597. echo "=========================================================================" >> $TMP/txtTEMP$$
  1598. echo >> $TMP/txtTEMP$$
  1599. echo "~# ppp-go      <-Make PPP connection.)" >> $TMP/txtTEMP$$
  1600.  
  1601. echo >> $TMP/txtTEMP$$
  1602. echo "You'll hear and see the modem dialing then once connected," >> $TMP/txtTEMP$$
  1603. echo "logging you in Username: or Login: and Password: etc." >> $TMP/txtTEMP$$
  1604.  
  1605. echo >> $TMP/txtTEMP$$
  1606. echo "You won't see a Username or Login: and Password: prompt" >> $TMP/txtTEMP$$
  1607. echo "if they're using PAP or CHAP to authenticate you." >> $TMP/txtTEMP$$
  1608.  
  1609. echo >> $TMP/txtTEMP$$
  1610. echo "If they use PAP or CHAP you'll just see CONNECT -- got it." >> $TMP/txtTEMP$$
  1611.  
  1612. echo >> $TMP/txtTEMP$$
  1613. echo "If the connection was successful you'll see the Local IP and" >> $TMP/txtTEMP$$
  1614. echo "Remote IP address printed to the screen, you can press [Enter]." >> $TMP/txtTEMP$$
  1615.  
  1616. echo >> $TMP/txtTEMP$$
  1617. echo "If you run ppp-go in X windows you probably won't see a Local" >> $TMP/txtTEMP$$
  1618. echo "and Remote IP address printed to the screen, you'll just see" >> $TMP/txtTEMP$$
  1619. echo "the connection process come to a end, wait a few seconds and" >> $TMP/txtTEMP$$
  1620. echo "press [Enter] at that point." >> $TMP/txtTEMP$$
  1621.  
  1622. echo >> $TMP/txtTEMP$$
  1623. echo "If you don't connect for whatever reason e.g. Failed No" >> $TMP/txtTEMP$$ 
  1624. echo "Dialtone, Busy, No Carrier, Whatever, Exit, just press" >> $TMP/txtTEMP$$ 
  1625. echo "[Enter] at that point." >> $TMP/txtTEMP$$
  1626.  
  1627. echo >> $TMP/txtTEMP$$
  1628. echo "if you have syslogd running, you can see the output messages" >> $TMP/txtTEMP$$ 
  1629. echo "from pppd and chat in the /var/log/messages and or debug file." >> $TMP/txtTEMP$$ 
  1630.  
  1631. echo >> $TMP/txtTEMP$$
  1632. echo "Sample /var/log/messages file." >> $TMP/txtTEMP$$    
  1633. echo >> $TMP/txtTEMP$$
  1634. echo "`hostname 2>/dev/null` pppd[562]: Serial connection established." >> $TMP/txtTEMP$$    
  1635. echo "`hostname 2>/dev/null` pppd[562]: Using interface ppp0" >> $TMP/txtTEMP$$              
  1636. echo "`hostname 2>/dev/null` pppd[562]: Connect: ppp0 <--> /dev/modem" >> $TMP/txtTEMP$$     
  1637. echo "`hostname 2>/dev/null` pppd[562]: local IP address 215.87.78.18" >> $TMP/txtTEMP$$      
  1638. echo "`hostname 2>/dev/null` pppd[562]: remote IP address 205.94.97.35" >> $TMP/txtTEMP$$     
  1639.  
  1640. echo >> $TMP/txtTEMP$$
  1641. echo "You don't have a successful PPP connection until you" >> $TMP/txtTEMP$$ 
  1642. echo "receive a local & remote IP address like above." >> $TMP/txtTEMP$$
  1643.  
  1644. echo >> $TMP/txtTEMP$$
  1645. echo "If you have the X window system, you could connect in a Xterm." >> $TMP/txtTEMP$$
  1646. echo >> $TMP/txtTEMP$$
  1647. echo "`hostname 2>/dev/null` # startx" >> $TMP/txtTEMP$$
  1648. echo "`hostname 2>/dev/null` # ppp-go" >> $TMP/txtTEMP$$
  1649. echo "`hostname 2>/dev/null` # netscape mosaic etc." >> $TMP/txtTEMP$$
  1650.  
  1651. echo >> $TMP/txtTEMP$$
  1652. echo "~# ppp-off     <-To end the ppp connection.)" >> $TMP/txtTEMP$$
  1653.  
  1654. echo >> $TMP/txtTEMP$$
  1655. echo "~# ppp-go -h   <-For help.)" >> $TMP/txtTEMP$$
  1656.  
  1657. echo >> $TMP/txtTEMP$$
  1658. echo 'There is no support in linux for "WinModems", if you have a' >> $TMP/txtTEMP$$
  1659. echo "WinModem you will not be able to use it in linux." >> $TMP/txtTEMP$$ 
  1660. echo >> $TMP/txtTEMP$$
  1661. echo "There is support for plug n play modems, if you have a pnp" >> $TMP/txtTEMP$$
  1662. echo 'modem you may need "isapnptools" to get it recognized.' >> $TMP/txtTEMP$$
  1663.  
  1664. echo >> $TMP/txtTEMP$$
  1665. echo "=========================================================================" >> $TMP/txtTEMP$$
  1666. if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
  1667. echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" >> $TMP/txtTEMP$$
  1668. fi
  1669. echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" >> $TMP/txtTEMP$$
  1670. echo "=========================================================================" >> $TMP/txtTEMP$$
  1671.  
  1672. echo >> $TMP/txtTEMP$$
  1673. echo "Done... You can exit now..." >> $TMP/txtTEMP$$
  1674. echo >> $TMP/txtTEMP$$
  1675. echo "End..." >> $TMP/txtTEMP$$
  1676. echo "=========================================================================" >> $TMP/txtTEMP$$
  1677.  
  1678. dialog --title "DONE" --clear --textbox "$TMP/txtTEMP$$" 22 78    
  1679.             
  1680. clear 2>/dev/null || echo
  1681.  
  1682. cat $TMP/txtTEMP$$ >> /etc/ppp/pppsetup.txt
  1683. chmod 600 /etc/ppp/pppsetup.txt 2>/dev/null 
  1684.  
  1685. if [ ! -s /etc/syslog.conf ]; then
  1686. echo "# Log info & debug messages to these files." > /etc/syslog.conf
  1687. echo >> /etc/syslog.conf
  1688. echo "*.=debug                        /var/log/debug" >> /etc/syslog.conf
  1689. echo "*.=info;*.=notice                /var/log/messages" >> /etc/syslog.conf
  1690.  
  1691. demand >> /etc/ppp/pppsetup.txt
  1692. other >> /etc/ppp/pppsetup.txt
  1693. rm -f $TMP/*TEMP* 2>/dev/null
  1694.  
  1695. killall -9 syslogd 2>/dev/null 
  1696. syslogd & 2>/dev/null 
  1697. echo
  1698. echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" 
  1699. if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
  1700. echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" 
  1701. fi
  1702. echo
  1703. exit 
  1704.  
  1705. else
  1706. demand >> /etc/ppp/pppsetup.txt
  1707. other >> /etc/ppp/pppsetup.txt
  1708. rm -f $TMP/*TEMP* 2>/dev/null
  1709. echo
  1710. echo "#### A copy of this text can be found in: /etc/ppp/pppsetup.txt ####" 
  1711. if [ -s /usr/doc/pppsetup/pppsetup-$VERSION.README ]; then
  1712. echo "#### Look at the /usr/doc/pppsetup/pppsetup-$VERSION.README. ####" 
  1713. fi
  1714. echo
  1715. exit 
  1716. fi
  1717.  
  1718.