localnet 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin localnet
  4. #
  5. # Description : Loopback device
  6. #
  7. # Authors : Gerard Beekmans - gerard@linuxfromscratch.org
  8. # DJ Lucas - dj@linuxfromscratch.org
  9. # Update : Bruce Dubbs - bdubbs@linuxfromscratch.org
  10. #
  11. # Version : LFS 7.0
  12. #
  13. ########################################################################
  14. ### BEGIN INIT INFO
  15. # Provides: localnet
  16. # Required-Start: $local_fs
  17. # Should-Start:
  18. # Required-Stop:
  19. # Should-Stop:
  20. # Default-Start: S
  21. # Default-Stop: 0 6
  22. # Short-Description: Starts the local network.
  23. # Description: Sets the hostname of the machine and starts the
  24. # loopback interface.
  25. # X-LFS-Provided-By: LFS
  26. ### END INIT INFO
  27. . /lib/lsb/init-functions
  28. [ -r /etc/sysconfig/network ] && . /etc/sysconfig/network
  29. [ -r /etc/hostname ] && HOSTNAME=`cat /etc/hostname`
  30. case "${1}" in
  31. start)
  32. log_info_msg "Bringing up the loopback interface..."
  33. ip addr add 127.0.0.1/8 label lo dev lo
  34. ip link set lo up
  35. evaluate_retval
  36. log_info_msg "Setting hostname to ${HOSTNAME}..."
  37. hostname ${HOSTNAME}
  38. evaluate_retval
  39. ;;
  40. stop)
  41. log_info_msg "Bringing down the loopback interface..."
  42. ip link set lo down
  43. evaluate_retval
  44. ;;
  45. restart)
  46. ${0} stop
  47. sleep 1
  48. ${0} start
  49. ;;
  50. status)
  51. echo "Hostname is: $(hostname)"
  52. ip link show lo
  53. ;;
  54. *)
  55. echo "Usage: ${0} {start|stop|restart|status}"
  56. exit 1
  57. ;;
  58. esac
  59. exit 0
  60. # End localnet