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.
8 # $Id: rc,v 1.25.2.2 2001/05/13 17:47:45 misiek Exp $
11 # Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
12 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
15 # avoid being interrupted by child or keyboard
16 trap ":" INT QUIT TSTP
21 # Get terminal size of standard input of the system console
22 [ -z "$CONSOLE" ] && CONSOLE=/dev/console
23 set -- $(stty size < $CONSOLE)
26 export LINES COLUMNS CONSOLE
29 if [ -f /etc/sysconfig/i18n ]; then
31 [ -n "$LANG" ] && export LANG || unset LANG
32 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
33 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
34 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
35 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
36 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
37 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
38 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
39 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
40 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
43 # Source function library.
44 . /etc/rc.d/init.d/functions
46 # Read system config data.
47 if [ -f /etc/sysconfig/system ]; then
48 . /etc/sysconfig/system
50 RUN_SULOGIN_ON_ERR=yes
61 # Now find out what the current and what the previous runlevel are.
65 export runlevel previous
67 # if previous runlevel = current runlevel do nothing
68 [ "$runlevel" = "$previous" ] && exit 0
70 # if runlevel is 0 (halt) or 6 (reboot) change to first
71 # virtual console, and send messages to /dev/console
72 # (it can be serial console too)
73 if [ "$COLUMNS" -gt 0 ]; then
74 if [ "$runlevel" = "0" -o "$runlevel" = "6" ]; then
76 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo > $CONSOLE
77 exec 0<> /dev/console 1>&0 2>&0
80 # Serial: columns and lines are not defined
85 # See if we want to be in user confirmation mode
86 if [ "$previous" = "N" ]; then
87 if grep -qi confirm /proc/cmdline >/dev/null \
88 || [ -f /var/run/confirm ]; then
89 rm -f /var/run/confirm
91 nls "Entering interactive startup"
94 nls "Entering non-interactive startup"
98 # set onlcr to avoid staircase effect and do not lock scrolling
101 # Get first argument. Set new runlevel to this argument.
102 [ -n "$1" ] && runlevel="$argv1"
104 # Tell linuxconf what runlevel we are in
105 [ -d /var/run -a -w /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
109 af2=$(termput setaf 2)
110 af6=$(termput setaf 6)
111 af7=$(termput setaf 7)
112 text="$(termput op)$(nls '%sResource Manager: %sEntering runlevel number' "$af2" "$af7")"
113 text_size="$(nls '%sResource Manager: %sEntering runlevel number' "" "")"
114 resp_size="$(nls 'DONE')"
116 awk "BEGIN { for (j=length(\"$text_size\"); j<$INIT_COL+${#resp_size}-${#runlevel}; j++) printf \".\" }"
117 echo "${af6}[${af2} $runlevel ${af6}]${af7}"
119 # Is there an rc directory for this new runlevel?
120 if [ -d /etc/rc.d/rc$runlevel.d ]; then
121 # First, run the KILL scripts.
122 for i in /etc/rc.d/rc$runlevel.d/K*; do
123 # Check if the script is there.
124 [ ! -f $i ] && continue
126 # Don't run [KS]??foo.{rpmsave,rpmorig,rpmnew} scripts
127 [ "${1%.rpmsave}" != "${1}" ] && continue
128 [ "${1%.rpmorig}" != "${1}" ] && continue
129 [ "${1%.rpmnew}" != "${1}" ] && continue
131 # Check if the subsystem is already up.
132 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
133 [ ! -f /var/lock/subsys/$subsys ] && \
134 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
136 # Bring the subsystem down.
140 # Now run the START scripts.
141 for i in /etc/rc.d/rc$runlevel.d/S*; do
142 # Check if the script is there.
143 [ ! -f $i ] && continue
145 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
146 [ "${1%.rpmsave}" != "${1}" ] && continue
147 [ "${1%.rpmorig}" != "${1}" ] && continue
148 [ "${1%.rpmnew}" != "${1}" ] && continue
150 # Check if the subsystem is already up.
151 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
152 [ -f /var/lock/subsys/$subsys ] || \
153 [ -f /var/lock/subsys/${subsys}.init ] && continue
155 # If we're in confirmation mode, get user confirmation
172 # Bring the subsystem up.
177 # if runlevel is 0 (halt) or 6 (reboot) run rc.shutdown
178 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
179 /etc/rc.d/rc.shutdown
180 if [ "$runlevel" = "0" ] ; then
181 show "The system is halted"; ok
182 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
185 show "Please stand by while rebooting the system"; ok
186 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
190 if is_yes "$RUN_LDCONFIG" || [ ! -f /etc/ld.so.cache ] ; then
191 if [ -x /sbin/ldconfig ]; then
192 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
198 text="$(nls '%sResource Manager: %sRunlevel has been reached' "$af2" "$af7")"
199 text_size="$(nls '%sResource Manager: %sRunlevel has been reached' "" "")"
201 awk "BEGIN { for (j=length(\"$text_size\"); j<$INIT_COL+${#resp_size}-${#runlevel}; j++) printf \".\" }"
202 echo "${af6}[${af2} $runlevel ${af6}]${af7}"
207 # This must be last line !
208 # vi:syntax=sh:tw=78:ts=8:sw=4