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.15 1999/12/30 12:11:37 jajcus 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 # Now find out what the current and what the previous runlevel are.
38 export runlevel previous
40 # if runlevel is 0 (halt) or 6 (reboot) change to first
41 # virtual console, and send messages to /dev/console
42 # (it can be serial console too)
43 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
44 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo
45 exec 0<> /dev/console 1>&0 2>&0
47 # if previous runlevel = current runlevel do nothing
48 [ "$runlevel" = "$previous" ] && exit 0
51 # set onlcr to avoid staircase effect and do not lock scrolling
54 # Get first argument. Set new runlevel to this argument.
55 [ "$1" != "" ] && runlevel="$argv1"
57 # Tell linuxconf what runlevel we are in
58 [ -d /var/run -a -w /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
62 af2="`termput setaf 2`"
63 af7="`termput setaf 7`"
64 line="............................................................................"
65 text="`nls "%sResource Manager: %sEntering runlevel number%s" $af2 $af7 $line`"
67 awk "BEGIN {printf \"%.78s\", \"$text\";}"
68 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"
70 # Is there an rc directory for this new runlevel?
71 if [ -d /etc/rc.d/rc$runlevel.d ]; then
72 # First, run the KILL scripts.
73 for i in /etc/rc.d/rc$runlevel.d/K*; do
74 # Check if the script is there.
75 [ ! -f $i ] && continue
77 # Don't run [KS]??foo.{rpmsave,rpmorig,rpmnew} scripts
78 [ "${1%.rpmsave}" != "${1}" ] && continue
79 [ "${1%.rpmorig}" != "${1}" ] && continue
80 [ "${1%.rpmnew}" != "${1}" ] && continue
82 # Check if the subsystem is already up.
83 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
84 [ ! -f /var/lock/subsys/$subsys ] && \
85 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
87 # Bring the subsystem down.
91 # Now run the START scripts.
92 for i in /etc/rc.d/rc$runlevel.d/S*; do
93 # Check if the script is there.
94 [ ! -f $i ] && continue
96 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
97 [ "${1%.rpmsave}" != "${1}" ] && continue
98 [ "${1%.rpmorig}" != "${1}" ] && continue
99 [ "${1%.rpmnew}" != "${1}" ] && continue
101 # Check if the subsystem is already up.
102 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
103 [ -f /var/lock/subsys/$subsys ] || \
104 [ -f /var/lock/subsys/${subsys}.init ] && continue
106 # Bring the subsystem up.
111 # if runlevel is 0 (halt) or 6 (reboot) run rc.shutdown
112 if [ "$runlevel" = "0" ] || [ "$runlevel" = "6" ]; then
113 /etc/rc.d/rc.shutdown
114 if [ "$runlevel" = "0" ] ; then
115 show "The system is halted"; ok
116 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
119 show "Please stand by while rebooting the system"; ok
120 [ -f /fastboot ] && (show "On the next boot fsck will be skipped."; ok)
124 if [ -x /sbin/ldconfig ]; then
125 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
130 af2="`termput setaf 2`"
131 af7="`termput setaf 7`"
132 line="............................................................................"
133 text="`nls "%sResource Manager: %sRunlevel has been reached%s" $af2 $af7 $line`"
135 awk "BEGIN {printf \"%.78s\", \"$text\";}"
136 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"