network 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin network
  4. #
  5. # Description : Network Control Script
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # Nathan Coulson - nathan@linuxfromscratch.org
  9. # Kevin P. Fleming - kpfleming@linuxfromscratch.org
  10. # DJ Lucas - dj@linuxfromscratch.org
  11. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  12. #
  13. # Version : LFS 7.0
  14. #
  15. ########################################################################
  16. ### BEGIN INIT INFO
  17. # Provides: $network
  18. # Required-Start: $local_fs swap localnet
  19. # Should-Start: $syslog
  20. # Required-Stop: $local_fs swap localnet
  21. # Should-Stop: $syslog
  22. # Default-Start: 3 4 5
  23. # Default-Stop: 0 1 2 6
  24. # Short-Description: Starts and configures network interfaces.
  25. # Description: Starts and configures network interfaces.
  26. # X-LFS-Provided-By: LFS
  27. ### END INIT INFO
  28. case "${1}" in
  29. start)
  30. # Start all network interfaces
  31. for file in /etc/sysconfig/ifconfig.*
  32. do
  33. interface=${file##*/ifconfig.}
  34. # Skip if $file is * (because nothing was found)
  35. if [ "${interface}" = "*" ]
  36. then
  37. continue
  38. fi
  39. /sbin/ifup ${interface}
  40. done
  41. ;;
  42. stop)
  43. # Reverse list
  44. net_files=""
  45. for file in /etc/sysconfig/ifconfig.*
  46. do
  47. net_files="${file} ${net_files}"
  48. done
  49. # Stop all network interfaces
  50. for file in ${net_files}
  51. do
  52. interface=${file##*/ifconfig.}
  53. # Skip if $file is * (because nothing was found)
  54. if [ "${interface}" = "*" ]
  55. then
  56. continue
  57. fi
  58. /sbin/ifdown ${interface}
  59. done
  60. ;;
  61. restart)
  62. ${0} stop
  63. sleep 1
  64. ${0} start
  65. ;;
  66. *)
  67. echo "Usage: ${0} {start|stop|restart}"
  68. exit 1
  69. ;;
  70. esac
  71. exit 0
  72. # End network