network_default_connect 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/bin/sh
  2. #Barry Kauler, May 2012, license GPL3 (ref: /usr/share/doc/legal)
  3. #this code is taken out of /etc/rc.d/rc.sysinit
  4. #called from /usr/bin/xwin, if file /tmp/simple_network_setup/network_default_reconnect_required_flag exists.
  5. #that 'flag' file is created in /usr/sbin/hostname-set, if the hostname was changed and the network connection brought down.
  6. #100227 choose default network tool...
  7. DEFAULTCONNECT="`cat /usr/local/bin/defaultconnect | tail -n 1 | tr -s " " | cut -f 2 -d " "`"
  8. [ "`grep 'gprs' /usr/local/bin/defaultconnect`" != "" ] && DEFAULTCONNECT='pgprs-connect'
  9. [ "$DEFAULTCONNECT" = "gkdial" ] && DEFAULTCONNECT="pupdial" #for older pups.
  10. NETCHOICE="$DEFAULTCONNECT" #101007 shinobar
  11. case $DEFAULTCONNECT in
  12. Pwireless2)
  13. NETCHOICE='Pwireless2'
  14. ;;
  15. net-setup.sh)
  16. NETCHOICE='net-setup.sh'
  17. ;;
  18. net_wiz_classic)
  19. NETCHOICE='net_wiz_classic'
  20. ;;
  21. sns)
  22. NETCHOICE='sns'
  23. ;;
  24. connectwizard) #try determine which tool was used to setup networking... 101007
  25. if [ -s /etc/simple_network_setup/connections ];then #100306
  26. NETCHOICE='sns'
  27. else
  28. CHECKOLDWIZ="`ls -1 /etc/*[0-9]mode 2>/dev/null`" #ex: eth0mode, wlan0mode.
  29. if [ "$CHECKOLDWIZ" != "" -a -d /usr/local/net_setup ];then
  30. NETCHOICE='net_wiz_classic'
  31. else
  32. CHECKNEWWIZ="`ls -1 /etc/network-wizard/network/interfaces 2>/dev/null`"
  33. if [ "$CHECKNEWWIZ" != "" ];then
  34. NETCHOICE='net-setup.sh'
  35. else
  36. [ -f /usr/local/Pwireless2/interface ] && NETCHOICE='Pwireless2' #100304
  37. fi
  38. fi
  39. fi
  40. ;;
  41. esac
  42. [ -f /etc/init.d/Pwireless2 ] && chmod 644 /etc/init.d/Pwireless2 #prevent jemimah's script from running. 100304 100513
  43. case $NETCHOICE in
  44. Pwireless2)
  45. #this only sets up interface 'lo'...
  46. /etc/rc.d/rc.network_basic
  47. #jemimah's script is in /etc/init.d/Pwireless2
  48. chmod 755 /etc/init.d/Pwireless2 #make executable so it will run.
  49. #i want to run it right now, as a separate process (rc.services will ignore it)...
  50. /etc/init.d/Pwireless2 start &
  51. ;;
  52. net-setup.sh)
  53. /etc/rc.d/rc.network &
  54. ;;
  55. net_wiz_classic)
  56. #note, old wizard is located in /usr/local/net_setup.
  57. /usr/local/net_setup/etc/rc.d/rc.network &
  58. ;;
  59. sns) #100306
  60. /etc/rc.d/rc.network_basic #this only sets up interface 'lo'.
  61. /usr/local/simple_network_setup/rc.network &
  62. ;;
  63. connectwizard) #101007 shinobar
  64. #100628 shinobar: launch rc.network if eth0 is usable
  65. RCNETWORK=/etc/rc.d/rc.network_basic #this only sets up interface 'lo'.
  66. # eth0 usable?
  67. if /sbin/ifconfig eth0 &>/dev/null ;then
  68. if [ -x /etc/rc.d/rc.network ]; then
  69. RCNETWORK=/etc/rc.d/rc.network
  70. elif [ -e /etc/init.d/Pwireless2 ]; then
  71. chmod 755 /etc/init.d/Pwireless2
  72. fi
  73. fi
  74. $RCNETWORK &
  75. ;;
  76. *) #101007 shinobar
  77. /etc/rc.d/rc.network_basic &
  78. ;;
  79. esac