3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.43 2000/01/31 14:29:38 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`"
58 # Set console loglevel
59 /bin/dmesg -n $CONSOLE_LOGLEVEL
61 # we need /proc mounted before starting fsck
62 mount -n -t proc /proc /proc
65 run_cmd "`nls "Activating swap partitions"`" swapon -a
68 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
70 # Set the NIS domain name
71 if [ -n "$NISDOMAIN" ]; then
72 run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
77 if [ -f /fsckoptions ]; then
78 fsckoptions=`cat /fsckoptions`
83 if [ -f /forcefsck ]; then
84 fsckoptions="-f $fsckoptions"
88 NFSROOT=`cat /proc/mounts | awk '{ if ($2 ~ /^\/$/ && $3 ~ /^nfs$/) print $3 }'`
91 if [ ! -f /fastboot -a ! -n "$NFSROOT" ]; then
92 show "Checking root filesystems."; started
93 initlog -c "fsck -C -T -a $fsckoptions /"
97 # A return of 2 or higher means there were serious problems.
98 if [ $rc -gt 1 ]; then
99 # don't use '\n' in nls macro !
101 nls "*** An error occurred during the file system check."
102 nls "*** Dropping you to a shell; the system will reboot"
103 nls "*** when you leave the shell."
106 PS1="`nls "(Repair filesystem) #"`"; export PS1
107 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
113 run_cmd "Unmounting file systems" umount -a
114 mount -n -o remount,ro /
115 run_cmd "Automatic reboot in progress." reboot
116 elif [ "$rc" = "1" ]; then
121 # check for arguments
122 if grep -i nopnp /proc/cmdline >/dev/null ; then
129 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
130 if [ -n "$PNP" -a "$RUN_ISAPNP" = "yes" ]; then
131 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
135 # Remount the root filesystem read-write.
136 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
138 # Update quotas if fsck was run on /.
139 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck -a ! -n "$NFSROOT" ]; then
140 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
143 # /etc/nologin when starting system
144 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
146 if [ "$DELAY_LOGIN" = "yes" -a ! -f /etc/nologin ]; then
147 show "Enabling Delay Login"; busy
149 nls "System bootup in progress - please wait" >> /etc/nologin
151 chmod 644 /etc/nologin
152 cp -fp /etc/nologin /etc/nologin.boot
156 echo ${HOSTNAME} > /etc/HOSTNAME
161 # Enter root and /proc into mtab.
165 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
171 # Kernel dependent links
172 rm -f /lib/modules/preferred
173 rm -f /lib/modules/default
174 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
175 if [ "$SET_SLINKS" != "no" ]; then
176 # Get ready for kmod if module support in the kernel
177 if [ -z `uname -r | grep "-"` ]; then
178 # we're using a new kernel, no preferred needed
181 ktag="`cat /proc/version`"
182 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
183 if [ -n "$mtag" ]; then
184 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's, \
185 /.rhkmvtag,,' -e 's,[ ].*$,,'
187 if [ -n "$mver" ]; then
188 ln -sf /lib/modules/$mver /lib/modules/default
192 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
193 ln -sf /boot/module-info-$mver /boot/module-info
194 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
195 ln -sf /boot/System.map-$mver /boot/System.map
197 show "Finding module dependencies"; busy
198 if (depmod -a 2>&1 | grep -q nresolved) then
206 if [ -n "$USEMODULES" -a "$LOAD_SOUND" = "yes" ]; then
207 if grep -s -q "^alias sound" /etc/modules.conf ; then
208 run_cmd "Loading sound module" modprobe -s sound
210 if grep -s -q "^alias midi" /etc/modules.conf ; then
211 run_cmd "Loading midi module" modprobe -s midi
215 if [ -f /proc/sys/kernel/modprobe ]; then
216 # /proc/sys/kernel/modprobe indicates built-in kmod instead
217 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
221 if [ -f /etc/rc.d/rc.modules ]; then
226 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
227 show "Starting up RAID devices."; started
231 for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
233 RAIDDEV=`basename $i`
234 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
235 if [ -z "$RAIDSTAT" ]; then
236 # Try raidstart first...if that fails then
237 # fall back to raid0run.
239 if [ -x /sbin/raidstart ]; then
243 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
249 # A non-zero return means there were problems.
250 if [ $rc -gt 0 ]; then
251 show "Starting up RAID devices."; fail
253 nls "*** An error occurred during the RAID startup"
254 nls "*** Dropping you to a shell; the system will reboot"
255 nls "*** when you leave the shell."
258 PS1="`nls "(RAID Repair) #"`"; export PS1
259 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
265 run_cmd "Unmounting file systems" umount -a
266 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
267 run_cmd "Automatic reboot in progress" reboot
269 show "Starting up RAID devices."; ok
273 if [ ! -f /fastboot ]; then
274 show "Checking filesystems."; started
275 initlog -c "fsck -C -T -R -A -a $fsckoptions"
279 # A return of 2 or higher means there were serious problems.
280 if [ $rc -gt 1 ]; then
282 nls "*** An error occurred during the file system check."
283 nls "*** Dropping you to a shell; the system will reboot"
284 nls "*** when you leave the shell."
287 PS1="`nls "(Repair filesystem) #"`"; export PS1
288 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
294 run_cmd "Unmounting file systems" umount -a
295 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
296 run_cmd "Automatic reboot in progress." reboot
297 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
298 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
302 # Mount all other filesystems (except for NFS and /proc, which is already
303 # mounted). Contrary to standard usage,
304 # filesystems are NOT unmounted in single user mode.
305 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
307 # set the console font
308 #if [ -x /sbin/setsysfont ]; then
309 # show "Loading default system font"; busy
310 # if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
313 if [ -x /sbin/quotaon ]; then
314 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
317 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
318 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
321 chown root.utmp /var/run/utmpx
322 chmod 0664 /var/run/utmpx
325 if [ "$CLEAN_TMP" = "yes" ]; then
329 # Delete UUCP lock files.
332 # Delete stale subsystem files.
333 rm -f /var/lock/subsys/*
335 # Delete stale pam_console locks.
336 rm -f /var/lock/console/*
337 rm -f /var/lock/console.lock
339 # Delete stale pid files
341 rm -f /var/spool/postoffice/.pid.*
346 # Delete Postgres sockets
347 rm -f /tmp/.s.PGSQL.*
349 # Set the system clock.
350 show "Setting clock"; busy
354 if [ -f /etc/sysconfig/clock ]; then
355 . /etc/sysconfig/clock
357 # convert old style clock config to new values
358 if [ "${CLOCKMODE}" = "GMT" ]; then
360 elif [ "${CLOCKMODE}" = "ARC" ]; then
365 if [ -x /sbin/hwclock ]; then
366 CLOCKFLAGS="--hctosys"
375 CLOCKFLAGS="$CLOCKFLAGS -u";
382 CLOCKFLAGS="$CLOCKFLAGS -A";
388 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
390 show "`nls "Date set to"` `date`"; ok
392 # Right, now turn on swap in case we swap to files.
393 swapon -a >/dev/null 2>&1
394 run_cmd "Enabling swap space" /bin/true
395 #show "Enabling swap space"; busy
396 #if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" = "" ]; then
402 # Initialize the serial ports.
403 if [ -f /etc/rc.d/rc.serial ]; then
404 . /etc/rc.d/rc.serial
407 # If a SCSI tape has been detected, load the st module unconditionally
408 # since many SCSI tapes don't deal well with st being loaded and unloaded
409 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
410 if cat /proc/devices | grep -qv ' 9 st' ; then
411 if [ -n "$USEMODULES" ] ; then
412 # Try to load the module. If it fails, ignore it...
413 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
418 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
420 #if [ -x /bin/ps ]; then
421 #show "Rebuilding /etc/psdevtab database"; busy
422 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
425 if ([ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
426 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
427 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
430 # Now that we have all of our basic modules loaded and the kernel going,
431 # let's dump the syslog ring somewhere so we can find it later
432 dmesg > /var/log/dmesg
433 chmod 640 /var/log/dmesg
435 # Feed entropy into the entropy pool
436 /etc/rc.d/init.d/random start