3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.69.2.14 2001/10/25 08:27:05 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 # Set console loglevel
84 /bin/dmesg -n $CONSOLE_LOGLEVEL
86 # /dev must be also mounted before everything but only if we want use them ;-)
87 if is_yes "$MOUNT_DEVFS"; then
88 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
92 if [ -e /dev/.devfsd -a -x /sbin/devfsd ]; then
93 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
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 /
280 # Remove stale backups
281 rm -f /etc/mtab~ /etc/mtab~~
283 # Enter root, /proc and (potentially) /proc/bus/usb and devfs into mtab.
286 [ -f /proc/bus/usb/devices ] && mount -f -t usbdevfs usbdevfs /proc/bus/usb
287 [ -e /dev/.devfsd ] && mount -f -t devfs devfs /dev
289 # Setup hdparm thing (if exists and is needed)
290 if ! grep -iq nohdparm /proc/cmdline; then
291 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
294 # Update quotas if fsck was run on /.
295 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
296 if [ -x /sbin/convertquota ]; then
297 if [ -f /quota.user ]; then
298 /sbin/convertquota -u / && rm -f /quota.user
300 if [ -f /quota.group ]; then
301 /sbin/convertquota -g / && rm -f /quota.group
304 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
307 # /etc/nologin when starting system
308 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
310 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
311 show "Enabling Delay Login"; busy
313 nls "System bootup in progress - please wait" >> /etc/nologin
315 chmod 644 /etc/nologin
316 cp -fp /etc/nologin /etc/nologin.boot
320 # The root filesystem is now read-write, so we can now log via
321 # syslog() directly..
322 if [ -n "$IN_INITLOG" ]; then
326 if [ ! -f /proc/modules ]; then
328 elif ! grep -iq nomodules /proc/cmdline; then
334 # Adjust symlinks as necessary in /boot to keep system services from
335 # spewing messages about mismatched System maps and so on.
336 if is_yes "$SET_SLINKS"; then
337 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
338 ln -s -f System.map-`uname -r` /boot/System.map
340 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
341 ln -s -f System.map-`uname -r` /boot/System.map
345 # Run depmod if RUN_DEPMOD != "no" and:
346 # a) user requested or RUN_DEPMOD="";
347 # b) modules.dep is missing
348 # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
350 if ! is_no "$RUN_DEPMOD" && [ -n "$USEMODULES" ]; then
351 is_yes "$RUN_DEPMOD" && _RUN_DEPMOD=1
352 [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] && _RUN_DEPMOD=1
353 [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] && _RUN_DEPMOD=1
354 [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ] && _RUN_DEPMOD=1
357 if [ "$_RUN_DEPMOD" = "1" ]; then
358 run_cmd "Finding module dependencies" depmod -a
361 # Load sound modules iff they need persistent DMA buffers
362 if grep -q "options sound dmabuf=1" /etc/modules.conf 2>/dev/null ; then
364 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound[[:space:]]+" | awk '{ print $3 }')
365 if [ -n "$alias" -a "$alias" != "off" ] ; then
366 run_cmd "$(nls 'Loading sound module') ($alias)" /sbin/modprobe -k $alias
369 alias=$(/sbin/modprobe -c | egrep -s "^alias[[:space:]]+sound-slot-0[[:space:]]+" | awk '{ print $3 }')
370 if [ -n "$alias" -a "$alias" != "off" ] ; then
371 run_cmd "$(nls 'Loading sound module') ($alias)" /sbin/modprobe -k $alias
376 if [ -f /proc/sys/kernel/modprobe ]; then
377 if [ -n "$USEMODULES" ]; then
378 sysctl -w kernel.modprobe="/sbin/modprobe" >/dev/null 2>&1
379 sysctl -w kernel.hotplug="/sbin/hotplug" >/dev/null 2>&1
381 # We used to set this to NULL, but that causes
382 # 'failed to exec' messages"
383 sysctl -w kernel.modprobe="/bin/true" >/dev/null 2>&1
384 sysctl -w kernel.hotplug="/bin/true" >/dev/null 2>&1
389 if [ -x /etc/rc.d/rc.modules ]; then
393 # Find and activate volume groups
394 modprobe -s lvm-mod >/dev/null 2>&1
395 if [ -e /proc/lvm -a -x /sbin/vgscan -a -x /sbin/vgchange -a -e /etc/lvmtab ]; then
396 run_cmd "Scanning for LVM volume groups" /sbin/vgscan && \
397 run_cmd "Activating LVM volume groups" /sbin/vgchange -a y
401 if [ ! -f /proc/mdstat ]; then
402 modprobe -s md >/dev/null 2>&1
406 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
410 for i in $(grep -v "^#" /etc/raidtab | grep "raiddev" | awk '{print $2}')
412 RAIDDEV=$(basename $i)
413 RAIDSTAT=$(grep "^$RAIDDEV : active" /proc/mdstat)
414 show "Starting up RAID device %s" $RAIDDEV
416 if [ -z "$RAIDSTAT" ]; then
417 # Try raidstart first...if that fails then
418 # fall back to raid0run and if that fails, too
419 # fall back to raidadd, raidrun.
421 if [ -x /sbin/raidstart ]; then
425 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
429 if [ $RESULT -gt 0 -a -x /sbin/raidadd -a -x /sbin/raidrun ]; then
434 if [ $RESULT -gt 0 ]; then
445 # A non-zero return means there were problems.
446 if [ $rc -gt 0 ]; then
447 show "Starting up RAID devices."; fail
450 nls "*** An error occurred during the RAID startup"
451 nls "*** Dropping you to a shell; the system will reboot"
452 nls "*** when you leave the shell."
455 PS1="$(nls '(RAID Repair)# ')"; export PS1
456 if is_yes "$RUN_SULOGIN_ON_ERR"; then
462 run_cmd "Unmounting file systems" umount -a
463 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
464 run_cmd "Automatic reboot in progress" reboot
466 show "Starting up RAID devices."; ok
471 if [ -z "$fastboot" ] && ! grep -q nofsck /proc/cmdline; then
472 show "Checking filesystems"; started
473 initlog -c "fsck -T -R -A -a $fsckoptions"
477 # A return of 2 or higher means there were serious problems.
478 if [ $rc -gt 1 ]; then
481 nls "*** An error occurred during the file system check."
482 nls "*** Dropping you to a shell; the system will reboot"
483 nls "*** when you leave the shell."
486 PS1="$(nls '(Repair filesystem)# ')"; export PS1
487 if is_yes "$RUN_SULOGIN_ON_ERR"; then
493 run_cmd "Unmounting file systems" umount -a
494 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
495 run_cmd "Automatic reboot in progress." reboot
496 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
501 # Mount all other filesystems (except for NFS and /proc, which is already
502 # mounted). Contrary to standard usage,
503 # filesystems are NOT unmounted in single user mode.
504 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs
506 if [ "$_RUN_QUOTACHECK" = "1" -a -x /sbin/quotacheck ]; then
507 if [ -x /sbin/convertquota ]; then
508 # try to convert old quotas
509 for mountpt in $(cat /etc/mtab | awk '$4 ~ /quota/{print $2}'); do
510 if [ -f "$mountpt/quota.user" ]; then
511 /sbin/convertquota -u $mountpt && \
512 rm -f $mountpt/quota.user
514 if [ -f "$mountpt/quota.group" ]; then
515 /sbin/convertquota -g $mountpt && \
516 rm -f $mountpt/quota.group
520 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
524 if [ -x /sbin/quotaon ]; then
525 run_cmd "Turning on user and group quotas for local filesystems" /sbin/quotaon -a
528 # Turn on process accounting
529 if [ -x /sbin/accton ] ; then
530 run_cmd "Turning on process accounting" /sbin/accton /var/log/pacct
533 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
534 if is_yes "$TIME_SETUP_DELAYED"; then
535 if run_cmd "$(nls 'Setting clock')$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
536 show "$(nls 'Today`s date:') $(LC_CTYPE=C date)"; ok
540 # Initialize the serial ports.
541 if [ -f /etc/rc.d/rc.serial ]; then
542 . /etc/rc.d/rc.serial
545 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
546 show 'Setting %s seconds for kernel reboot after panic' "$PANIC_REBOOT_TIME"; busy
547 if (sysctl -w kernel.panic=$PANIC_REBOOT_TIME > /dev/null 2>&1); then ok; else fail; fi
551 rm -f /fastboot /fsckoptions /forcefsck /halt /poweroff
554 # I'd use find, but /usr may not be mounted.
555 for afile in /var/lock/* /var/run/*; do
556 if [ -d "$afile" ]; then
557 bafile=$(basename $afile)
558 [ "$bafile" != "news" -a "$bafile" != "sudo" -a "$bafile" != "mon" ] && rm -f $afile/*
567 if ! is_no "$NEED_XFILES" ; then
570 chown root.utmp /var/run/utmpx /var/log/wtmpx
571 chmod 0664 /var/run/utmpx /var/log/wtmpx
575 chown root.utmp /var/run/utmp /var/log/wtmp
576 chmod 0664 /var/run/utmp /var/log/wtmp
580 if is_yes "$CLEAN_TMP"; then
587 # Delete Postgres sockets
588 rm -f /tmp/.s.PGSQL.*
590 # Right, now turn on swap in case we swap to files.
591 swapon -a >/dev/null 2>&1
592 run_cmd "Enabling swap space" /bin/true
594 # If a SCSI tape has been detected, load the st module unconditionally
595 # since many SCSI tapes don't deal well with st being loaded and unloaded
596 if [ -f /proc/scsi/scsi ] && grep -q 'Type: Sequential-Access' /proc/scsi/scsi 2>/dev/null ; then
597 if grep -qv ' 9 st' /proc/devices ; then
598 if [ -n "$USEMODULES" ] ; then
599 # Try to load the module. If it fails, ignore it...
600 insmod -p st >/dev/null 2>&1 && /sbin/modprobe st >/dev/null 2>&1
605 # Load usb storage here, to match most other things
606 if [ -n "$needusbstorage" ]; then
607 /sbin/modprobe usb-storage >/dev/null 2>&1
610 # If they asked for ide-scsi, load it
611 if grep -q "ide-scsi" /proc/cmdline ; then
612 /sbin/modprobe -k ide-cd >/dev/null 2>&1
613 /sbin/modprobe -k ide-scsi >/dev/null 2>&1
616 # Adjust symlinks as necessary in /boot to keep system services from
617 # spewing messages about mismatched System maps and so on.
618 if [ -L /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
619 ln -s -f System.map-`uname -r` /boot/System.map
621 if [ ! -e /boot/System.map -a -r /boot/System.map-`uname -r` ] ; then
622 ln -s -f System.map-`uname -r` /boot/System.map
625 # there could be a new kernel version. remove old psdevtab database
628 # Now that we have all of our basic modules loaded and the kernel going,
629 # let's dump the syslog ring somewhere so we can find it later
630 dmesg > /var/log/dmesg
631 chmod 640 /var/log/dmesg
634 # Now that we have all of our basic modules loaded and the kernel going,
635 # let's dump the syslog ring somewhere so we can find it later
636 kill -TERM $(/sbin/pidof getkey) >/dev/null 2>&1
638 if is_yes "$PROMPT"; then
639 /sbin/getkey i && touch /var/run/confirm
644 # This must be last line !
645 # vi:syntax=sh:tw=78:ts=8:sw=4