aboutsummaryrefslogtreecommitdiffstats
path: root/chapter07/rcS.xml
blob: 7b98bac87714b55863ff06247fa0125c464bf88e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<sect1 id="ch07-rcS">
<title>Creating the rcS script</title>
<?dbhtml filename="rcs.html" dir="chapter07"?>

<para>The second main boot script is the <filename>rcS</filename> script. 
Create the <filename>/etc/init.d/rcS</filename> script by running the following
command:</para>

<para><screen><userinput>cat &gt; /etc/init.d/rcS &lt;&lt; "EOF"</userinput>
#!/bin/sh
# Begin /etc/init.d/rcS

#
# See the rc script for the extensive comments on the constructions
# used here
#

source /etc/init.d/functions

print_error_msg()
{
 
        echo
        $FAILURE
        echo -n "You should not read this error message. It means "
        echo "that an unforeseen error "
        echo -n "took place and subscript $i exited with "
        echo "a return value "
        echo -n "of $error_value for an unknown reason. If you're able "
        echo "to trace this error down "
        echo -n "to a bug in one of the files provided by this book, "
        echo "please be so kind to "
        echo -n "inform us at lfs-dev@linuxfromscratch.org"
        $NORMAL
        echo
        echo
        echo "Press a key to continue..."
        read

}

runlevel=S
prevlevel=N
umask 022
export runlevel prevlevel

trap ":" INT QUIT TSTP

#
# Collect all the S scripts in /etc/rcS.d and execute them
#

for i in /etc/rcS.d/S*
do
        [ ! -f  "$i" ] &amp;&amp; continue;
                $i start
                error_value=$?

                if [ $error_value != 0 ]
                then
                        print_error_msg
                fi
done

# End /etc/init.d/rcS
<userinput>EOF</userinput></screen></para>

</sect1>