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.9 1999/08/31 23:12:44 wiget 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
42 if [ "$runlevel" == "0" ] || [ "$runlevel" == "6" ]; then
43 exec 0<> /dev/tty1 1>&0 2>&0
44 [ -x /usr/bin/chvt ] && /usr/bin/chvt 1 && echo
46 # if previous runlevel == current runlevel do nothing
47 [ "$runlevel" == "$previous" ] && exit 0
50 # set onlcr to avoid staircase effect and do not lock scrolling
53 # Get first argument. Set new runlevel to this argument.
54 [ "$1" != "" ] && runlevel="$argv1"
56 # Tell linuxconf what runlevel we are in
57 [ -d /var/run ] && echo "/etc/rc.d/rc$runlevel.d" > /var/run/runlevel.dir
61 text="`termput setaf 2``nls "Resource Manager:"``termput setaf 7` `nls "Leaving runlevel number"`............................................................................"
62 awk "BEGIN {printf \"%.78s\", \"$text\";}"
63 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"
65 # Is there an rc directory for this new runlevel?
66 if [ -d /etc/rc.d/rc$runlevel.d ]; then
67 # First, run the KILL scripts.
68 for i in /etc/rc.d/rc$runlevel.d/K*; do
69 # Check if the script is there.
70 [ ! -f $i ] && continue
72 # Don't run [KS]??foo.{rpmsave,rpmorig,rpmnew} scripts
73 [ "${1%.rpmsave}" != "${1}" ] && continue
74 [ "${1%.rpmorig}" != "${1}" ] && continue
75 [ "${1%.rpmnew}" != "${1}" ] && continue
77 # Check if the subsystem is already up.
78 subsys=${i#/etc/rc.d/rc$runlevel.d/K??}
79 [ ! -f /var/lock/subsys/$subsys ] && \
80 [ ! -f /var/lock/subsys/${subsys}.init ] && continue
82 # Bring the subsystem down.
86 # Now run the START scripts.
87 for i in /etc/rc.d/rc$runlevel.d/S*; do
88 # Check if the script is there.
89 [ ! -f $i ] && continue
91 # Don't run [KS]??foo.{rpmsave,rpmorig} scripts
92 [ "${1%.rpmsave}" != "${1}" ] && continue
93 [ "${1%.rpmorig}" != "${1}" ] && continue
94 [ "${1%.rpmnew}" != "${1}" ] && continue
96 # Check if the subsystem is already up.
97 subsys=${i#/etc/rc.d/rc$runlevel.d/S??}
98 [ -f /var/lock/subsys/$subsys ] || \
99 [ -f /var/lock/subsys/${subsys}.init ] && continue
101 # Bring the subsystem up.
107 text="`termput setaf 2``nls "Resource Manager:"``termput setaf 7` `nls "Runlevel has been reached"`............................................................................"
108 awk "BEGIN {printf \"%.78s\", \"$text\";}"
109 echo "`termput setaf 6`[`termput setaf 2` $runlevel `termput setaf 6`]`termput setaf 7`"