1
0

localnet 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. case "${1}" in
  30. start)
  31. log_info_msg "Bringing up the loopback interface..."
  32. ip addr add 127.0.0.1/8 label lo dev lo
  33. ip link set lo up
  34. evaluate_retval
  35. log_info_msg "Setting hostname to ${HOSTNAME}..."
  36. hostname ${HOSTNAME}
  37. evaluate_retval
  38. ;;
  39. stop)
  40. log_info_msg "Bringing down the loopback interface..."
  41. ip link set lo down
  42. evaluate_retval
  43. ;;
  44. restart)
  45. ${0} stop
  46. sleep 1
  47. ${0} start
  48. ;;
  49. status)
  50. echo "Hostname is: $(hostname)"
  51. ip link show lo
  52. ;;
  53. *)
  54. echo "Usage: ${0} {start|stop|restart|status}"
  55. exit 1
  56. ;;
  57. esac
  58. exit 0
  59. # End localnet