2 # Begin $rc_base/init.d/rc - Main Run Level Control Script
4 # Based on rc script from LFS-3.1 and earlier.
5 # Rewritten by Gerard Beekmans - gerard@linuxfromscratch.org
10 # This sets a few default terminal options.
13 # These 3 signals will not cause our script to exit
16 [ "$1" != "" ] && runlevel
=$1
18 if [ "$runlevel" = "" ]
20 echo "Usage: $0 <runlevel>" >&2
25 [ "$previous" = "" ] && previous
=N
27 if [ ! -d $rc_base/rc
$runlevel.d
]
29 echo "$rc_base/rc$runlevel.d does not exist"
33 # Attempt to stop all service started by previous runlevel,
34 # and killed in this runlevel
35 if [ "$previous" != "N" ]
37 for i
in $
(ls -v $rc_base/rc
$runlevel.d
/K
* 2> /dev
/null
)
42 suffix
=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
43 prev_start
=$rc_base/rc
$previous.d
/S
[0-9][0-9]$suffix
44 sysinit_start
=$rc_base/rcsysinit.d
/S
[0-9][0-9]$suffix
46 if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
48 if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
51 echo "$i can't be executed because it was"
52 echo "not started in the previous runlevel ($previous)"
60 if [ "$error_value" != "0" ]
67 #Start all functions in this runlevel
68 for i
in $
( ls -v $rc_base/rc
$runlevel.d
/S
* 2> /dev
/null
)
70 if [ "$previous" != "N" ]
72 suffix
=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
73 stop
=$rc_base/rc
$runlevel.d
/K
[0-9][0-9]$suffix
74 prev_start
=$rc_base/rc
$previous.d
/S
[0-9][0-9]$suffix
76 [ -f $prev_start ] && [ ! -f $stop ] && continue
84 if [ "$error_value" != "0" ]
90 # End $rc_base/init.d/rc