blob: 808283ddcda0167104c64fc207bbe7599a8650e1 (
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
#! /bin/bash
#
# rc This file is responsible for starting/stopping
# services when the runlevel changes.
#
# Original Author:
# Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
#
set -m
# check a file to be a correct runlevel script
check_runlevel ()
{
# Check if the file exists at all.
[ -x "$1" ] || return 1
is_ignored_file "$1" && return 1
return 0
}
# Now find out what the current and what the previous runlevel are.
argv1="$1"
set $(/sbin/runlevel)
runlevel=$2
previous=$1
export runlevel previous
# Get first argument. Set new runlevel to this argument.
if [ "$argv1" != "" ] ; then
newrunlevel="$argv1"
else
newrunlevel="$runlevel"
fi
if [ "$previous" = "N" ];then
if [ -e /var/run/failsafe ];then
rm -f /var/run/failsafe
if [ -x /sbin/askrunlevel ];then
/sbin/askrunlevel --interactive && ASKRUNLEVEL=no
else
init 1 #jump to init 1 if not aksrunlevel.
fi
fi
fi
. /etc/init.d/functions
export CONSOLETYPE
do_confirm="no"
if [ -f /var/run/confirm ]; then
do_confirm="yes"
fi
UPSTART=
[ -x /sbin/initctl ] && UPSTART=yes
# See if we want to be in user confirmation mode
if [ "$previous" = "N" ]; then
if [ "$do_confirm" = "yes" ]; then
gprintf "Entering interactive startup\n"
else
gprintf "Entering non-interactive startup\n"
fi
elif [[ "$newrunlevel" = "0" || "$newrunlevel" = "6" ]]; then
[ -x /etc/rc.d/init.d/dm -a -f /var/lock/subsys/dm ] && /etc/init.d/dm stop 2> /dev/null
chvt 1
exec &> /dev/console
fi
# Get first argument. Set new runlevel to this argument.
[ -n "$argv1" ] && runlevel="$argv1"
# Is there an rc directory for this new runlevel?
[ -d /etc/rc$runlevel.d ] || exit 0
# Set language, vc settings once to avoid doing it for every init script
# through functions
if [ -z "${NOLOCALE:-}" ] && [ -f /etc/sysconfig/i18n ] ; then
. /etc/profile.d/10lang.sh 2>/dev/null
export LANGSH_SOURCED=1
fi
initsplash
[[ "$newrunlevel" = "0" || "$newrunlevel" = "6" ]] && [ "$splash_mode" = "plymouth" ] && rc_splash start $newrunlevel
nopinit=`grep nopinit /proc/cmdline`
rc_mode=K
export rc_mode
# First, run the KILL scripts.
if [ -z "$nopinit" ]; then
/sbin/prcsys K /etc/rc$runlevel.d/
else
for i in /etc/rc$runlevel.d/K* ; do
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/K??}
[ -f /var/lock/subsys/$subsys ] || [ -f /var/lock/subsys/$subsys.init ] || continue
check_runlevel "$i" || continue
update_boot_stage "$subsys"
# Bring the subsystem down.
[ -n "$UPSTART" ] && initctl emit --quiet stopping JOB=$subsys
action "Stopping %s: " $subsys $i stop
[ -n "$UPSTART" ] && initctl emit --quiet stopped JOB=$subsys
done
fi
rc_mode=S
if [ -z "$nopinit" ] && [ "$do_confirm" != "yes" -a "$runlevel" != "0" -a "$runlevel" != "1" -a "$runlevel" != "6" ]; then
/sbin/prcsys S /etc/rc$runlevel.d/
else
# Now run the START scripts.
for i in /etc/rc$runlevel.d/S* ; do
# Check if the subsystem is already up.
subsys=${i#/etc/rc$runlevel.d/S??}
[ -f /var/lock/subsys/$subsys ] && continue
[ -f /var/lock/subsys/$subsys.init ] && continue
check_runlevel "$i" || continue
# If we're in confirmation mode, get user confirmation
if [ "$do_confirm" = "yes" ]; then
confirm $subsys
rc=$?
if [ "$rc" = "1" ]; then
continue
elif [ "$rc" = "2" ]; then
do_confirm="no"
fi
fi
update_boot_stage "$subsys"
# Bring the subsystem up.
[ -n "$UPSTART" ] && initctl emit --quiet starting JOB=$subsys
if [ "$subsys" = "halt" -o "$subsys" = "reboot" ]; then
export LC_ALL=C
exec $i start
fi
action "Starting %s: " $subsys $i start
[ -n "$UPSTART" ] && initctl emit --quiet started JOB=$subsys
done
fi
if [[ "$newrunlevel" != "0" && "$newrunlevel" != "6" && "$newrunlevel" != "S" && "$newrunlevel" != "5" ]]; then
rc_splash stop
fi
[ "$do_confirm" = "yes" ] && rm -f /var/run/confirm
exit 0
|