3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.69.2.11 2001/09/30 10:19:36 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
19 # we need /proc mounted before everything
20 mount -n -o gid=17 -t proc /proc /proc
22 # Choose Hardware profile
23 rm -f /var/run/hwprofile 2> /dev/null
24 if [ -f /etc/sysconfig/hwprof ]; then
25 . /etc/sysconfig/hwprof
26 if is_yes "${HWPROFILES}" && [ -x /sbin/hwprofile -a -d /etc/sysconfig/hwprofiles/data ]; then
27 mount -n / -o rw,remount
29 mount -n / -o ro,remount
34 if [ -r /etc/sysconfig/i18n ]; then
36 [ -n "$LANG" ] && export LANG || unset LANG
37 [ -n "$LC_CTYPE" ] && export LC_CTYPE || unset LC_CTYPE
38 [ -n "$LC_COLLATE" ] && export LC_COLLATE || unset LC_COLLATE
39 [ -n "$LC_MESSAGES" ] && export LC_MESSAGES || unset LC_MESSAGES
40 [ -n "$LC_NUMERIC" ] && export LC_NUMERIC || unset LC_NUMERIC
41 [ -n "$LC_MONETARY" ] && export LC_MONETARY || unset LC_MONETARY
42 [ -n "$LC_TIME" ] && export LC_TIME || unset LC_TIME
43 [ -n "$LC_ALL" ] && export LC_ALL || unset LC_ALL
44 [ -n "$LANGUAGE" ] && export LANGUAGE || unset LANGUAGE
45 [ -n "$LINGUAS" ] && export LINGUAS || unset LINGUAS
49 . /etc/rc.d/init.d/functions
51 # Read network config data.
52 if [ -r /etc/sysconfig/network ]; then
53 . /etc/sysconfig/network
59 # Read system config data.
60 if [ -r /etc/sysconfig/system ]; then
61 . /etc/sysconfig/system
63 RUN_SULOGIN_ON_ERR=yes
75 # Print welcome message
76 nls "\t\t\t%sPowered by %sPLD GNU/Linux%s" "$(termput setaf 6)" "$(termput setaf 2)" "$(termput setaf 7)"
77 if is_yes "$PROMPT"; then
78 nls -n "\t\t Press %sI%s to enter interactive startup." "$(termput setaf 1)" "$(termput setaf 7)"
83 # /dev must be also mounted before everything but only if we want use them ;-)
84 if is_yes "$MOUNT_DEVFS"; then
85 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
89 if [ -c /dev/.devfsd -a -x /sbin/devfsd ]; then
90 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
93 # Set console loglevel
94 /bin/dmesg -n $CONSOLE_LOGLEVEL
96 # Configure Linux kernel
97 run_cmd "Configuring kernel parameters" /sbin/sysctl -p /etc/sysctl.conf
99 # Set the system clock.
104 if [ -f /etc/sysconfig/clock ]; then
105 . /etc/sysconfig/clock
107 # convert old style clock config to new values
108 if [ "${CLOCKMODE}" = "GMT" ]; then
110 elif [ "${CLOCKMODE}" = "ARC" ]; then
115 if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
120 CLOCKFLAGS="--hctosys"
122 if is_yes "${UTC}"; then
123 CLOCKFLAGS="${CLOCKFLAGS} --utc";
124 CLOCKDEF="${CLOCKDEF} (utc)";
126 CLOCKFLAGS="${CLOCKFLAGS} --localtime";
127 CLOCKDEF="${CLOCKDEF} (local)";
130 if is_yes "${ARC}"; then
131 CLOCKFLAGS="${CLOCKFLAGS} -A";
132 CLOCKDEF="${CLOCKDEF} (arc)";
135 if is_yes "${SRM}"; then
136 CLOCKFLAGS="${CLOCKFLAGS} -S";
137 CLOCKDEF="${CLOCKDEF} (srm)";
140 # Check if timezone definition is available
141 if [ -e /etc/localtime ] ; then
142 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
143 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
146 TIME_SETUP_DELAYED=yes
150 run_cmd "Activating swap partitions" swapon -a
153 run_cmd "$(nls 'Host:') ${HOSTNAME}" hostname ${HOSTNAME}
155 # Set the NIS domain name
156 if [ -n "$NISDOMAIN" ]; then
157 run_cmd "$(nls 'NIS Domain:') ${NISDOMAIN}" domainname $NISDOMAIN
162 # Initialize USB controller and HID devices
164 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && ! grep -q "usb" /proc/devices 2>/dev/null ; then
165 aliases=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+usb-controller" | awk '{ print $3 }')
166 if [ -n "$aliases" -a "$aliases" != "off" ] ; then
167 /sbin/modprobe -k usbcore
168 run_cmd "Mounting USB filesystem" mount -t usbdevfs usbdevfs /proc/bus/usb
169 for alias in $aliases ; do
170 run_cmd "$(nls 'Initializing USB controller') ($alias)" /sbin/modprobe $alias
172 [ $? -eq 0 -a -n "$aliases" ] && usb=1
176 if ! grep -iq "nousb" /proc/cmdline 2>/dev/null && grep -q "usb" /proc/devices 2>/dev/null ; then
181 if [ $usb = "1" ]; then
183 mouseoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=02")
184 kbdoutput=$(cat /proc/bus/usb/devices 2>/dev/null|grep -E "^I.*Cls=03.*Prot=01")
185 needusbstorage=$(cat /proc/bus/usb/devices 2>/dev/null|grep -e "^I.*Cls=08")
186 if [ -n "$kbdoutput" ] || [ -n "$mouseoutput" ]; then
187 run_cmd "Initializing USB HID interface" /sbin/modprobe hid 2> /dev/null
189 if [ -n "$kbdoutput" ]; then
190 run_cmd "Initializing USB keyboard" /sbin/modprobe keybdev
192 if [ -n "$mouseoutput" ]; then
193 run_cmd "Initializing USB mouse" /sbin/modprobe mousedev
197 if [ -f /fastboot ] || grep -iq "fastboot" /proc/cmdline 2> /dev/null ; then
203 if [ -f /fsckoptions ]; then
204 fsckoptions=$(cat /fsckoptions)
209 if [ -f /forcefsck ]; then
210 fsckoptions="-f $fsckoptions"
213 if is_yes "$COLOR_INIT"; then
214 fsckoptions="-C $fsckoptions"
216 fsckoptions="-V $fsckoptions"
220 _ROOTFS_TYPE=$(grep " / " /proc/mounts | awk '{ print $3 }')
222 if [ -z "$fastboot" -a "$_ROOTFS_TYPE" != "nfs" -a "$_ROOTFS_TYPE" != "romfs" ]; then
223 show "Checking root filesystems."; started
224 initlog -c "fsck -T -a $fsckoptions /"
228 # A return of 2 or higher means there were serious problems.
229 if [ $rc -gt 1 ]; then
230 # don't use '\n' in nls macro !
233 nls "*** An error occurred during the file system check."
234 nls "*** Dropping you to a shell; the system will reboot"
235 nls "*** when you leave the shell."
238 PS1="$(nls '(Repair filesystem)# ')"; export PS1
239 if is_yes "$RUN_SULOGIN_ON_ERR"; then
245 run_cmd "Unmounting file systems" umount -a
246 mount -n -o remount,ro /
247 run_cmd "Automatic reboot in progress." reboot
248 elif [ "$rc" = "1" ]; then
253 # check for arguments
254 if grep -iq nopnp /proc/cmdline; then
260 # set up pnp and kernel pnp
261 if [ -n "$PNP" ]; then
262 if is_yes "$RUN_USERPNP" && [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
263 run_cmd "Setting up ISA PNP devices (userspace pnp)" /sbin/isapnp /etc/isapnp/isapnp.conf
265 if is_yes "$RUN_KERNELPNP"; then
266 /sbin/modprobe -k isa-pnp 2> /dev/null
267 if [ -e /proc/isapnp -a -f /etc/isapnp/isapnp-kernel.conf ]; then
268 show "Setting up ISA PNP devices (kernelspace pnp)"; busy
269 grep -v "^#" /etc/isapnp/isapnp-kernel.conf > /proc/isapnp && (deltext; ok) || (deltext; fail)
274 # Remount the root filesystem read-write.
275 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
277 # Find and activate volume groups
278 if [ -e /proc/lvm -a -x /sbin/vgscan -a -x /sbin/vgchange -a -e /etc/lvmtab ]; then
279 run_cmd "Scanning for LVM volume groups" /sbin/vgscan && \
280 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
286 # Remove stale backups
287 rm -f /etc/mtab~ /etc/mtab~~
289 # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab.
292 [ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb
293 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
295 # Setup hdparm thing (if exists and is needed)
296 if ! grep -iq nohdparm /proc/cmdline; then
297 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
300 # Update quotas if fsck was run on /.
301 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
302 if [ -x /sbin/convertquota ]; then
303 if [ -f /quota.user ]; then
304 /sbin/convertquota -u / && rm -f /quota.user
306 if [ -f /quota.group ]; then
307 /sbin/convertquota -g / && rm -f /quota.group
310 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
313 # /etc/nologin when starting system
314 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
316 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
317 show "Enabling Delay Login"; busy
319 nls "System bootup in progress - please wait" >> /etc/nologin
321 chmod 644 /etc/nologin
322 cp -fp /etc/nologin /etc/nologin.boot
326 # The root filesystem is now read-write, so we can now log via
327 # syslog() directly..
328 if [ -n "$IN_INITLOG" ]; then
332 if [ ! -f /proc/modules ]; then
334 elif ! grep -iq nomodules /proc/cmdline; then
340 # Adjust symlinks as necessary in /boot to keep system services from
341 # spewing messages about mismatched System maps and so on.
342 if is_yes "$SET_SLINKS"; then
343 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
344 ln -s -f System.map-`uname -r` /boot/System.map
346 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
347 ln -s -f System.map-`uname -r` /boot/System.map
351 # Run depmod if RUN_DEPMOD != "no" and:
352 # a) user requested or RUN_DEPMOD="";
353 # b) modules.dep is missing
354 # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
356 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
357 is_yes "$RUN_DEPMOD" && _RUN_DEPMOD=1
358 [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] && _RUN_DEPMOD=1
359 [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] && _RUN_DEPMOD=1
360 [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ] && _RUN_DEPMOD=1
363 if [ "$_RUN_DEPMOD" = "1" ]; then
364 run_cmd "Finding module dependencies" depmod -a
367 # Load sound modules iff they need persistent DMA buffers
368 if grep -q "options sound dmabuf=1" /etc/modules.conf 2>/dev/null ; then
370 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" | awk '{ print $3 }')
371 if [ -n "$alias" -a "$alias" != "off" ] ; then
372 run_cmd "$(nls 'Loading sound module') ($alias)" /sbin/modprobe -k $alias
375 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" | awk '{ print $3 }')
376 if [ -n "$alias" -a "$alias" != "off" ] ; then
377 run_cmd "$(nls 'Loading sound module') ($alias)" /sbin/modprobe -k $alias
382 if [ -f /proc/sys/kernel/modprobe ]; then
383 if [ -n "$USEMODULES" ]; then
384 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
385 sysctl -w kernel.hotplug="/sbin/hotplug" >/dev/null 2>&1
387 # We used to set this to NULL, but that causes
388 # 'failed to exec' messages"
389 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
390 sysctl -w kernel.hotplug="/bin/true" >/dev/null 2>&1
395 if [ -x /etc/rc.d/rc.modules ]; then
400 if [ ! -f /proc/mdstat ]; then
401 modprobe -s md >/dev/null 2>&1
405 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
409 for i in $(grep -v "^#" /etc/raidtab | grep "raiddev" | awk '{print $2}')
411 RAIDDEV=$(basename $i)
412 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
413 show "Starting up RAID device %s" $RAIDDEV
415 if [ -z "$RAIDSTAT" ]; then
416 # Try raidstart first...if that fails then
417 # fall back to raid0run and if that fails, too
418 # fall back to raidadd, raidrun.
420 if [ -x /sbin/raidstart ]; then
424 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
428 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
433 if [ $RESULT -gt 0 ]; then
444 # A non-zero return means there were problems.
445 if [ $rc -gt 0 ]; then
446 show "Starting up RAID devices."; fail
449 nls "*** An error occurred during the RAID startup"
450 nls "*** Dropping you to a shell; the system will reboot"
451 nls "*** when you leave the shell."
454 PS1="$(nls '(RAID Repair)# ')"; export PS1
455 if is_yes "$RUN_SULOGIN_ON_ERR"; then
461 run_cmd "Unmounting file systems" umount -a
462 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
463 run_cmd "Automatic reboot in progress" reboot
465 show "Starting up RAID devices."; ok
470 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline; then
471 show "Checking filesystems"; started
472 initlog -c "fsck -T -R -A -a $fsckoptions"
476 # A return of 2 or higher means there were serious problems.
477 if [ $rc -gt 1 ]; then
480 nls "*** An error occurred during the file system check."
481 nls "*** Dropping you to a shell; the system will reboot"
482 nls "*** when you leave the shell."
485 PS1="$(nls '(Repair filesystem)# ')"; export PS1
486 if is_yes "$RUN_SULOGIN_ON_ERR"; then
492 run_cmd "Unmounting file systems" umount -a
493 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
494 run_cmd "Automatic reboot in progress." reboot
495 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
500 # Mount all other filesystems (except for NFS and /proc, which is already
501 # mounted). Contrary to standard usage,
502 # filesystems are NOT unmounted in single user mode.
503 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs
505 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
506 if [ -x /sbin/convertquota ]; then
507 # try to convert old quotas
508 for mountpt in $(cat /etc/mtab | awk '$4 ~ /quota/{print $2}'); do
509 if [ -f "$mountpt/quota.user" ]; then
510 /sbin/convertquota -u $mountpt && \
511 rm -f $mountpt/quota.user
513 if [ -f "$mountpt/quota.group" ]; then
514 /sbin/convertquota -g $mountpt && \
515 rm -f $mountpt/quota.group
519 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
523 if [ -x /sbin/quotaon ]; then
524 run_cmd "Turning on user and group quotas for local filesystems" /sbin/quotaon -a
527 # Turn on process accounting
528 if [ -x /sbin/accton ] ; then
529 run_cmd "Turning on process accounting" /sbin/accton /var/log/pacct
532 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
533 if is_yes "$TIME_SETUP_DELAYED"; then
534 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
535 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
539 # Initialize the serial ports.
540 if [ -f /etc/rc.d/rc.serial ]; then
541 . /etc/rc.d/rc.serial
544 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
545 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
546 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME 2> /dev/null); then ok; else fail; fi
550 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
553 # I'd use find, but /usr may not be mounted.
554 for afile in /var/lock/* /var/run/*; do
555 if [ -d "$afile" ]; then
556 bafile=$(basename $afile)
557 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -f $afile/*
566 if ! is_no "$NEED_XFILES" ; then
569 chown root.utmp /var/run/utmpx /var/log/wtmpx
570 chmod 0664 /var/run/utmpx /var/log/wtmpx
574 chown root.utmp /var/run/utmp /var/log/wtmp
575 chmod 0664 /var/run/utmp /var/log/wtmp
579 if is_yes "$CLEAN_TMP"; then
586 # Delete Postgres sockets
587 rm -f /tmp/.s.PGSQL.*
589 # Right, now turn on swap in case we swap to files.
590 swapon -a >/dev/null 2>&1
591 run_cmd "Enabling swap space" /bin/true
593 # If a SCSI tape has been detected, load the st module unconditionally
594 # since many SCSI tapes don't deal well with st being loaded and unloaded
595 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
596 if grep -qv ' 9 st' /proc/devices ; then
597 if [ -n "$USEMODULES" ] ; then
598 # Try to load the module. If it fails, ignore it...
599 insmod -p st >/dev/null 2>&1 && /sbin/modprobe st >/dev/null 2>&1
604 # Load usb storage here, to match most other things
605 if [ -n "$needusbstorage" ]; then
606 /sbin/modprobe usb-storage >/dev/null 2>&1
609 # If they asked for ide-scsi, load it
610 if grep -q "ide-scsi" /proc/cmdline ; then
611 /sbin/modprobe -k ide-cd >/dev/null 2>&1
612 /sbin/modprobe -k ide-scsi >/dev/null 2>&1
615 # Adjust symlinks as necessary in /boot to keep system services from
616 # spewing messages about mismatched System maps and so on.
617 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
618 ln -s -f System.map-`uname -r` /boot/System.map
620 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
621 ln -s -f System.map-`uname -r` /boot/System.map
624 # there could be a new kernel version. remove old psdevtab database
627 # Now that we have all of our basic modules loaded and the kernel going,
628 # let's dump the syslog ring somewhere so we can find it later
629 dmesg > /var/log/dmesg
630 chmod 640 /var/log/dmesg
633 # Now that we have all of our basic modules loaded and the kernel going,
634 # let's dump the syslog ring somewhere so we can find it later
635 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
637 if is_yes "$PROMPT"; then
638 /sbin/getkey i && touch /var/run/confirm
643 # This must be last line !
644 # vi:syntax=sh:tw=78:ts=8:sw=4