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.17 2000/03/08 16:29:09 misiek Exp $
11 # Miquel van Smoorenburg, <miquels@drinkel.nl.mugnet.org>
12 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
16 if [ -f /etc/sysconfig/i18n ]; then
18 [ -n "$LANG" ] && export LANG || unset LANG
19 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
20 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
21 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
22 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
23 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
24 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
25 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
26 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
27 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
30 # Source function library.
31 . /etc/rc.d/init.d/functions
33 # Read system config data.
34 if [ -f /etc/sysconfig/system ]; then
35 . /etc/sysconfig/system
37 RUN_SULOGIN_ON_ERR=yes
48 # Now find out what the current and what the previous runlevel are.
53 export runlevel previous
55 # if runlevel is 0 (halt) or 6 (reboot) change to first
56 # virtual console, and send messages to /dev/console
57 # (it can be serial console too)
58 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
59 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo
60 exec 0<> /dev/console 1>&0 2>&0
62 # if previous runlevel = current runlevel do nothing
63 [ "$runlevel" = "$previous" ] && exit 0
66 # See if we want to be in user confirmation mode
67 if [ "$previous" = "N" ]; then
68 if grep -qi confirm /proc/cmdline >/dev/null \
69 || [ -f /var/run/confirm ]; then
70 rm -f /var/run/confirm
72 nls "Entering interactive startup"
75 nls "Entering non-interactive startup"
79 # set onlcr to avoid staircase effect and do not lock scrolling
82 # Get first argument. Set new runlevel to this argument.
83 [ "$1" != "" ] && runlevel="$argv1"
85 # Tell linuxconf what runlevel we are in
86 [ -d /var/run -a -w /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
90 af2="`termput setaf 2`"
91 af7="`termput setaf 7`"
92 line="............................................................................"
93 text="`nls "%sResource Manager: %sEntering runlevel number%s" $af2 $af7 $line`"
95 awk "BEGIN {printf \"%.78s\", \"$text\";}"
96 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"
98 # Is there an rc directory for this new runlevel?
99 if [ -d /etc/rc.d/rc$runlevel.d ]; then
100 # First, run the KILL scripts.
101 for i in /etc/rc.d/rc$runlevel.d/K*; do
102 # Check if the script is there.
103 [ ! -f $i ] && continue
105 # Don't run [KS]??foo.{rpmsave,rpmorig,rpmnew} scripts
106 [ "${1%.rpmsave}" != "${1}" ] && continue
107 [ "${1%.rpmorig}" != "${1}" ] && continue
108 [ "${1%.rpmnew}" != "${1}" ] && continue
110 # Check if the subsystem is already up.
111 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
112 [ ! -f /var/lock/subsys/$subsys ] && \
113 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
115 # Bring the subsystem down.
119 # Now run the START scripts.
120 for i in /etc/rc.d/rc$runlevel.d/S*; do
121 # Check if the script is there.
122 [ ! -f $i ] && continue
124 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
125 [ "${1%.rpmsave}" != "${1}" ] && continue
126 [ "${1%.rpmorig}" != "${1}" ] && continue
127 [ "${1%.rpmnew}" != "${1}" ] && continue
129 # Check if the subsystem is already up.
130 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
131 [ -f /var/lock/subsys/$subsys ] || \
132 [ -f /var/lock/subsys/${subsys}.init ] && continue
134 # If we're in confirmation mode, get user confirmation
151 # Bring the subsystem up.
156 # if runlevel is 0 (halt) or 6 (reboot) run rc.shutdown
157 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
158 /etc/rc.d/rc.shutdown
159 if [ "$runlevel" = "0" ] ; then
160 show "The system is halted"; ok
161 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
164 show "Please stand by while rebooting the system"; ok
165 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
169 if [ "$RUN_LDCONFIG" = "yes" ] ; then
170 if [ -x /sbin/ldconfig ]; then
171 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
177 af2="`termput setaf 2`"
178 af7="`termput setaf 7`"
179 line="............................................................................"
180 text="`nls "%sResource Manager: %sRunlevel has been reached%s" $af2 $af7 $line`"
182 awk "BEGIN {printf \"%.78s\", \"$text\";}"
183 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"