ifup 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin /sbin/ifup
  4. #
  5. # Description : Interface Up
  6. #
  7. # Authors : Nathan Coulson - nathan@linuxfromscratch.org
  8. # Kevin P. Fleming - kpfleming@linuxfromscratch.org
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. #
  11. # Version : LFS 7.0
  12. #
  13. # Notes : The IFCONFIG variable is passed to the SERVICE script
  14. # in the /lib/boot directory, to indicate what file the
  15. # service should source to get environmental variables.
  16. #
  17. ########################################################################
  18. file=/etc/sysconfig/ifconfig.${1}
  19. # Skip backup files
  20. [ "${file}" = "${file%""~""}" ] || exit 0
  21. . /lib/boot/functions
  22. boot_mesg "Bringing up the ${1} interface..."
  23. boot_mesg_flush
  24. if [ ! -r "${file}" ]; then
  25. boot_mesg "${file} is missing or cannot be accessed." ${WARNING}
  26. echo_warning
  27. exit 1
  28. fi
  29. . $file
  30. if [ "$IFACE" = "" ]; then
  31. boot_mesg "${file} does not define an interface [IFACE]." ${FAILURE}
  32. echo_failure
  33. exit 1
  34. fi
  35. # Do not process this service if started by boot, and ONBOOT
  36. # is not set to yes
  37. if [ "${IN_BOOT}" = "1" -a "${ONBOOT}" != "yes" ]; then
  38. echo_skipped
  39. exit 0
  40. fi
  41. if [ -n "${SERVICE}" -a -x "/lib/boot/${SERVICE}" ]; then
  42. if [ -z "${CHECK_LINK}" -o \
  43. "${CHECK_LINK}" = "y" -o \
  44. "${CHECK_LINK}" = "yes" -o \
  45. "${CHECK_LINK}" = "1" ]; then
  46. # Bring up the interface
  47. if ip link show ${IFACE} > /dev/null 2>&1; then
  48. link_status=`ip link show ${IFACE}`
  49. if [ -n "${link_status}" ]; then
  50. if ! echo "${link_status}" | grep -q UP; then
  51. ip link set ${IFACE} up
  52. fi
  53. fi
  54. else
  55. boot_mesg "Interface ${IFACE} doesn't exist." ${WARNING}
  56. echo_warning
  57. fi
  58. fi
  59. IFCONFIG=${file} /lib/boot/${SERVICE} ${IFACE} up
  60. else
  61. boot_mesg "Unable to process ${file}. Either" ${FAILURE}
  62. boot_mesg "the SERVICE variable was not set"
  63. boot_mesg "or the specified service cannot be executed."
  64. echo_failure
  65. exit 1
  66. fi
  67. # End /sbin/ifup