rcS.xml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <sect1 id="ch07-rcS">
  2. <title>Creating the rcS script</title>
  3. <?dbhtml filename="rcs.html" dir="chapter07"?>
  4. <para>The second main boot script is the <filename>rcS</filename> script.
  5. Create the <filename>/etc/init.d/rcS</filename> script by running the following
  6. command:</para>
  7. <para><screen><userinput>cat &gt; /etc/init.d/rcS &lt;&lt; "EOF"</userinput>
  8. #!/bin/sh
  9. # Begin /etc/init.d/rcS
  10. #
  11. # See the rc script for the extensive comments on the constructions
  12. # used here
  13. #
  14. source /etc/init.d/functions
  15. print_error_msg()
  16. {
  17. echo
  18. $FAILURE
  19. echo -n "You should not read this error message. It means "
  20. echo "that an unforeseen error "
  21. echo -n "took place and subscript $i exited with "
  22. echo "a return value "
  23. echo -n "of $error_value for an unknown reason. If you're able "
  24. echo "to trace this error down "
  25. echo -n "to a bug in one of the files provided by this book, "
  26. echo "please be so kind to "
  27. echo -n "inform us at lfs-dev@linuxfromscratch.org"
  28. $NORMAL
  29. echo
  30. echo
  31. echo "Press a key to continue..."
  32. read
  33. }
  34. runlevel=S
  35. prevlevel=N
  36. umask 022
  37. export runlevel prevlevel
  38. trap ":" INT QUIT TSTP
  39. #
  40. # Collect all the S scripts in /etc/rcS.d and execute them
  41. #
  42. for i in /etc/rcS.d/S*
  43. do
  44. [ ! -f "$i" ] &amp;&amp; continue;
  45. $i start
  46. error_value=$?
  47. if [ $error_value != 0 ]
  48. then
  49. print_error_msg
  50. fi
  51. done
  52. # End /etc/init.d/rcS
  53. <userinput>EOF</userinput></screen></para>
  54. </sect1>