3 # rc This file is responsible for starting/stopping
4 # services when the runlevel changes. It is also
5 # responsible for the very first setup of basic
6 # things, such as setting the hostname.
10 # Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
13 # avoid being interrupted by child or keyboard
14 trap ":" INT QUIT TSTP
20 # Get terminal size of standard input of the system console
21 [ -z "$CONSOLE" ] && CONSOLE=/dev/console
22 if [ -c $CONSOLE ]; then
23 set -- $(stty size < $CONSOLE 2>/dev/null)
30 export LINES COLUMNS CONSOLE
33 if [ -f /etc/sysconfig/i18n ]; then
35 [ -n "$LANG" ] && export LANG || unset LANG
36 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
37 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
38 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
39 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
40 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
41 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
42 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
43 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
44 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
47 # Source function library.
48 . /etc/rc.d/init.d/functions
50 if [ "$argv2" != "chroot" ]; then
51 # Now find out what the current and what the previous runlevel are.
55 export runlevel previous
58 # Get first argument. Set new runlevel to this argument.
59 [ -n "$argv1" ] && runlevel="$argv1"
61 # if previous runlevel = current runlevel do nothing
62 [ "$runlevel" = "$previous" ] && exit 0
64 # Tell linuxconf what runlevel we are in
65 [ -d /var/run -a -w /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
67 # if runlevel is 0 (halt) or 6 (reboot) change to first
68 # virtual console, and send messages to /dev/console
69 # (it can be serial console too)
70 if [ "$COLUMNS" -gt 0 ]; then
71 if [ "$argv2" != "chroot" ] && \
72 [ "$runlevel" = "0" -o "$runlevel" = "6" ]; then
74 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > $CONSOLE
75 exec 0<> /dev/console 1>&0 2>&0
78 # Serial: columns and lines are not defined
83 # See if we want to be in user confirmation mode
84 if [ "$previous" = "N" ]; then
85 if grep -qi confirm /proc/cmdline >/dev/null 2>/dev/null \
86 || [ -f /var/run/confirm ]; then
87 rm -f /var/run/confirm
89 nls "Entering interactive startup"
92 nls "Entering non-interactive startup"
96 # calculate bootsplash variables
98 for i in /etc/rc.d/rc$runlevel.d/S*; do
99 [ ! -f $i ] && continue
100 [ "${1%.rpmsave}" != "${1}" ] && continue
101 [ "${1%.rpmorig}" != "${1}" ] && continue
102 [ "${1%.rpmnew}" != "${1}" ] && continue
103 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
104 [ -f /var/lock/subsys/$subsys ] && \
105 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
106 sscripts=$(( sscripts + 1 ))
110 if test "$previous" != "N" ; then
112 for i in /etc/rc.d/rc$runlevel.d/K*; do
113 [ ! -f $i ] && continue
114 [ "${1%.rpmsave}" != "${1}" ] && continue
115 [ "${1%.rpmorig}" != "${1}" ] && continue
116 [ "${1%.rpmnew}" != "${1}" ] && continue
117 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
118 [ ! -f /var/lock/subsys/$subsys ] && \
119 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
120 kscripts=$(( kscripts + 1 ))
125 if test "$previous" = "N" -a "$runlevel" = "5" ; then
127 sscripts=$(( $sscripts + 15 ))
132 # set onlcr to avoid staircase effect and do not lock scrolling
133 stty onlcr -ixon 0>&1 2>/dev/null
136 af2=$(termput setaf $CRESMAN)
137 af6=$(termput setaf $CBRACKETS)
139 text="$(termput op)$(nls '%sResource Manager: %sEntering runlevel number' "$af2" "$af7")"
140 text_size="$(nls '%sResource Manager: %sEntering runlevel number' "" "")"
141 resp_size="$(nls 'DONE')"
144 _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
145 while [ $((_len++)) -lt $_last_col ]; do
151 echo "${af6}[${af2} $runlevel ${af6}]${af7}"
153 # Is there an rc directory for this new runlevel?
154 if [ -d /etc/rc.d/rc$runlevel.d ]; then
155 # First, run the KILL scripts.
156 for i in /etc/rc.d/rc$runlevel.d/K*; do
157 # Check if the script is there.
158 [ ! -f $i ] && continue
160 # Don't run [KS]??foo.{rpmsave,rpmorig,rpmnew} scripts
161 [ "${1%.rpmsave}" != "${1}" ] && continue
162 [ "${1%.rpmorig}" != "${1}" ] && continue
163 [ "${1%.rpmnew}" != "${1}" ] && continue
165 # Check if the subsystem is already up.
166 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
167 [ ! -f /var/lock/subsys/$subsys ] && \
168 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
172 # Bring the subsystem down.
176 # Now run the START scripts.
177 for i in /etc/rc.d/rc$runlevel.d/S*; do
178 # Check if the script is there.
179 [ ! -f $i ] && continue
181 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
182 [ "${1%.rpmsave}" != "${1}" ] && continue
183 [ "${1%.rpmorig}" != "${1}" ] && continue
184 [ "${1%.rpmnew}" != "${1}" ] && continue
186 # Check if the subsystem is already up.
187 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
188 [ -f /var/lock/subsys/$subsys ] || \
189 [ -f /var/lock/subsys/${subsys}.init ] && continue
191 # If we're in confirmation mode, get user confirmation
209 # Bring the subsystem up.
214 # if runlevel is 0 (halt) or 6 (reboot) run rc.shutdown
215 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
228 unset LC_IDENTIFICATION
232 if [ "$argv2" != "chroot" ]; then
233 exec /etc/rc.d/rc.shutdown $runlevel $previous
238 if is_yes "$RUN_LDCONFIG" || [ ! -f /etc/ld.so.cache ] ; then
239 if [ -x /sbin/ldconfig ]; then
240 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
248 text="$(nls '%sResource Manager: %sRunlevel has been reached' "$af2" "$af7")"
249 text_size="$(nls '%sResource Manager: %sRunlevel has been reached' "" "")"
252 _last_col=$(($INIT_COL+${#resp_size}-${#runlevel}))
253 while [ $((_len++)) -lt $_last_col ]; do
259 echo "${af6}[${af2} $runlevel ${af6}]${af7}"