3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.48 2000/02/28 12:50:45 misiek 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/Linux`termput setaf 7`"
59 if [ -x /sbin/devfsd -a -f /etc/devfsd.conf ]; then
60 if [ "$RUN_DEVFSD" = "yes" ]; then
61 run_cmd "Starting Device Filesystem Daemon" /sbin/devfsd /dev
65 # Set console loglevel
66 /bin/dmesg -n $CONSOLE_LOGLEVEL
68 # we need /proc mounted before starting fsck
69 mount -n -t proc /proc /proc
72 run_cmd "`nls "Activating swap partitions"`" swapon -a
75 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
77 # Set the NIS domain name
78 if [ -n "$NISDOMAIN" ]; then
79 run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
84 if [ -f /fsckoptions ]; then
85 fsckoptions=`cat /fsckoptions`
90 if [ -f /forcefsck ]; then
91 fsckoptions="-f $fsckoptions"
95 NFSROOT=`cat /proc/mounts | awk '{ if ($2 ~ /^\/$/ && $3 ~ /^nfs$/) print $3 }'`
98 if [ ! -f /fastboot -a ! -n "$NFSROOT" ]; then
99 show "Checking root filesystems."; started
100 initlog -c "fsck -C -T -a $fsckoptions /"
104 # A return of 2 or higher means there were serious problems.
105 if [ $rc -gt 1 ]; then
106 # don't use '\n' in nls macro !
108 nls "*** An error occurred during the file system check."
109 nls "*** Dropping you to a shell; the system will reboot"
110 nls "*** when you leave the shell."
113 PS1="`nls "(Repair filesystem)# "`"; export PS1
114 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
120 run_cmd "Unmounting file systems" umount -a
121 mount -n -o remount,ro /
122 run_cmd "Automatic reboot in progress." reboot
123 elif [ "$rc" = "1" ]; then
128 # check for arguments
129 if grep -i nopnp /proc/cmdline >/dev/null ; then
136 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
137 if [ -n "$PNP" -a "$RUN_ISAPNP" = "yes" ]; then
138 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
143 # Remount the root filesystem read-write.
144 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
146 # Update quotas if fsck was run on /.
147 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck -a ! -n "$NFSROOT" ]; then
148 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
151 # /etc/nologin when starting system
152 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
154 if [ "$DELAY_LOGIN" = "yes" -a ! -f /etc/nologin ]; then
155 show "Enabling Delay Login"; busy
157 nls "System bootup in progress - please wait" >> /etc/nologin
159 chmod 644 /etc/nologin
160 cp -fp /etc/nologin /etc/nologin.boot
164 echo ${HOSTNAME} > /etc/HOSTNAME
169 # Enter root and /proc into mtab.
173 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
179 # Kernel dependent links
180 rm -f /lib/modules/preferred
181 rm -f /lib/modules/default
182 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
183 if [ "$SET_SLINKS" != "no" ]; then
184 # Get ready for kmod if module support in the kernel
185 if [ -z `uname -r | grep "-"` ]; then
186 # we're using a new kernel, no preferred needed
189 ktag="`cat /proc/version`"
190 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
191 if [ -n "$mtag" ]; then
192 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's, \
193 /.rhkmvtag,,' -e 's,[ ].*$,,'
195 if [ -n "$mver" ]; then
196 ln -sf /lib/modules/$mver /lib/modules/default
200 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
201 ln -sf /boot/module-info-$mver /boot/module-info
202 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
203 ln -sf /boot/System.map-$mver /boot/System.map
205 # Run depmod if: a) user requested; b) modules.dep is missing
206 # c) modules.dep is older than /etc/modules.conf
207 if [ "$RUN_DEPMOD" != "no" ]; then
208 if [ "$RUN_DEPMOD" = "ifmissing" -a ! -r /lib/modules/$mver/modules.dep ] || (find /lib/modules/$mver/ -name modules.dep ! -newer /etc/modules.conf -print 2>&1 | grep -q "modules.dep"); then
209 run_cmd "Finding module dependencies" depmod -a
215 if [ -n "$USEMODULES" -a "$LOAD_SOUND" = "yes" ]; then
216 if grep -s -q "^alias sound" /etc/modules.conf ; then
217 run_cmd "Loading sound module" modprobe -s sound
219 if grep -s -q "^alias midi" /etc/modules.conf ; then
220 run_cmd "Loading midi module" modprobe -s midi
224 if [ -f /proc/sys/kernel/modprobe ]; then
225 # /proc/sys/kernel/modprobe indicates built-in kmod instead
226 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
230 if [ -f /etc/rc.d/rc.modules ]; then
235 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
236 show "Starting up RAID devices."; started
240 for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
242 RAIDDEV=`basename $i`
243 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
244 if [ -z "$RAIDSTAT" ]; then
245 # Try raidstart first...if that fails then
246 # fall back to raid0run.
248 if [ -x /sbin/raidstart ]; then
252 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
258 # A non-zero return means there were problems.
259 if [ $rc -gt 0 ]; then
260 show "Starting up RAID devices."; fail
262 nls "*** An error occurred during the RAID startup"
263 nls "*** Dropping you to a shell; the system will reboot"
264 nls "*** when you leave the shell."
267 PS1="`nls "(RAID Repair)# "`"; export PS1
268 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
274 run_cmd "Unmounting file systems" umount -a
275 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
276 run_cmd "Automatic reboot in progress" reboot
278 show "Starting up RAID devices."; ok
282 if [ ! -f /fastboot ]; then
283 show "Checking filesystems."; started
284 initlog -c "fsck -C -T -R -A -a $fsckoptions"
288 # A return of 2 or higher means there were serious problems.
289 if [ $rc -gt 1 ]; then
291 nls "*** An error occurred during the file system check."
292 nls "*** Dropping you to a shell; the system will reboot"
293 nls "*** when you leave the shell."
296 PS1="`nls "(Repair filesystem)# "`"; export PS1
297 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
303 run_cmd "Unmounting file systems" umount -a
304 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
305 run_cmd "Automatic reboot in progress." reboot
306 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
307 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
311 # Mount all other filesystems (except for NFS and /proc, which is already
312 # mounted). Contrary to standard usage,
313 # filesystems are NOT unmounted in single user mode.
314 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
316 # set the console font
317 #if [ -x /sbin/setsysfont ]; then
318 # show "Loading default system font"; busy
319 # if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
322 if [ -x /sbin/quotaon ]; then
323 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
326 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
327 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
330 chown root.utmp /var/run/utmpx
331 chmod 0664 /var/run/utmpx
334 if [ "$CLEAN_TMP" = "yes" ]; then
338 # Delete UUCP lock files.
341 # Delete stale subsystem files.
342 rm -f /var/lock/subsys/*
344 # Delete stale pam_console locks.
345 rm -f /var/lock/console/*
346 rm -f /var/lock/console.lock
348 # Delete stale pid files
350 rm -f /var/spool/postoffice/.pid.*
355 # Delete Postgres sockets
356 rm -f /tmp/.s.PGSQL.*
358 # Set the system clock.
359 show "Setting clock"; busy
363 if [ -f /etc/sysconfig/clock ]; then
364 . /etc/sysconfig/clock
366 # convert old style clock config to new values
367 if [ "${CLOCKMODE}" = "GMT" ]; then
369 elif [ "${CLOCKMODE}" = "ARC" ]; then
374 if [ -x /sbin/hwclock ]; then
375 CLOCKFLAGS="--hctosys"
384 CLOCKFLAGS="$CLOCKFLAGS -u";
391 CLOCKFLAGS="$CLOCKFLAGS -A";
397 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
399 show "`nls "Date set to"` `date`"; ok
401 # Right, now turn on swap in case we swap to files.
402 swapon -a >/dev/null 2>&1
403 run_cmd "Enabling swap space" /bin/true
404 #show "Enabling swap space"; busy
405 #if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" = "" ]; then
411 # Initialize the serial ports.
412 if [ -f /etc/rc.d/rc.serial ]; then
413 . /etc/rc.d/rc.serial
416 # If a SCSI tape has been detected, load the st module unconditionally
417 # since many SCSI tapes don't deal well with st being loaded and unloaded
418 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
419 if cat /proc/devices | grep -qv ' 9 st' ; then
420 if [ -n "$USEMODULES" ] ; then
421 # Try to load the module. If it fails, ignore it...
422 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
427 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
429 #if [ -x /bin/ps ]; then
430 #show "Rebuilding /etc/psdevtab database"; busy
431 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
434 if ([ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
435 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
436 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
439 # Now that we have all of our basic modules loaded and the kernel going,
440 # let's dump the syslog ring somewhere so we can find it later
441 dmesg > /var/log/dmesg
442 chmod 640 /var/log/dmesg
444 # Feed entropy into the entropy pool
445 /etc/rc.d/init.d/random start