ifup 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. . /lib/lsb/init-functions
  18. # Collect a list of configuration files for our interface
  19. if [ -n "${2}" ]; then
  20. for file in ${@#$1} # All parameters except $1
  21. do
  22. FILES="${FILES} ${NETWORK_DEVICES}/ifconfig.${1}/${file}"
  23. done
  24. elif [ -d "${NETWORK_DEVICES}/ifconfig.${1}" ]; then
  25. FILES=`echo ${NETWORK_DEVICES}/ifconfig.${1}/*`
  26. else
  27. FILES="${NETWORK_DEVICES}/ifconfig.${1}"
  28. fi
  29. message="Bringing up the ${1} interface..."
  30. # Process each configruation file
  31. for file in ${FILES}; do
  32. # skip backup files
  33. if [ "${file}" != "${file%""~""}" ]; then
  34. continue
  35. fi
  36. if [ ! -f "${file}" ]; then
  37. log_warning_msg
  38. message="${file} is not a network configuration file or directory."
  39. log_warning_msg
  40. fi
  41. (
  42. . ${file}
  43. # Will not process this service if started by boot, and ONBOOT
  44. # is not set to yes
  45. if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
  46. continue
  47. fi
  48. # Will not process this service if started by hotplug, and
  49. # ONHOTPLUG is not set to yes
  50. if [ "${IN_HOTPLUG}" = "1" -a "${ONHOTPLUG}" != "yes" -a "${HOSTNAME}" != "(none)" ]; then
  51. continue
  52. fi
  53. if [ -n "${SERVICE}" -a -x "${NETWORK_DEVICES}/services/${SERVICE}" ]; then
  54. if [ -z "${CHECK_LINK}" -o "${CHECK_LINK}" = "y" -o "${CHECK_LINK}" = "yes" -o "${CHECK_LINK}" = "1" ]; then
  55. if ip link show ${1} > /dev/null 2>&1; then
  56. link_status=`ip link show ${1}`
  57. if [ -n "${link_status}" ]; then
  58. if ! echo "${link_status}" | grep -q UP; then
  59. ip link set ${1} up
  60. evaluate_retval standard
  61. fi
  62. fi
  63. else
  64. message="${message}Interface ${1} doesn't exist."
  65. log_warning_msg
  66. fi
  67. fi
  68. IFCONFIG=${file} ${NETWORK_DEVICES}/services/${SERVICE} ${1} up
  69. else
  70. echo -e "${FAILURE}Unable to process ${file}. Either"
  71. echo -e "${FAILURE}the SERVICE variable was not set,"
  72. echo -e "${FAILURE}or the specified service cannot be executed."
  73. message=""
  74. log_failure_msg
  75. fi
  76. )
  77. done
  78. # End $NETWORK_DEVICES/ifup