localnet.xml 1.3 KB

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