3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.69.2.1 2000/10/18 20:10:49 misiek Exp $
6 # Taken in part from Miquel van Smoorenburg's bcheckrc.
7 # Changes: Arkadiusz Mi¶kiewicz <misiek@pld.org.pl>
10 # Rerun ourselves through initlog
11 if [ -z "$IN_INITLOG" ]; then
12 [ -f /sbin/initlog ] && exec /sbin/initlog -r /etc/rc.d/rc.sysinit
16 PATH=/bin:/sbin:/usr/bin:/usr/sbin
20 if [ -r /etc/sysconfig/i18n ]; then
22 [ -n "$LANG" ] && export LANG || unset LANG
23 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
24 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
25 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
26 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
27 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
28 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
29 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
30 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
31 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
35 . /etc/rc.d/init.d/functions
37 # Read network config data.
38 if [ -r /etc/sysconfig/network ]; then
39 . /etc/sysconfig/network
45 # Read system config data.
46 if [ -r /etc/sysconfig/system ]; then
47 . /etc/sysconfig/system
49 RUN_SULOGIN_ON_ERR=yes
60 # Print welcome message
61 nls "\t\t\t%sPowered by %sPLD GNU/Linux%s" "$(termput setaf 6)" "$(termput setaf 2)" "$(termput setaf 7)"
62 if is_yes "$PROMPT"; then
63 nls -n "\t\t Press %sI%s to enter interactive startup." "$(termput setaf 1)" "$(termput setaf 7)"
68 # we need /proc mounted before everything
69 mount -n -o gid=17 -t proc /proc /proc
71 # /dev must be also mounted before everything but only if we want use them ;-)
72 if is_yes "$MOUNT_DEVFS"; then
73 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
77 if [ -c /dev/.devfsd -a -x /sbin/devfsd ]; then
78 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
79 if [ -e /dev/cdroms/cdrom0 ]; then
80 ln -sf /dev/cdroms/cdrom0 /dev/cdrom
82 if [ -f /etc/sysconfig/mouse ]; then
83 . /etc/sysconfig/mouse
84 if [ -n "$DEVICE" -a "$DEVICE" != "/dev/mouse" ]; then
85 ln -s $DEVICE /dev/mouse
90 # Set console loglevel
91 /bin/dmesg -n $CONSOLE_LOGLEVEL
93 # Configure Linux kernel
94 run_cmd "Configuring kernel parameters" /sbin/sysctl -p /etc/sysctl.conf
96 # Set the system clock.
101 if [ -f /etc/sysconfig/clock ]; then
102 . /etc/sysconfig/clock
104 # convert old style clock config to new values
105 if [ "${CLOCKMODE}" = "GMT" ]; then
107 elif [ "${CLOCKMODE}" = "ARC" ]; then
112 if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
117 CLOCKFLAGS="--hctosys"
121 CLOCKFLAGS="$CLOCKFLAGS -u";
122 CLOCKDEF="$CLOCKDEF (utc)";
128 CLOCKFLAGS="$CLOCKFLAGS -A";
129 CLOCKDEF="$CLOCKDEF (arc)";
134 CLOCKFLAGS="$CLOCKFLAGS -S";
135 CLOCKDEF="$CLOCKDEF (srm)";
139 # Check if timezone definition is available
140 if [ -e /etc/localtime ] ; then
141 if run_cmd "$(nls "Setting clock")$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
142 show "$(nls "Today's date:") $(LC_CTYPE=C date)"; ok
145 TIME_SETUP_DELAYED=yes
149 run_cmd "Activating swap partitions" swapon -a
152 run_cmd "$(nls "Host:") ${HOSTNAME}" hostname ${HOSTNAME}
154 # Set the NIS domain name
155 if [ -n "$NISDOMAIN" ]; then
156 run_cmd "$(nls "NIS Domain:") ${NISDOMAIN}" domainname $NISDOMAIN
161 # Setup hdparm thing (if exists and is needed)
162 if ! grep -iq nohdparm /proc/cmdline; then
163 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
166 if [ -f /fsckoptions ]; then
167 fsckoptions=$(cat /fsckoptions)
172 if [ -f /forcefsck ]; then
173 fsckoptions="-f $fsckoptions"
176 if is_yes "$COLOR_INIT"; then
177 fsckoptions="-C $fsckoptions"
179 fsckoptions="-V $fsckoptions"
183 if awk '{ if ($2 ~ /^\/$/ && ( $3 ~ /^(nfs|romfs)$/ || $6 ~ /^0$/ ) ) exit 1 ; else exit 0}' /etc/fstab; then
185 if [ ! -f /fastboot ]; then
186 show "Checking root filesystems."; started
187 initlog -c "fsck -T -a $fsckoptions /"
191 # A return of 2 or higher means there were serious problems.
192 if [ $rc -gt 1 ]; then
193 # don't use '\n' in nls macro !
195 nls "*** An error occurred during the file system check."
196 nls "*** Dropping you to a shell; the system will reboot"
197 nls "*** when you leave the shell."
200 PS1="$(nls "(Repair filesystem)# ")"; export PS1
201 if is_yes "$RUN_SULOGIN_ON_ERR"; then
207 run_cmd "Unmounting file systems" umount -a
208 mount -n -o remount,ro /
209 run_cmd "Automatic reboot in progress." reboot
210 elif [ "$rc" = "1" ]; then
217 # check for arguments
218 if grep -iq nopnp /proc/cmdline; then
225 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
226 if [ -n "$PNP" ] && is_yes "$RUN_ISAPNP"; then
227 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
232 # Remount the root filesystem read-write.
233 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
235 # Update quotas if fsck was run on /.
236 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ]; then
237 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
240 # /etc/nologin when starting system
241 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
243 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
244 show "Enabling Delay Login"; busy
246 nls "System bootup in progress - please wait" >> /etc/nologin
248 chmod 644 /etc/nologin
249 cp -fp /etc/nologin /etc/nologin.boot
253 # The root filesystem is now read-write, so we can now log via
254 # syslog() directly..
255 if [ -n "$IN_INITLOG" ]; then
259 echo ${HOSTNAME} > /etc/HOSTNAME
264 # Enter root and /proc into mtab.
268 if [ ! -f /proc/modules ]; then
270 elif ! grep -iq nomodules /proc/cmdline; then
276 # Kernel dependent links
277 rm -f /lib/modules/preferred
278 rm -f /lib/modules/default
279 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
280 if is_yes "$SET_SLINKS"; then
281 # Get ready for kmod if module support in the kernel
282 if [ -z $(uname -r | grep "-") ]; then
283 # we're using a new kernel, no preferred needed
286 ktag="$(cat /proc/version)"
287 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
288 if [ -n "$mtag" ]; then
289 mver=$(echo $mtag | awk ' { gsub(/\/lib\/modules\//,NIL); gsub(/.rhkmvtag/,NIL); gsub(/[ ].*$/,NIL); print $0 } ')
291 if [ -n "$mver" ]; then
292 ln -sf /lib/modules/$mver /lib/modules/default
296 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
297 ln -sf /boot/module-info-$mver /boot/module-info
298 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
299 ln -sf /boot/System.map-$mver /boot/System.map
303 # Run depmod if RUN_DEPMOD != "no" and:
304 # a) user requested or RUN_DEPMOD="";
305 # b) modules.dep is missing
306 # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
307 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
308 if is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] || \
309 [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
310 [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
311 [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]; then
312 run_cmd "Finding module dependencies" depmod -a
316 if [ -f /proc/sys/kernel/modprobe ]; then
317 if [ -n "$USEMODULES" ]; then
318 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
320 # We used to set this to NULL, but that causes
321 # 'failed to exec' messages"
322 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
327 if [ -x /etc/rc.d/rc.modules ]; then
332 if [ -n "$USEMODULES" ] && is_yes "$LOAD_SOUND"; then
333 if grep -s -q "^alias sound-slot-0" /etc/modules.conf ; then
334 run_cmd "Loading sound module" modprobe -s sound-slot-0
336 if grep -s -q "^alias synth0" /etc/modules.conf ; then
337 run_cmd "Loading synthesiser module" modprobe -s synth0
342 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
346 for i in $(grep "raiddev" /etc/raidtab | awk '{print $2}')
348 RAIDDEV=$(basename $i)
349 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
350 show "Starting up RAID device %s" $RAIDDEV
352 if [ -z "$RAIDSTAT" ]; then
353 # Try raidstart first...if that fails then
354 # fall back to raid0run and if that fails, too
355 # fall back to raidadd, raidrun.
357 if [ -x /sbin/raidstart ]; then
361 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
365 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
370 if [ $RESULT -gt 0 ]; then
381 # A non-zero return means there were problems.
382 if [ $rc -gt 0 ]; then
383 show "Starting up RAID devices."; fail
385 nls "*** An error occurred during the RAID startup"
386 nls "*** Dropping you to a shell; the system will reboot"
387 nls "*** when you leave the shell."
390 PS1="$(nls "(RAID Repair)# ")"; export PS1
391 if is_yes "$RUN_SULOGIN_ON_ERR"; then
397 run_cmd "Unmounting file systems" umount -a
398 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
399 run_cmd "Automatic reboot in progress" reboot
401 show "Starting up RAID devices."; ok
404 # Find and activate volume groups
405 if [ -s /etc/lvmtab -a -x /sbin/vgscan -a -x /sbin/vgchange ]; then
406 /sbin/vgscan > /dev/null 2>&1
408 # 3 - no volume group(s) found
409 # 95 - driver/module not in kernel
410 if [ "$RESULT" = "3" -o "$RESULT" = "95" ]; then
411 rm -rf /etc/lvmtab.d /etc/lvmtab
413 run_cmd "Scanning for LVM volume groups" /sbin/vgscan
414 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
419 if [ ! -f /fastboot ]; then
420 show "Checking filesystems."; started
421 initlog -c "fsck -T -R -A -a $fsckoptions"
425 # A return of 2 or higher means there were serious problems.
426 if [ $rc -gt 1 ]; then
428 nls "*** An error occurred during the file system check."
429 nls "*** Dropping you to a shell; the system will reboot"
430 nls "*** when you leave the shell."
433 PS1="$(nls "(Repair filesystem)# ")"; export PS1
434 if is_yes "$RUN_SULOGIN_ON_ERR"; then
440 run_cmd "Unmounting file systems" umount -a
441 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
442 run_cmd "Automatic reboot in progress." reboot
443 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
444 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
448 # Mount all other filesystems (except for NFS and /proc, which is already
449 # mounted). Contrary to standard usage,
450 # filesystems are NOT unmounted in single user mode.
451 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
453 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
454 if is_yes "$TIME_SETUP_DELAYED"; then
455 if run_cmd "$(nls "Setting clock")$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
456 show "$(nls "Today's date:") $(LC_CTYPE=C date)"; ok
460 if [ -x /sbin/quotaon ]; then
461 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
464 # Initialize the serial ports.
465 if [ -f /etc/rc.d/rc.serial ]; then
466 . /etc/rc.d/rc.serial
469 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
470 show "Setting %s seconds for kernel reboot after panic." "$PANIC_REBOOT_TIME"; busy
471 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME 2> /dev/null); then ok; else fail; fi
474 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
475 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
480 if ! is_no "$NEED_XFILES" ; then
483 chown root.utmp /var/run/utmpx /var/log/wtmpx
484 chmod 0664 /var/run/utmpx /var/log/wtmpx
488 chown root.utmp /var/run/utmp /var/log/wtmp
489 chmod 0664 /var/run/utmp /var/log/wtmp
493 if is_yes "$CLEAN_TMP"; then
497 # Delete UUCP lock files.
500 # Delete stale subsystem files.
501 rm -f /var/lock/subsys/*
503 # Delete stale pam_console locks.
504 rm -f /var/lock/console/*
505 rm -f /var/lock/console.lock
507 # Delete stale pid files
509 rm -f /var/spool/postoffice/.pid.*
514 # Delete Postgres sockets
515 rm -f /tmp/.s.PGSQL.*
517 # Right, now turn on swap in case we swap to files.
518 swapon -a >/dev/null 2>&1
519 run_cmd "Enabling swap space" /bin/true
521 # If a SCSI tape has been detected, load the st module unconditionally
522 # since many SCSI tapes don't deal well with st being loaded and unloaded
523 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
524 if cat /proc/devices | grep -qv ' 9 st' ; then
525 if [ -n "$USEMODULES" ] ; then
526 # Try to load the module. If it fails, ignore it...
527 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
532 # there could be a new kernel version. remove old psdevtab database
535 # Now that we have all of our basic modules loaded and the kernel going,
536 # let's dump the syslog ring somewhere so we can find it later
537 dmesg > /var/log/dmesg
538 chmod 640 /var/log/dmesg
540 # Now that we have all of our basic modules loaded and the kernel going,
541 # let's dump the syslog ring somewhere so we can find it later
542 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
544 if is_yes "$PROMPT"; then
545 /sbin/getkey i && touch /var/run/confirm
550 # This must be last line !
551 # vi:syntax=sh:tw=78:ts=8:sw=4