3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.67 2000/07/13 14:45:10 baggins 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
30 . /etc/rc.d/init.d/functions
32 # Read network config data.
33 if [ -f /etc/sysconfig/network ]; then
34 . /etc/sysconfig/network
40 # Read system config data.
41 if [ -f /etc/sysconfig/system ]; then
42 . /etc/sysconfig/system
44 RUN_SULOGIN_ON_ERR=yes
55 # Print welcome message
56 echo -e "\t\t\t`termput setaf 6`Powered by `termput setaf 2`PLD GNU/Linux`termput setaf 7`"
57 if is_yes "$PROMPT"; then
58 echo -en "\t\t`nls "Press"` '`termput setaf 1`I`termput setaf 7`' `nls "to enter interactive startup."`"
63 # we need /proc mounted before everything
64 mount -n -t proc /proc /proc
66 # /dev must be also mounted before everything but only if we want use them ;-)
67 if is_yes "$MOUNT_DEVFS"; then
68 run_cmd "Mounting Device Filesystem" mount -n -t devfs /dev /dev
72 if is_yes "$RUN_DEVFSD"; then
73 if [ -x /sbin/devfsd -a -f /etc/devfsd.conf ]; then
74 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
78 # Set console loglevel
79 /bin/dmesg -n $CONSOLE_LOGLEVEL
82 if [ -f /proc/sys/kernel/sysrq ] && is_no "$MAGIC_SYSRQ"; then
83 echo "0" > /proc/sys/kernel/sysrq
84 run_cmd "Turning off Magic SysRq key" /bin/true
88 if [ -f /proc/sys/kernel/stop-a ] && is_no "$STOP_A"; then
89 echo "0" > /proc/sys/kernel/stop-a
90 run_cmd "Turning off Stop-A/Break-A" /bin/true
93 # Set the system clock.
98 if [ -f /etc/sysconfig/clock ]; then
99 . /etc/sysconfig/clock
101 # convert old style clock config to new values
102 if [ "${CLOCKMODE}" = "GMT" ]; then
104 elif [ "${CLOCKMODE}" = "ARC" ]; then
109 if grep "system serial" /proc/cpuinfo | grep -q MILO ; then
114 CLOCKFLAGS="--hctosys"
118 CLOCKFLAGS="$CLOCKFLAGS -u";
119 CLOCKDEF="$CLOCKDEF (utc)";
125 CLOCKFLAGS="$CLOCKFLAGS -A";
126 CLOCKDEF="$CLOCKDEF (arc)";
131 CLOCKFLAGS="$CLOCKFLAGS -S";
132 CLOCKDEF="$CLOCKDEF (srm)";
136 # Check if timezone definition is available
137 if [ -e /etc/localtime ] ; then
138 if run_cmd "Setting clock$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
139 show "Today's date: `LC_CTYPE=C date`"; ok
142 TIME_SETUP_DELAYED=yes
146 run_cmd "`nls "Activating swap partitions"`" swapon -a
149 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
151 # Set the NIS domain name
152 if [ -n "$NISDOMAIN" ]; then
153 run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
158 # Setup hdparm thingy (if exists)
159 [ -x /etc/rc.d/rc.hdparm ] && /etc/rc.d/rc.hdparm
161 if [ -f /fsckoptions ]; then
162 fsckoptions=`cat /fsckoptions`
167 if [ -f /forcefsck ]; then
168 fsckoptions="-f $fsckoptions"
172 if awk '{ if ($2 ~ /^\/$/ && ( $3 ~ /^(nfs|romfs)$/ || $6 ~ /^0$/ ) ) exit 1 ; else exit 0}' /etc/fstab; then
174 if [ ! -f /fastboot ]; then
175 show "Checking root filesystems."; started
176 initlog -c "fsck -C -T -a $fsckoptions /"
180 # A return of 2 or higher means there were serious problems.
181 if [ $rc -gt 1 ]; then
182 # don't use '\n' in nls macro !
184 nls "*** An error occurred during the file system check."
185 nls "*** Dropping you to a shell; the system will reboot"
186 nls "*** when you leave the shell."
189 PS1="`nls "(Repair filesystem)# "`"; export PS1
190 if is_yes "$RUN_SULOGIN_ON_ERR"; then
196 run_cmd "Unmounting file systems" umount -a
197 mount -n -o remount,ro /
198 run_cmd "Automatic reboot in progress." reboot
199 elif [ "$rc" = "1" ]; then
206 # check for arguments
207 if grep -i nopnp /proc/cmdline >/dev/null ; then
214 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
215 if [ -n "$PNP" ] && is_yes "$RUN_ISAPNP"; then
216 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
221 # Remount the root filesystem read-write.
222 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
224 # Update quotas if fsck was run on /.
225 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ]; then
226 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
229 # /etc/nologin when starting system
230 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
232 if is_yes "$DELAY_LOGIN" && [ ! -f /etc/nologin ]; then
233 show "Enabling Delay Login"; busy
235 nls "System bootup in progress - please wait" >> /etc/nologin
237 chmod 644 /etc/nologin
238 cp -fp /etc/nologin /etc/nologin.boot
242 echo ${HOSTNAME} > /etc/HOSTNAME
247 # Enter root and /proc into mtab.
251 if [ ! -f /proc/modules ]; then
253 elif ! grep -i nomodules /proc/cmdline >/dev/null ; then
259 # Kernel dependent links
260 rm -f /lib/modules/preferred
261 rm -f /lib/modules/default
262 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
263 if is_yes "$SET_SLINKS"; then
264 # Get ready for kmod if module support in the kernel
265 if [ -z `uname -r | grep "-"` ]; then
266 # we're using a new kernel, no preferred needed
269 ktag="`cat /proc/version`"
270 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
271 if [ -n "$mtag" ]; then
272 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's, \
273 /.rhkmvtag,,' -e 's,[ ].*$,,'
275 if [ -n "$mver" ]; then
276 ln -sf /lib/modules/$mver /lib/modules/default
280 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
281 ln -sf /boot/module-info-$mver /boot/module-info
282 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
283 ln -sf /boot/System.map-$mver /boot/System.map
286 # a) user requested or RUN_DEPMOD="";
287 # b) modules.dep is missing
288 # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
289 if ! is_no "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
290 if [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
291 is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] ||\
292 [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
293 [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]
295 run_cmd "Finding module dependencies" depmod -a
301 if [ -n "$USEMODULES" ] && is_yes "$LOAD_SOUND"; then
302 if grep -s -q "^alias sound-slot-0" /etc/modules.conf ; then
303 run_cmd "Loading sound module" modprobe -s sound-slot-0
305 if grep -s -q "^alias synth0" /etc/modules.conf ; then
306 run_cmd "Loading synthesiser module" modprobe -s synth0
310 if [ -f /proc/sys/kernel/modprobe ]; then
311 # /proc/sys/kernel/modprobe indicates built-in kmod instead
312 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
316 if [ -f /etc/rc.d/rc.modules ]; then
321 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
322 show "Starting up RAID devices."; started
326 for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
328 RAIDDEV=`basename $i`
329 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
330 if [ -z "$RAIDSTAT" ]; then
331 # Try raidstart first...if that fails then
332 # fall back to raid0run.
334 if [ -x /sbin/raidstart ]; then
338 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
344 # A non-zero return means there were problems.
345 if [ $rc -gt 0 ]; then
346 show "Starting up RAID devices."; fail
348 nls "*** An error occurred during the RAID startup"
349 nls "*** Dropping you to a shell; the system will reboot"
350 nls "*** when you leave the shell."
353 PS1="`nls "(RAID Repair)# "`"; export PS1
354 if is_yes "$RUN_SULOGIN_ON_ERR"; then
360 run_cmd "Unmounting file systems" umount -a
361 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
362 run_cmd "Automatic reboot in progress" reboot
364 show "Starting up RAID devices."; ok
368 if [ ! -f /fastboot ]; then
369 show "Checking filesystems."; started
370 initlog -c "fsck -C -T -R -A -a $fsckoptions"
374 # A return of 2 or higher means there were serious problems.
375 if [ $rc -gt 1 ]; then
377 nls "*** An error occurred during the file system check."
378 nls "*** Dropping you to a shell; the system will reboot"
379 nls "*** when you leave the shell."
382 PS1="`nls "(Repair filesystem)# "`"; export PS1
383 if is_yes "$RUN_SULOGIN_ON_ERR"; then
389 run_cmd "Unmounting file systems" umount -a
390 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
391 run_cmd "Automatic reboot in progress." reboot
392 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
393 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
397 # Mount all other filesystems (except for NFS and /proc, which is already
398 # mounted). Contrary to standard usage,
399 # filesystems are NOT unmounted in single user mode.
400 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
402 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
403 if is_yes "$TIME_SETUP_DELAYED"; then
404 if run_cmd "Setting clock$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
405 show "Today's date: `LC_CTYPE=C date`"; ok
409 if [ -x /sbin/quotaon ]; then
410 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
413 # Initialize the serial ports.
414 if [ -f /etc/rc.d/rc.serial ]; then
415 . /etc/rc.d/rc.serial
418 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
419 show "`nls "Setting %s seconds for kernel reboot after panic." "$PANIC_REBOOT_TIME"`"; busy
420 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then ok; else fail; fi
423 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
424 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
428 if [ ! is_no "$NEED_XFILES" ]; then
431 chown root.utmp /var/run/utmpx /var/log/wtmpx
432 chmod 0664 /var/run/utmpx /var/log/wtmpx
436 chown root.utmp /var/run/utmp /var/log/wtmp
437 chmod 0664 /var/run/utmp /var/log/wtmp
441 if is_yes "$CLEAN_TMP"; then
445 # Delete UUCP lock files.
448 # Delete stale subsystem files.
449 rm -f /var/lock/subsys/*
451 # Delete stale pam_console locks.
452 rm -f /var/lock/console/*
453 rm -f /var/lock/console.lock
455 # Delete stale pid files
457 rm -f /var/spool/postoffice/.pid.*
462 # Delete Postgres sockets
463 rm -f /tmp/.s.PGSQL.*
465 # Right, now turn on swap in case we swap to files.
466 swapon -a >/dev/null 2>&1
467 run_cmd "Enabling swap space" /bin/true
469 # If a SCSI tape has been detected, load the st module unconditionally
470 # since many SCSI tapes don't deal well with st being loaded and unloaded
471 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
472 if cat /proc/devices | grep -qv ' 9 st' ; then
473 if [ -n "$USEMODULES" ] ; then
474 # Try to load the module. If it fails, ignore it...
475 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
480 # there could be a new kernel version. remove old psdevtab database
483 # If needed increase number of available system files
484 # There are two versions of each setting, because file names
485 # changed between Linux 2.0 and 2.2
486 if [ -n "$VFS_FILE_MAX" ] ; then
487 if [ -f /proc/sys/kernel/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
488 echo $VFS_FILE_MAX >/proc/sys/kernel/file-max
490 if [ -f /proc/sys/fs/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
491 echo $VFS_FILE_MAX >/proc/sys/fs/file-max
494 if [ -n "$VFS_INODE_MAX" ] ; then
495 if [ -f /proc/sys/kernel/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
496 echo $VFS_INODE_MAX >/proc/sys/kernel/inode-max
498 if [ -f /proc/sys/fs/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
499 echo $VFS_INODE_MAX >/proc/sys/fs/inode-max
504 # Now that we have all of our basic modules loaded and the kernel going,
505 # let's dump the syslog ring somewhere so we can find it later
506 dmesg > /var/log/dmesg
507 chmod 640 /var/log/dmesg
509 # Now that we have all of our basic modules loaded and the kernel going,
510 # let's dump the syslog ring somewhere so we can find it later
511 kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1
513 if is_yes "$PROMPT"; then
514 /sbin/getkey i && touch /var/run/confirm