network 1.9 KB

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