LinuxSir.cn,穿越时空的Linuxsir!

 找回密码
 注册
搜索
热搜: shell linux mysql
查看: 605|回复: 0

FreeBSD设置PPP, PPPoE, 以太网的配置脚本,邀请各位同好共同改进

[复制链接]
发表于 2005-6-6 23:54:31 | 显示全部楼层 |阅读模式
  1. #!/bin/sh
  2. #
  3. # Copyright 2005 RelaxBSD All rights reserved.
  4. #
  5. # Redistribution and use in source and binary forms, with or without
  6. # modification, are permitted provided that the following conditions are met:
  7. #
  8. #  1.Redistributions of source code must retain the above copyright notice,
  9. #    this list of conditions and the following disclaimer.
  10. #  2.Redistributions in binary form must reproduce the above copyright notice,
  11. #    this list of conditions and the following disclaimer in the documentation
  12. #    and/or other materials provided with the distribution.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY RelaxBSD ``AS IS'' AND ANY EXPRESS OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  17. # EVENT SHALL THE FREEBSD PROJECT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  18. # INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
  19. # BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  20. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
  21. # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  22. # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  23. # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. #
  25. # The views and conclusions contained in the software and documentation are
  26. # those of the authors and should not be interpreted as representing official
  27. # policies, either expressed or implied, of the RelaxBSD
  28. #

  29. export PATH="/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"

  30. [ -f /etc/ppp/ppp.conf ] && cp /etc/ppp/ppp.conf /etc/ppp/ppp.conf.bak

  31. . gettext.sh
  32. export TEXTDOMAIN=relaxconf
  33. export TEXTDOMAINDIR="/usr/local/share/locale"
  34. TMP=/tmp
  35. SYSTEM="RelaxBSD 1.0"
  36. PPPCONF="/etc/ppp/ppp.conf"
  37. RCCONF="/etc/rc.conf"
  38. CANCELLABEL=$(gettext "Return")

  39. DIALOG="/usr/local/bin/cdialog"

  40. export PATH

  41. dns_function ()
  42. {
  43. gettext "Please enter the IP address of your ISP's primary DNS server." > $TMP/txtTEMP$$
  44. echo >> $TMP/txtTEMP$$
  45. gettext "It's important that these IP numbers be correct." >> $TMP/txtTEMP$$
  46. gettext "The IP numbers should not be: 0.0.0.0 " >> $TMP/txtTEMP$$
  47. echo >> $TMP/txtTEMP$$
  48. gettext "Note: Your service provider's technical support can provide you with this information." >> $TMP/txtTEMP$$
  49. echo >> $TMP/txtTEMP$$
  50. backtitle=$(eval_gettext "\$SYSTEM -> DNS IP ADDRESS ...")
  51. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txtTEMP$$`" 11 74 2> $TMP/rspTEMP$$

  52. if [ $? = 1 ]; then
  53. rm -f $TMP/*TEMP*
  54. clear 2>/dev/null || echo
  55. #gettext "PPP configuration cancelled."
  56. menu_main
  57. fi

  58. DNSIP="`cat $TMP/rspTEMP$$`"
  59. if [ -n $DNSIP ] ; then
  60. gettext "Please enter the IP address of your ISP's secondary DNS server." > $TMP/txtTEMP$$
  61. echo >> $TMP/txtTEMP$$
  62. gettext "If you just press enter, I will assume there is only one DNS server." >> $TMP/txtTEMP$$
  63. gettext "The IP numbers should not be: 0.0.0.0 " >> $TMP/txtTEMP$$
  64. echo >> $TMP/txtTEMP$$
  65. gettext "Note: Your service provider's technical support can provide you with this information." >> $TMP/txtTEMP$$
  66. echo >> $TMP/txtTEMP$$
  67. backtitle=$(eval_gettext "\$SYSTEM -> DNS IP ADDRESS ...")
  68. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txtTEMP$$`" 11 74 2> $TMP/rspTEMP$$
  69. if [ $? = 1 ]; then
  70. rm -f $TMP/*TEMP*
  71. clear 2>/dev/null || echo
  72. #gettext "PPP configuration cancelled."
  73. menu_main
  74. fi

  75. DNSIP2="`cat $TMP/rspTEMP$$`"
  76. fi
  77. if [ -n "$DNSIP" ] ; then
  78.     echo "nameserver $DNSIP" > /etc/resolv.conf
  79.     if [ -n "$DNSIP2" ] ; then
  80.         echo "nameserver $DNSIP2" >> /etc/resolv.conf
  81.     fi
  82. fi
  83. clear 2>/dev/null || echo
  84. }

  85. ppprc ()
  86. {
  87. TITLE=$(gettext "Do you want to connect to internet now?")
  88. YESNO=$(gettext "Setup successfully! You can trying to bring the link up at any time. For example,link up: 'ppp -auto myisp' (See man ppp for more help),link down: 'killall ppp'")
  89. ${DIALOG} --title "$TITLE" --yesno "$YESNO" 7 60
  90. [ $? = 0 ] && ppp -auto myisp
  91. TITLE=$(gettext "Do you want to auto link up when bootup?")
  92. YESNO=$(gettext 'To save these configurations,you must run "/usr/local/bin/relaxsavesetting" to save to a disk before reboot.')
  93. ${DIALOG} --title "$TITLE" --yesno "$YESNO" 7 60
  94. case $? in
  95.     0)
  96. cat >> $RCCONF << RCCONFEOF
  97. ppp_enable="yes"
  98. ppp_mode="auto"
  99. ppp_nat="yes"
  100. ppp_profile="myisp"
  101. RCCONFEOF
  102. ;;
  103. esac
  104. }

  105. ppp_function ()
  106. {
  107. backtitle=$(eval_gettext "\$SYSTEM -> PHONE NUMBER ...")
  108. while [ -z "$PHONENUM" ]
  109. do
  110. gettext "To begin setting up your PPP connection, I need to know a few things." > $TMP/txtTEMP$$
  111. gettext "For starters, what is the phone number of your (I)nternet (S)ervice (P)rovider?" >> $TMP/txtTEMP$$
  112. echo  >> $TMP/txtTEMP$$
  113.        
  114. $DIALOG --cancel-label "${CANCELLABEL}" --backtitle "${backtitle}" --inputbox "`cat $TMP/txtTEMP$$`" 10 75 2> $TMP/rspTEMP$$   

  115. if [ $? = 1 ]; then
  116. rm -f $TMP/*TEMP*
  117. clear 2>/dev/null || echo
  118. #gettext "PPP configuration cancelled."
  119. menu_main
  120. fi

  121. PHONENUM="`cat $TMP/rspTEMP$$`"

  122. if [ -z "$PHONENUM" ]; then
  123. clear 2>/dev/null || echo
  124. rm -f $TMP/*TEMP*
  125. #gettext "PPP configuration cancelled."
  126. #gettext "No phone number."
  127. menu_main
  128. fi
  129. done

  130. backtitle=$(eval_gettext "\$SYSTEM -> MODEM DEVICE ...")
  131. gettext "Where is your modem /dev/cuaa?" > $TMP/txtTEMP$$
  132. $DIALOG --cancel-label "${CANCELLABEL}" --backtitle "$backtitle" --menu "`cat $TMP/txtTEMP$$`" 11 60 4 \
  133. cuaa0 "= (COM1: under DOS)" \
  134. cuaa1 "= (COM2: under DOS)" \
  135. cuaa2 "= (COM3: under DOS)" \
  136. cuaa3 "= (COM4: under DOS)" \
  137. 2> $TMP/rspTEMP$$

  138. MODEM="`cat $TMP/rspTEMP$$`"

  139. if [ -z $MODEM ]; then
  140.     clear 2>/dev/null || echo
  141.     rm -f $TMP/*TEMP*
  142. #    gettext "PPP configuration cancelled."
  143.     menu_main
  144. fi

  145. backtitle=$(eval_gettext "\$SYSTEM -> MODEM BAUD RATE ...")
  146. gettext "What baud rate is your modem?" > $TMP/txtTEMP$$
  147. $DIALOG --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --default-item "115200" --menu "`cat $TMP/txtTEMP$$`" 14 72 7 \
  148. 460800 "460KBps  - ISDN modem..." \
  149. 230400 "230KBps  - 56Kbps modem... or ISDN modem..." \
  150. 115200 "115KBps  - 28.8, 33.6, or 56Kbps modem..." \
  151. 57600  "57.6KBps - 28.8, 33.6, or 56Kbps modem..." \
  152. 38400  "38.4KBps - Hangin ten on the net! 28.8 or 33.6..." \
  153. 19200  "19.2KBps - Better known as 14.4..." \
  154. 9600   "9600bps  - No comment..." 2> $TMP/rspTEMP$$

  155. BAUDRATE="`cat $TMP/rspTEMP$$`"

  156. if [ -z $BAUDRATE ]; then
  157. clear 2>/dev/null || echo
  158. rm -f $TMP/*TEMP*
  159. #gettext "PPP configuration cancelled."
  160. menu_main
  161. fi

  162. gettext "Put your Login = Username in the box below." > $TMP/txtTEMP1
  163. echo >> $TMP/txtTEMP1
  164. gettext "Sometimes they want your username or number followed" >> $TMP/txtTEMP1
  165. gettext "by their @domenu_main name like this below." >> $TMP/txtTEMP1
  166. gettext "Example: [email]jerry@foo.boo.com[/email]" >> $TMP/txtTEMP1
  167. gettext "Example: [email]1234567@foo.boo.com[/email]" >> $TMP/txtTEMP1
  168. echo >> $TMP/txtTEMP1
  169. gettext "Sometimes the username is two words." >> $TMP/txtTEMP1
  170. gettext "Example: jerry donut" >> $TMP/txtTEMP1
  171. echo >> $TMP/txtTEMP1
  172. gettext "Usally it's just your username like this below." >> $TMP/txtTEMP1
  173. gettext "Example: jerry" >> $TMP/txtTEMP1
  174. echo >> $TMP/txtTEMP1

  175. backtitle=$(eval_gettext "\$SYSTEM -> PAP or CHAP LOGIN? ...")
  176. $DIALOG --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txtTEMP1`" 14 64 2> $TMP/rspTEMP1

  177. if [ $? = 1 ]; then
  178. rm -f $TMP/*TEMP*
  179. clear 2>/dev/null || echo
  180. #gettext "PPP configuration cancelled."
  181. menu_main
  182. fi

  183. if [ ! -s $TMP/rspTEMP1 ]; then   
  184. rm -f $TMP/*TEMP*
  185. clear 2>/dev/null || echo
  186. #gettext "PPP configuration cancelled."
  187. #gettext "No username for pap, chap, or ms-chap given."
  188. menu_main
  189. fi

  190. if [ -s $TMP/rspTEMP1 ]; then
  191. AUTH1="`cat $TMP/rspTEMP1`"
  192. eval_gettext "User:$AUTH1 " > $TMP/txtTEMP2
  193. gettext "What's the password for the username above?" >> $TMP/txtTEMP2
  194. gettext "Example: Xpi9u87T" >> $TMP/txtTEMP2
  195. backtitle=$(eval_gettext "\$SYSTEM -> PAP or CHAP PASSWORD? ...")
  196. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txtTEMP2`" 9 64 2> $TMP/rspTEMP2
  197. AUTH2="`cat $TMP/rspTEMP2`"
  198. fi
  199. rm -f $TMP/*TEMP*

  200. ! [ -s /etc/resolv.conf ] && dns_function

  201. cat > $PPPCONF << EOF_
  202. default:
  203. set log Phase Chat LCP IPCP CCP tun command
  204. ident user-ppp VERSION (built COMPILATIONDATE)
  205. set device /dev/$MODEM
  206. set speed $BAUDRATE
  207. set dial "ABORT BUSY ABORT NO\\\sCARRIER TIMEOUT 5 \\
  208.            "" AT OK-AT-OK ATE1Q0 OK \\\dATDT\\\T TIMEOUT 40 CONNECT"
  209. set timeout 180
  210. enable dns
  211. myisp:
  212. set phone $PHONENUM
  213. set authname $AUTH1
  214. set authkey $AUTH2
  215. set ifaddr 10.0.0.1/0 10.0.0.2/0 255.255.255.0 0.0.0.0
  216. add default HISADDR
  217. EOF_
  218. ppprc
  219. }

  220. pppoe_function () {
  221.         if [ -x /usr/local/sbin/pppoe ] ; then
  222.                 DISCOVERY_PROGRAM="/usr/local/sbin/pppoe"
  223.         else
  224.                 echo $(gettext "Please install port: net/rp-pppoe")
  225.                 menu_main
  226.         fi
  227. BACKTITLE=$(eval_gettext "\$SYSTEM -> The Ethernet interface connected to the ADSL modem")
  228. MENU=$(gettext "Select the Ethernet interface connected to the ADSL modem")
  229. echo "${DIALOG}  --clear --item-help --cancel-label "$CANCELLABEL" --backtitle "$BACKTITLE" --menu "$MENU" 10 75 3 \" > $TMP/menuTEMP$$
  230. for i in  /dev/net/* ; do
  231. ETHDEV="`echo $i | cut -nb 10-`"
  232. ETHTEST=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "ethernet"`
  233. if [ -n "$ETHTEST" ] ; then
  234. ETHNAME=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "device" | cut -nb 16-`
  235. ETHVENDOR=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "vendor" | cut -nb 16-`
  236. ETHNUM=`echo $ETHDEV | wc -w| tr -d " "`

  237. # Begin:Add date:2005.04.18
  238. for mmm in '' ' -U ' ; do
  239.         title=$(gettext "SCANNING DEVICE")
  240.         text=$(eval_gettext "Looking for PPPoE Access Concentrator on \$ETHNAME")
  241.         if test -n "$mmm" ; then
  242.                 mmode=$(gettext "(multi-modem mode)")
  243.         fi
  244.         touch $TMP/pppoe.scan
  245.         ifconfig $ETHNAME up
  246.         ($DISCOVERY_PROGRAM $mmm -A -I $ETHNAME > $TMP/$ETHNAME.pppoe ; rm $TMP/pppoe.scan) &
  247.         ( time=0 ; while test -f $TMP/pppoe.scan ; do time=`expr $time + 6`; echo $time; sleep 1; done ) | $DIALOG --title "$title" --gauge "$text $mmode" 10 60 0
  248.         true
  249. done
  250. # End:Add date:2005.04.18
  251. echo "$ETHDEV $ETHNAME $ETHVENDOR \" >> $TMP/menuTEMP$$
  252. fi
  253. done
  254. # Begin:Add date:2005.04.19
  255. cd "$TMP"
  256. ETHDEV=`grep -l AC *.pppoe| cut -f1 -d"." | head -n1`
  257. #ifacenocomma=$(echo $iface | sed -e 's/,/\\,/g')

  258. if test -z "$ETHDEV" ; then
  259.         title=$(gettext 'NOT CONNECTED')
  260.     backtitle=$(eval_gettext "\$SYSTEM -> Can't find any ADSL modem")
  261.         text=$(eval_ngettext \
  262.         'Sorry, I scanned $ETHNUM interface(s), but the Access Concentrator of your provider did not respond. Please check your network and  modem cables. Another reason for the scan failure may also be another running pppoe process which controls the modem.Do you still want to continue ?')
  263.          $DIALOG --title "$title" --clear --backtitle "$backtitle" --yesno "$text" 10 60
  264.          [ $? = "1" ] && (rm $TMP/*pppoe* ; menu_main)
  265. # End:Add date:2005.04.19
  266. echo "2> $TMP/rspTEMP$$" >> $TMP/menuTEMP$$
  267. sh $TMP/menuTEMP$$
  268. ETHDEV=`cat $TMP/rspTEMP$$`
  269. if [ $? = 1 ] ; then
  270. rm -f $TMP/*TEMP*
  271. clear 2> /dev/null || echo
  272. menu_main
  273. fi
  274. else
  275.         title=$(gettext 'DSL CONNECTION FOUND')
  276.         text=$(eval_gettext 'I found an Access Concentrator on $ETHDEV. Should I setup PPPOE for this connection?')
  277.         $DIALOG --title "$title" --clear --yesno "$text" 15 60
  278.         [ $? = "1" ] && (rm $TMP/*pppoe* ; menu_main)
  279. fi

  280. gettext "Welcome to the RelaxBSD ADSL client setup." > $TMP/textTEMP1
  281. gettext "Now, please enter some information" >> $TMP/textTEMP1
  282. gettext "Enter your PPPoE user name:" >> $TMP/textTEMP1

  283. BACKTITLE=$(eval_gettext "\$SYSTEM -> USER NAME")
  284. $DIALOG --cancel-label "$CANCELLABEL" --backtitle "$BACKTITLE" --inputbox "`cat $TMP/textTEMP1`" 9 64 2> $TMP/rspTEMP1

  285. if [ $? = 1 ]; then
  286.         rm -f $TMP/*TEMP*
  287.         clear 2>/dev/null || echo
  288. #        gettext "PPPoE configuration cancelled."
  289.         menu_main
  290. fi
  291.                                                                                                             
  292. if [ ! -s $TMP/rspTEMP1 ]; then
  293.         rm -f $TMP/*TEMP*
  294.         clear 2>/dev/null || echo
  295. #        gettext "PPPoE configuration cancelled."
  296. #        gettext "No username for PPPoE client."
  297.         menu_main
  298. fi
  299.                                                          
  300. if [ -s $TMP/rspTEMP1 ]; then
  301.         AUTH1="`cat $TMP/rspTEMP1`"
  302.         eval_gettext "User:$AUTH1. " > $TMP/txtTEMP2
  303.         gettext "What's the password for the username above?" >> $TMP/txtTEMP2
  304.         gettext "Example: Xpi9u87T" >> $TMP/txtTEMP2
  305.         BACKTITLE=$(eval_gettext "\$SYSTEM -> PPPoE PASSWORD")
  306.         $DIALOG --cancel-label "$CANCELLABEL" --backtitle "$BACKTITLE" --inputbox "`cat $TMP/txtTEMP2`" 9 64 2> $TMP/rspTEMP2
  307.         AUTH2="`cat $TMP/rspTEMP2`"
  308. fi

  309. rm $TMP/*TEMP*
  310. ! [ -s /etc/resolv.conf ] && dns_function

  311. cat > $PPPCONF << EOF_
  312. default:
  313. set log Phase Chat LCP IPCP CCP tun command
  314. ident user-ppp VERSION (built COMPILATIONDATE)
  315. set device PPPoE:$ETHDEV
  316. set speed sync
  317. set mru 1492
  318. set mtu 1492
  319. set ctsrts off
  320. set timeout 180
  321. disable lqr
  322. deny lqr
  323. add default HISADDR
  324. enable dns
  325. myisp:
  326. set authname $AUTH1
  327. set authkey $AUTH2
  328. set dial
  329. set login
  330. set ifaddr 10.0.0.1/0 10.0.0.2/0
  331. nat enable yes
  332. EOF_
  333. ppprc
  334. }

  335. netconf ()
  336. {
  337. BACKTITLE=$(eval_gettext "\$SYSTEM -> Configure additional network interfaces")
  338. MENU=$(gettext "Select the ethernet device")
  339. echo "${DIALOG}  --clear --item-help --cancel-label "$CANCELLABEL" --backtitle "$BACKTITLE" --menu "$MENU" 10 75 3 \" > $TMP/menuTEMP$$
  340. for i in  /dev/net/* ; do
  341.   ETHDEV="`echo $i | cut -nb 10-`"
  342.   ETHTEST=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "ethernet"`
  343.   if [ -n "$ETHTEST" ] ; then
  344.    ETHNAME=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "device" | cut -nb 16-`
  345.    ETHVENDOR=`pciconf -lv | egrep -A 4 "$ETHDEV" | egrep "vendor" | cut -nb 16-`
  346.    ETHNUM=`echo $ETHDEV | wc -w| tr -d " "`
  347.    echo "$ETHDEV $ETHNAME $ETHVENDOR \" >> $TMP/menuTEMP$$
  348.   fi
  349. done
  350. echo "2> $TMP/rspTEMP$$" >> $TMP/menuTEMP$$
  351. sh $TMP/menuTEMP$$
  352.   ETHDEV=`cat $TMP/rspTEMP$$`
  353.   if [ $? = 1 ] ; then
  354.           rm -f $TMP/*TEMP*
  355.           clear 2> /dev/null || echo
  356.           menu_main
  357.   fi
  358. TITLE=$(gettext "User Confirmation Requested")
  359. YESNO=$(gettext "Do you want to disable DHCP service of the interface?")
  360. ${DIALOG} --title "$TITLE" --yesno "$YESNO" 6 50
  361. case $? in
  362.     1)
  363.     menu_main;;
  364. esac
  365. eval_gettext "Configure for \$ETHDEV interface" > $TMP/txt2TEMP$$
  366. gettext " At first,please enter the IPv4 Address of your ethernet interface." >> $TMP/txt2TEMP$$
  367. gettext "For example:192.168.1.90" >> $TMP/txt2TEMP$$
  368. echo >> $TMP/txt2TEMP$$
  369. backtitle=$(eval_gettext "\$SYSTEM -> Network Configuration")
  370. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txt2TEMP$$`" 9 74 "192.168.1.90" 2> $TMP/rsp2TEMP$$
  371. [ "$?" = "1" ] && menu_main
  372. IPV4=`cat $TMP/rsp2TEMP$$`
  373. rm $TMP/*TEMP*
  374. [ -z $IPV4 ] && menu_main

  375. gettext "Please enter the Netmask of your ethernet interface." > $TMP/txt3TEMP$$
  376. gettext "For example:255.255.255.0" >> $TMP/txt3TEMP$$
  377. echo >> $TMP/txt3TEMP$$
  378. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txt3TEMP$$`" 9 74 "255.255.255.0" 2> $TMP/rsp3TEMP$$
  379. [ "$?" = "1" ] && menu_main
  380. NETMASK=`cat $TMP/rsp3TEMP$$`
  381. rm $TMP/*TEMP*
  382. [ -z $NETMASK ] && menu_main

  383. gettext "Please enter the IPv4 Gateway:" >> $TMP/txt4TEMP$$
  384. gettext "For example:192.168.1.1" >> $TMP/txt4TEMP$$
  385. echo >> $TMP/txt4TEMP$$
  386. $DIALOG --clear --cancel-label "$CANCELLABEL" --backtitle "$backtitle" --inputbox "`cat $TMP/txt4TEMP$$`" 8 74 "192.168.1.1" 2> $TMP/rsp4TEMP$$
  387. [ "$?" = "1" ] &&  menu_main
  388. GATEWAY=`cat $TMP/rsp4TEMP$$`
  389. rm $TMP/*TEMP*
  390. [ -z $NETMASK ] && menu_main
  391. [ -f /var/run/dhclient.pid ] && kill -INT `cat /var/run/dhclient.pid`
  392. ifconfig $ETHDEV inet $IPV4 netmask $NETMASK
  393. route add default $GATEWAY
  394. if [ ! -f /etc/resolv.conf ]; then
  395. YESNO=$(gettext "Do you want to configure /etc/resolv.conf?")
  396. ${DIALOG} --defaultno --yesno "$YESNO" 5 50
  397. [ "$?" == "0" ] && dns_function
  398. fi

  399. TITLE=$(gettext "Do you want to save configuration to /etc/rc.conf?")
  400. YESNO=$(gettext 'To save all these configurations,you must run "/usr/local/bin/relaxsavesetting" to save to a disk before reboot.')
  401. ${DIALOG} --title "$TITLE" --yesno "$YESNO" 7 60
  402. case $? in
  403.     0)
  404. sed -e '/NIC/d' $RCCONF > $TMP/rcTEMP.$$
  405. cp -f $TMP/rcTEMP.$$ $RCCONF
  406. rm /tmp/*TEMP*
  407. cat >> $RCCONF << RCCONFEOF
  408. ifconfig_$ETHDEV="inet $IPV4 netmask $NETMASK"
  409. defaultrouter="$GATEWAY"
  410. inetd_enable="yes"
  411. gateway_enable="yes"
  412. RCCONFEOF
  413. ;;
  414.    esac
  415.    
  416. }

  417. menu_main ()
  418. {
  419. BACKTITLE=$(eval_gettext "\$SYSTEM -> Configure network interface")
  420. MENU=$(gettext "Please choose a type of network interface")
  421. PPPLOG=$(gettext "Configure User-ppp")
  422. PPPOELOG=$(gettext "Configure PPP over Ethernet daemon (PPPoE for ADSL)")
  423. ETHLOG=$(gettext "Configure ethernet interface")
  424. NOLOG=$(gettext "I don't want to configure any network interface now")
  425. $DIALOG --clear --backtitle "$BACKTITLE" \
  426.         --menu "$MENU" 11 60 4 \
  427.         "PPP" "$PPPLOG" \
  428.         "PPPoE" "$PPPOELOG" \
  429.         "Ethernet" "$ETHLOG" \
  430.         "No" "$NOLOG" 2> /tmp/menuTEMP$$

  431. retval=$?
  432. choice=`cat /tmp/menuTEMP$$`
  433. rm -f /tmp/menuTEMP$$
  434. case $retval in
  435.   0)
  436.     case $choice in
  437.        PPP)
  438.           ppp_function
  439.           ;;
  440.        PPPoE)
  441.           pppoe_function
  442.           ;;
  443.        Ethernet)
  444.           netconf
  445.           ;;
  446.        No)
  447.           clear 2>/dev/null || echo
  448.           exit 0
  449.           ;;
  450.     esac
  451.     ;;
  452.   1)
  453.     clear 2>/dev/null || echo
  454.     exit 0
  455. esac
  456. }
  457. menu_main
复制代码

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?注册

x
您需要登录后才可以回帖 登录 | 注册

本版积分规则

快速回复 返回顶部 返回列表