localnet.xml 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <sect1 id="ch07-localnet">
  2. <title>Creating the localnet script</title>
  3. <para>Create the <filename>/etc/init.d/localnet</filename> script by running
  4. the following command:</para>
  5. <para><screen><userinput>cat &gt; /etc/init.d/localnet &lt;&lt; "EOF"</userinput>
  6. #!/bin/sh
  7. # Begin /etc/init.d/localnet
  8. #
  9. # Include the functions declared in the /etc/init.d/functions file
  10. # and include the variables from the /etc/sysconfig/network file.
  11. #
  12. source /etc/init.d/functions
  13. source /etc/sysconfig/network
  14. case "$1" in
  15. start)
  16. echo -n "Bringing up the loopback interface..."
  17. /sbin/ifconfig lo 127.0.0.1
  18. evaluate_retval
  19. echo -n "Setting up hostname..."
  20. /bin/hostname $HOSTNAME
  21. evaluate_retval
  22. ;;
  23. stop)
  24. echo -n "Bringing down the loopback interface..."
  25. /sbin/ifconfig lo down
  26. evaluate_retval
  27. ;;
  28. restart)
  29. $0 stop
  30. sleep 1
  31. $0 start
  32. ;;
  33. *)
  34. echo "Usage: $0: {start|stop|restart}"
  35. exit 1
  36. ;;
  37. esac
  38. # End /etc/init.d/localnet
  39. <userinput>EOF</userinput></screen></para>
  40. </sect1>