3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.27 1999/09/27 14:23:04 wiget Exp $
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
11 PATH=/bin:/sbin:/usr/bin:/usr/sbin
15 if [ -f /etc/sysconfig/i18n ]; then
17 [ -n "$LANG" ] && export LANG || unset LANG
18 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
19 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
20 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
21 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
22 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
23 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
24 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
25 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
26 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
31 . /etc/rc.d/init.d/functions
33 # Read network config data.
34 if [ -f /etc/sysconfig/network ]; then
35 . /etc/sysconfig/network
41 # Read system config data.
42 if [ -f /etc/sysconfig/system ]; then
43 . /etc/sysconfig/system
45 RUN_SULOGIN_ON_ERR=yes
55 # Set console loglevel
56 /sbin/loglevel $CONSOLE_LOGLEVEL
59 run_cmd "`nls "Activating swap partitions"`" swapon -a
62 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
64 # Set the NIS domain name
65 if [ -n "$NISDOMAIN" ]; then
66 run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
71 if [ -f /fsckoptions ]; then
72 fsckoptions=`cat /fsckoptions`
77 if [ -f /forcefsck ]; then
78 fsckoptions="-f $fsckoptions"
81 # we need /proc mounted before starting fsck
82 mount -t proc /proc /proc
85 NFSROOT=`cat /proc/mounts | awk '{ if ($2 ~ /^\/$/ && $3 ~ /^nfs$/) print $3 }'`
88 if [ ! -f /fastboot ] && [ ! -n "$NFSROOT" ]; then
89 show "Checking root filesystems."; started
90 initlog -c "fsck -T -a $fsckoptions /"
94 # A return of 2 or higher means there were serious problems.
95 if [ $rc -gt 1 ]; then
96 nls "\n\n*** An error occurred during the file system check.\n"
97 nls "*** Dropping you to a shell; the system will reboot\n"
98 nls "*** when you leave the shell.\n"
100 PS1="`nls "(Repair filesystem) #"`"; export PS1
101 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
107 run_cmd "Unmounting file systems" umount -a
108 mount -n -o remount,ro /
109 run_cmd "Automatic reboot in progress." reboot
110 elif [ "$rc" == "1" ]; then
115 # check for arguments
116 if grep -i nopnp /proc/cmdline >/dev/null ; then
123 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
124 if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
125 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
129 # Remount the root filesystem read-write.
130 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
132 # Update quotas if fsck was run on /.
133 if [ X"$_RUN_QUOTACHECK" == "X1" -a -x /sbin/quotacheck ] && [ ! -n "$NFSROOT" ]; then
134 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
137 # /etc/nologin when starting system
138 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
140 if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
141 show "Enabling Delay Login"; busy
143 nls "System bootup in progress - please wait" >> /etc/nologin
145 chmod 644 /etc/nologin
146 cp -fp /etc/nologin /etc/nologin.boot
154 # Enter root and /proc into mtab.
158 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
164 # Kernel dependent links
165 rm -f /lib/modules/preferred
166 rm -f /lib/modules/default
167 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
168 if [ "$SET_SLINKS" != "no" ]; then
169 # Get ready for kmod if module support in the kernel
170 if [ -z `uname -r | grep "-"` ]; then
171 # we're using a new kernel, no preferred needed
174 ktag="`cat /proc/version`"
175 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
176 if [ -n "$mtag" ]; then
177 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'
179 if [ -n "$mver" ]; then
180 ln -sf /lib/modules/$mver /lib/modules/default
184 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && ln -sf /boot/module-info-$mver /boot/module-info
185 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && ln -sf /boot/System.map-$mver /boot/System.map
186 run_cmd "Finding module dependencies" depmod -a -s
190 if [ -n "$USEMODULES" ] && [ "$LOAD_SOUND" == "yes" ]; then
191 if grep -s -q "^alias sound" /etc/conf.modules ; then
192 run_cmd "Loading sound module" modprobe -s sound
194 if grep -s -q "^alias midi" /etc/conf.modules ; then
195 run_cmd "Loading midi module" modprobe -s midi
199 if [ -f /proc/sys/kernel/modprobe ]; then
200 # /proc/sys/kernel/modprobe indicates built-in kmod instead
201 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
205 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
206 show "Starting up RAID devices."; started
207 initlog -c 'raidadd -a'
215 # A non-zero return means there were problems.
216 if [ $rc -gt 0 ]; then
219 nls "*** An error occurred during the RAID startup"
220 nls "*** Dropping you to a shell; the system will reboot"
221 nls "*** when you leave the shell."
223 PS1="`nls "(RAID Repair) #"`"; export PS1
224 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
230 run_cmd "Unmounting file systems" umount -a
231 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
232 run_cmd "Automatic reboot in progress" reboot
237 if [ ! -f /fastboot ]; then
238 show "Checking filesystems."; started
239 initlog -c "fsck -T -R -A -a $fsckoptions"
243 # A return of 2 or higher means there were serious problems.
244 if [ $rc -gt 1 ]; then
247 nls "*** An error occurred during the file system check."
248 nls "*** Dropping you to a shell; the system will reboot"
249 nls "*** when you leave the shell."
251 PS1="`nls "(Repair filesystem) #"`"; export PS1
252 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
258 run_cmd "Unmounting file systems" umount -a
259 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
260 run_cmd "Automatic reboot in progress." reboot
261 elif [ "$rc" == "1" -a -x /sbin/quotacheck ]; then
262 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
266 # Mount all other filesystems (except for NFS and /proc, which is already
267 # mounted). Contrary to standard usage,
268 # filesystems are NOT unmounted in single user mode.
269 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
271 # set the console font
272 #if [ -x /sbin/setsysfont ]; then
273 # show "Loading default system font"; busy
274 # if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
277 if [ -x /sbin/quotaon ]; then
278 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
281 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
282 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
285 chown root.utmp /var/run/utmpx
286 chmod 0664 /var/run/utmpx /var/log/wtmpx
289 if [ "$CLEAN_TMP" == "yes" ]; then
293 # Delete UUCP lock files.
296 # Delete stale subsystem files.
297 rm -f /var/lock/subsys/*
299 # Delete stale pam_console locks.
300 rm -f /var/lock/console/*
301 rm -f /var/lock/console.lock
303 # Delete stale pid files
305 rm -f /var/spool/postoffice/.pid.*
310 # Delete Postgres sockets
311 rm -f /tmp/.s.PGSQL.*
313 # Set the system clock.
314 show "Setting clock"; busy
318 if [ -f /etc/sysconfig/clock ]; then
319 . /etc/sysconfig/clock
321 # convert old style clock config to new values
322 if [ "${CLOCKMODE}" == "GMT" ]; then
324 elif [ "${CLOCKMODE}" == "ARC" ]; then
329 if [ -x /sbin/hwclock ]; then
330 CLOCKFLAGS="--hctosys"
339 CLOCKFLAGS="$CLOCKFLAGS -u";
346 CLOCKFLAGS="$CLOCKFLAGS -A";
352 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
354 show "`nls "Date set to"` `date`"; ok
356 # Right, now turn on swap in case we swap to files.
357 show "Enabling swap space"; busy
358 if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
364 # Initialize the serial ports.
365 if [ -f /etc/rc.d/rc.serial ]; then
366 . /etc/rc.d/rc.serial
369 # If a SCSI tape has been detected, load the st module unconditionally
370 # since many SCSI tapes don't deal well with st being loaded and unloaded
371 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
372 if cat /proc/devices | grep -qv ' 9 st' ; then
373 if [ -n "$USEMODULES" ] ; then
374 # Try to load the module. If it fails, ignore it...
375 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
380 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
382 #if [ -x /bin/ps ]; then
383 #show "Rebuilding /etc/psdevtab database"; busy
384 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
387 if [ -x /sbin/ldconfig ]; then
388 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
391 if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
392 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
393 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
396 # Now that we have all of our basic modules loaded and the kernel going,
397 # let's dump the syslog ring somewhere so we can find it later
398 dmesg > /var/log/dmesg
399 chmod 640 /var/log/dmesg
401 # Feed entropy into the entropy pool
402 /etc/rc.d/init.d/random start