added man-patch.xml file
[linux_from_scratch.git] / bootscripts / rc.d / init.d / rc
blobfedc068c9dae22b855fde9a1b599e6b9a4d67830
1 #!/bin/bash
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
7 source /etc/sysconfig/rc
8 source $rc_functions
10 trap "" INT QUIT TSTP
12 [ "$1" != "" ] && runlevel=$1
14 if [ "$runlevel" = "" ]
15 then
16 echo "Usage: $0 <runlevel>" >&2
17 exit 1
20 previous=$PREVLEVEL
21 [ "$previous" = "" ] && previous=N
23 if [ ! -d $rc_base/rc$runlevel.d ]
24 then
25 echo "$rc_base/rc$runlevel.d does not exist"
26 exit 1
29 if [ "$previous" != "N" ]
30 then
31 for i in $(ls -v $rc_base/rc$runlevel.d/K* 2> /dev/null)
34 check_script_status
36 suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
37 prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
38 sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix
40 if [ "$runlevel" != "0" ] && [ "$runlevel" != "6" ]
41 then
42 if [ ! -f $prev_start ] && [ ! -f $sysinit_start ]
43 then
44 $WARNING
45 echo "$i can't be executed because it was"
46 echo "not started in the previous runlevel ($previous)"
47 $NORMAL
48 continue
52 $i stop
53 error_value=$?
55 if [ "$error_value" != "0" ]
56 then
57 print_error_msg
59 done
62 for i in $( ls -v $rc_base/rc$runlevel.d/S* 2> /dev/null)
64 if [ "$previous" != "N" ]
65 then
66 suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
67 stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
68 prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
70 [ -f $prev_start ] && [ ! -f $stop ] && continue
73 check_script_status
75 $i start
76 error_value=$?
78 if [ "$error_value" != "0" ]
79 then
80 print_error_msg
82 done
84 # End $rc_base/init.d/rc