ifup 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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" -a "${HOSTNAME}" != "(none)" ]; then
  53. continue
  54. fi
  55. if [ -n "${SERVICE}" -a -x "${network_devices}/services/${SERVICE}" ]; then
  56. if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
  57. if ip link show ${1} > /dev/null 2>&1; then
  58. link_status=`ip link show ${1}`
  59. if [ -n "${link_status}" ]; then
  60. if ! echo "${link_status}" | grep -q UP; then
  61. ip link set ${1} up
  62. fi
  63. fi
  64. else
  65. boot_mesg "Interface ${1} doesn't exist." ${WARNING}
  66. echo_warning
  67. continue
  68. fi
  69. fi
  70. IFCONFIG=${file} ${network_devices}/services/${SERVICE} ${1} up
  71. else
  72. boot_mesg "Unable to process ${file}. Either" ${FAILURE}
  73. boot_mesg " the SERVICE variable was not set,"
  74. boot_mesg " or the specified service cannot be executed."
  75. echo_failure
  76. continue
  77. fi
  78. )
  79. done
  80. # End $network_devices/ifup