summaryrefslogtreecommitdiffstats
path: root/aaabasicfs/rc
blob: 81736e9f575f4ba79b555828292f38ea77a9211e (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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#!/bin/sh
########################################################################
# Begin $rc_base/init.d/rc
#
# Description : Main Run Level Control Script
#
# Authors     : Gerard Beekmans  - gerard@linuxfromscratch.org
#
# Version     : 00.00
#
# Notes       :
#
########################################################################

. /etc/sysconfig/rc
. ${rc_functions}

stty sane

trap "" INT QUIT TSTP

[ "${1}" != "" ]  && runlevel=${1}

splashy_update_progress(){
    STEPS_DIR=/etc/splashy/steps_dir
    [ -r "/etc/default/splashy" ] && . "/etc/default/splashy"
    SPL_UPD=/sbin/splashy_update
    SPL_PRG=$STEPS_DIR/${runlevel}-progress
    # load some default variables
    if ! ( pidof splashy > /dev/null ); then
	 /sbin/splashy boot 2>/dev/null
	sleep 1
    else
    	PER=`sed -n 's+'${1}' ++ p' $SPL_PRG`
    	$SPL_UPD "progress $PER"
    fi
}

if [ "${runlevel}" = "" ]; then
	echo "Usage: ${0} <runlevel>" >&2
	exit 1
fi

previous=${PREVLEVEL}
[ "${previous}" = "" ] && previous=N

if [ ! -d ${rc_base}/rc${runlevel}.d ]; then
	boot_mesg "${rc_base}/rc${runlevel}.d does not exist." ${WARNING}
	boot_mesg_flush
	exit 1
fi
# Attempt to stop all service started by previous runlevel,
# and killed in this runlevel
if [ "${previous}" != "N" ]; then
	for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2> /dev/null)
	do
		check_script_status

		suffix=${i#$rc_base/rc$runlevel.d/K[0-9][0-9]}
		prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix
		sysinit_start=$rc_base/rcsysinit.d/S[0-9][0-9]$suffix

		if [ "${runlevel}" != "0" ] && [ "${runlevel}" != "6" ]; then
			if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ]; then
				boot_mesg -n "WARNING:\n\n${i} can't be" ${WARNING}
				boot_mesg -n " executed because it was not"
				boot_mesg -n " not started in the previous"
				boot_mesg -n " runlevel (${previous})."
				boot_mesg "" ${NORMAL}
				boot_mesg_flush
				continue
			fi
		fi
		${i} stop
		error_value=${?}

		if [ "${error_value}" != "0" ]; then
			print_error_msg
		fi
	done
fi

#Start all functions in this runlevel
for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2> /dev/null)
do
	if [ "${previous}" != "N" ]; then
		suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]}
		stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix
		prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix

		[ -f ${prev_start} ] && [ ! -f ${stop} ] && continue
	fi

	check_script_status

	case ${runlevel} in
		0|6)
			[ -f /sbin/splashy ] && splashy_update_progress ${i}
			${i} stop
			;;
		*)
			[ -f /sbin/splashy ] && splashy_update_progress ${i}
			${i} start
			;;
	esac
	error_value=${?}

	if [ "${error_value}" != "0" ]; then
		print_error_msg
	fi
done
# End $rc_base/init.d/rc