ifup 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin $network_devices/ifup
  4. #
  5. # Description : Interface Up
  6. #
  7. # Authors : Nathan Coulson - nathan@linuxfromscratch.org
  8. # Kevin P. Fleming - kpfleming@linuxfromscratch.org
  9. #
  10. # Version : 00.00
  11. #
  12. # Notes : the IFCONFIG variable is passed to the scripts found
  13. # in the services directory, to indicate what file the
  14. # service should source to get environmental variables.
  15. #
  16. ########################################################################
  17. . /etc/sysconfig/rc
  18. . ${rc_functions}
  19. # Collect a list of configuration files for our interface
  20. if [ -n "${2}" ]; then
  21. for file in ${@#$1} # All parameters except $1
  22. do
  23. FILES="${FILES} ${network_devices}/ifconfig.${1}/${file}"
  24. done
  25. elif [ -d "${network_devices}/ifconfig.${1}" ]; then
  26. FILES=`echo ${network_devices}/ifconfig.${1}/*`
  27. else
  28. FILES="${network_devices}/ifconfig.${1}"
  29. fi
  30. boot_mesg "Bringing up the ${1} interface..."
  31. boot_mesg_flush
  32. # Process each configruation file
  33. for file in ${FILES}; do
  34. # skip backup files
  35. if [ "${file}" != "${file%""~""}" ]; then
  36. continue
  37. fi
  38. if [ ! -f "${file}" ]; then
  39. boot_mesg "${file} is not a network configuration file or directory." ${WARNING}
  40. echo_warning
  41. continue
  42. fi
  43. (
  44. . ${file}
  45. # Will not process this service if started by boot, and ONBOOT
  46. # is not set to yes
  47. if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
  48. continue
  49. fi
  50. # Will not process this service if started by hotplug, and
  51. # ONHOTPLUG is not set to yes
  52. if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" \
  53. -a "${HOSTNAME}" != "(none)" ]; then continue
  54. fi
  55. if [ -n "${SERVICE}" -a -x "${network_devices}/services/${SERVICE}" ]; then
  56. if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" \
  57. -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
  58. if ip link show ${1} > /dev/null 2>&1; then
  59. link_status=`ip link show ${1}`
  60. if [ -n "${link_status}" ]; then
  61. if ! echo "${link_status}" | grep -q UP; then
  62. ip link set ${1} up
  63. fi
  64. fi
  65. else
  66. boot_mesg "Interface ${1} doesn't exist." ${WARNING}
  67. echo_warning
  68. continue
  69. fi
  70. fi
  71. IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${1} up
  72. else
  73. boot_mesg "Unable to process ${file}. Either" ${FAILURE}
  74. boot_mesg " the SERVICE variable was not set,"
  75. boot_mesg " or the specified service cannot be executed."
  76. echo_failure
  77. continue
  78. fi
  79. )
  80. done
  81. # End $network_devices/ifup