3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.72 2000/11/16 15:58:54 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 -o gid=17 -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 | \
273 awk ' { gsub(/\/lib\/modules\//,NIL); \
274 gsub(/.rhkmvtag/,NIL); \
275 gsub(/[ ].*$/,NIL); \
278 if [ -n "$mver" ]; then
279 ln -sf /lib/modules/$mver /lib/modules/default
283 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
284 ln -sf /boot/module-info-$mver /boot/module-info
285 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
286 ln -sf /boot/System.map-$mver /boot/System.map
289 # a) user requested or RUN_DEPMOD="";
290 # b) modules.dep is missing
291 # c) modules.dep is older than /etc/modules.conf or /lib/modules/$mver
292 if ! is_no "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ]; then
293 if [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] ||\
294 is_yes "$RUN_DEPMOD" || [ -z "$RUN_DEPMOD" ] ||\
295 [ /lib/modules/$mver/modules.dep -ot /etc/modules.conf ] ||\
296 [ /lib/modules/$mver/modules.dep -ot /lib/modules/$mver ]
298 run_cmd "Finding module dependencies" depmod -a
304 if [ -n "$USEMODULES" ] && is_yes "$LOAD_SOUND"; then
305 if grep -s -q "^alias sound-slot-0" /etc/modules.conf ; then
306 run_cmd "Loading sound module" modprobe -s sound-slot-0
308 if grep -s -q "^alias synth0" /etc/modules.conf ; then
309 run_cmd "Loading synthesiser module" modprobe -s synth0
313 if [ -f /proc/sys/kernel/modprobe ]; then
314 # /proc/sys/kernel/modprobe indicates built-in kmod instead
315 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
319 if [ -f /etc/rc.d/rc.modules ]; then
324 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
325 show "Starting up RAID devices."; started
329 for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
331 RAIDDEV=`basename $i`
332 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
333 if [ -z "$RAIDSTAT" ]; then
334 # Try raidstart first...if that fails then
335 # fall back to raid0run.
337 if [ -x /sbin/raidstart ]; then
341 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
347 # A non-zero return means there were problems.
348 if [ $rc -gt 0 ]; then
349 show "Starting up RAID devices."; fail
351 nls "*** An error occurred during the RAID startup"
352 nls "*** Dropping you to a shell; the system will reboot"
353 nls "*** when you leave the shell."
356 PS1="`nls "(RAID Repair)# "`"; export PS1
357 if is_yes "$RUN_SULOGIN_ON_ERR"; then
363 run_cmd "Unmounting file systems" umount -a
364 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
365 run_cmd "Automatic reboot in progress" reboot
367 show "Starting up RAID devices."; ok
371 if [ ! -f /fastboot ]; then
372 show "Checking filesystems."; started
373 initlog -c "fsck -C -T -R -A -a $fsckoptions"
377 # A return of 2 or higher means there were serious problems.
378 if [ $rc -gt 1 ]; then
380 nls "*** An error occurred during the file system check."
381 nls "*** Dropping you to a shell; the system will reboot"
382 nls "*** when you leave the shell."
385 PS1="`nls "(Repair filesystem)# "`"; export PS1
386 if is_yes "$RUN_SULOGIN_ON_ERR"; then
392 run_cmd "Unmounting file systems" umount -a
393 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
394 run_cmd "Automatic reboot in progress." reboot
395 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
396 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
400 # Mount all other filesystems (except for NFS and /proc, which is already
401 # mounted). Contrary to standard usage,
402 # filesystems are NOT unmounted in single user mode.
403 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
405 # Set the clock if timezone definition wasn't available (eg. /usr not mounted)
406 if is_yes "$TIME_SETUP_DELAYED"; then
407 if run_cmd "Setting clock$CLOCKDEF" /sbin/hwclock $CLOCKFLAGS; then
408 show "Today's date: `LC_CTYPE=C date`"; ok
412 if [ -x /sbin/quotaon ]; then
413 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
416 # Initialize the serial ports.
417 if [ -f /etc/rc.d/rc.serial ]; then
418 . /etc/rc.d/rc.serial
421 if [ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ]; then
422 show "`nls "Setting %s seconds for kernel reboot after panic." "$PANIC_REBOOT_TIME"`"; busy
423 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then ok; else fail; fi
426 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
427 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
432 if ! is_no "$NEED_XFILES" ; then
435 chown root.utmp /var/run/utmpx /var/log/wtmpx
436 chmod 0664 /var/run/utmpx /var/log/wtmpx
440 chown root.utmp /var/run/utmp /var/log/wtmp
441 chmod 0664 /var/run/utmp /var/log/wtmp
445 if is_yes "$CLEAN_TMP"; then
449 # Delete UUCP lock files.
452 # Delete stale subsystem files.
453 rm -f /var/lock/subsys/*
455 # Delete stale pam_console locks.
456 rm -f /var/lock/console/*
457 rm -f /var/lock/console.lock
459 # Delete stale pid files
461 rm -f /var/spool/postoffice/.pid.*
466 # Delete Postgres sockets
467 rm -f /tmp/.s.PGSQL.*
469 # Right, now turn on swap in case we swap to files.
470 swapon -a >/dev/null 2>&1
471 run_cmd "Enabling swap space" /bin/true
473 # If a SCSI tape has been detected, load the st module unconditionally
474 # since many SCSI tapes don't deal well with st being loaded and unloaded
475 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
476 if cat /proc/devices | grep -qv ' 9 st' ; then
477 if [ -n "$USEMODULES" ] ; then
478 # Try to load the module. If it fails, ignore it...
479 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
484 # there could be a new kernel version. remove old psdevtab database
487 # If needed increase number of available system files
488 # There are two versions of each setting, because file names
489 # changed between Linux 2.0 and 2.2
490 if [ -n "$VFS_FILE_MAX" ] ; then
491 if [ -f /proc/sys/kernel/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
492 echo $VFS_FILE_MAX >/proc/sys/kernel/file-max
494 if [ -f /proc/sys/fs/file-max -a "$VFS_FILE_MAX" -gt 0 ]; then
495 echo $VFS_FILE_MAX >/proc/sys/fs/file-max
498 if [ -n "$VFS_INODE_MAX" ] ; then
499 if [ -f /proc/sys/kernel/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
500 echo $VFS_INODE_MAX >/proc/sys/kernel/inode-max
502 if [ -f /proc/sys/fs/inode-max -a "$VFS_INODE_MAX" -gt 0 ]; then
503 echo $VFS_INODE_MAX >/proc/sys/fs/inode-max
508 # Now that we have all of our basic modules loaded and the kernel going,
509 # let's dump the syslog ring somewhere so we can find it later
510 dmesg > /var/log/dmesg
511 chmod 640 /var/log/dmesg
513 # Now that we have all of our basic modules loaded and the kernel going,
514 # let's dump the syslog ring somewhere so we can find it later
515 kill -TERM `/sbin/pidof getkey` >/dev/null 2>&1
517 if is_yes "$PROMPT"; then
518 /sbin/getkey i && touch /var/run/confirm
522 # This must be last line !
523 # vi:syntax=sh:tw=78:ts=8:sw=4