3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.42 2000/01/05 01:18:01 kloczek 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 nls "\n\n*** An error occurred during the file system check.\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
101 PS1="`nls "(Repair filesystem) #"`"; export PS1
102 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
108 run_cmd "Unmounting file systems" umount -a
109 mount -n -o remount,ro /
110 run_cmd "Automatic reboot in progress." reboot
111 elif [ "$rc" = "1" ]; then
116 # check for arguments
117 if grep -i nopnp /proc/cmdline >/dev/null ; then
124 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
125 if [ -n "$PNP" -a "$RUN_ISAPNP" = "yes" ]; then
126 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
130 # Remount the root filesystem read-write.
131 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
133 # Update quotas if fsck was run on /.
134 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck -a ! -n "$NFSROOT" ]; then
135 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
138 # /etc/nologin when starting system
139 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
141 if [ "$DELAY_LOGIN" = "yes" -a ! -f /etc/nologin ]; then
142 show "Enabling Delay Login"; busy
144 nls "System bootup in progress - please wait" >> /etc/nologin
146 chmod 644 /etc/nologin
147 cp -fp /etc/nologin /etc/nologin.boot
151 echo ${HOSTNAME} > /etc/HOSTNAME
156 # Enter root and /proc into mtab.
160 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
166 # Kernel dependent links
167 rm -f /lib/modules/preferred
168 rm -f /lib/modules/default
169 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
170 if [ "$SET_SLINKS" != "no" ]; then
171 # Get ready for kmod if module support in the kernel
172 if [ -z `uname -r | grep "-"` ]; then
173 # we're using a new kernel, no preferred needed
176 ktag="`cat /proc/version`"
177 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
178 if [ -n "$mtag" ]; then
179 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's, \
180 /.rhkmvtag,,' -e 's,[ ].*$,,'
182 if [ -n "$mver" ]; then
183 ln -sf /lib/modules/$mver /lib/modules/default
187 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && \
188 ln -sf /boot/module-info-$mver /boot/module-info
189 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && \
190 ln -sf /boot/System.map-$mver /boot/System.map
192 show "Finding module dependencies"; busy
193 if (depmod -a 2>&1 | grep -q nresolved) then
201 if [ -n "$USEMODULES" -a "$LOAD_SOUND" = "yes" ]; then
202 if grep -s -q "^alias sound" /etc/modules.conf ; then
203 run_cmd "Loading sound module" modprobe -s sound
205 if grep -s -q "^alias midi" /etc/modules.conf ; then
206 run_cmd "Loading midi module" modprobe -s midi
210 if [ -f /proc/sys/kernel/modprobe ]; then
211 # /proc/sys/kernel/modprobe indicates built-in kmod instead
212 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
216 if [ -f /etc/rc.d/rc.modules ]; then
221 if [ -f /proc/mdstat -a -f /etc/raidtab ]; then
222 show "Starting up RAID devices."; started
226 for i in `grep "raiddev" /etc/raidtab | awk '{print $2}'`
228 RAIDDEV=`basename $i`
229 RAIDSTAT=`grep "^$RAIDDEV : active" /proc/mdstat`
230 if [ -z "$RAIDSTAT" ]; then
231 # Try raidstart first...if that fails then
232 # fall back to raid0run.
234 if [ -x /sbin/raidstart ]; then
238 if [ $RESULT -gt 0 -a -x /sbin/raid0run ]; then
244 # A non-zero return means there were problems.
245 if [ $rc -gt 0 ]; then
246 show "Starting up RAID devices."; fail
247 nls "\n\n*** An error occurred during the RAID startup\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
249 PS1="`nls "(RAID Repair) #"`"; export PS1
250 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
256 run_cmd "Unmounting file systems" umount -a
257 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
258 run_cmd "Automatic reboot in progress" reboot
260 show "Starting up RAID devices."; ok
264 if [ ! -f /fastboot ]; then
265 show "Checking filesystems."; started
266 initlog -c "fsck -C -T -R -A -a $fsckoptions"
270 # A return of 2 or higher means there were serious problems.
271 if [ $rc -gt 1 ]; then
272 nls "\n\n*** An error occurred during the file system check.\n*** Dropping you to a shell; the system will reboot\n*** when you leave the shell.\n"
274 PS1="`nls "(Repair filesystem) #"`"; export PS1
275 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
281 run_cmd "Unmounting file systems" umount -a
282 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
283 run_cmd "Automatic reboot in progress." reboot
284 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
285 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
289 # Mount all other filesystems (except for NFS and /proc, which is already
290 # mounted). Contrary to standard usage,
291 # filesystems are NOT unmounted in single user mode.
292 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
294 # set the console font
295 #if [ -x /sbin/setsysfont ]; then
296 # show "Loading default system font"; busy
297 # if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
300 if [ -x /sbin/quotaon ]; then
301 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
304 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
305 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
308 chown root.utmp /var/run/utmpx
309 chmod 0664 /var/run/utmpx
312 if [ "$CLEAN_TMP" = "yes" ]; then
316 # Delete UUCP lock files.
319 # Delete stale subsystem files.
320 rm -f /var/lock/subsys/*
322 # Delete stale pam_console locks.
323 rm -f /var/lock/console/*
324 rm -f /var/lock/console.lock
326 # Delete stale pid files
328 rm -f /var/spool/postoffice/.pid.*
333 # Delete Postgres sockets
334 rm -f /tmp/.s.PGSQL.*
336 # Set the system clock.
337 show "Setting clock"; busy
341 if [ -f /etc/sysconfig/clock ]; then
342 . /etc/sysconfig/clock
344 # convert old style clock config to new values
345 if [ "${CLOCKMODE}" = "GMT" ]; then
347 elif [ "${CLOCKMODE}" = "ARC" ]; then
352 if [ -x /sbin/hwclock ]; then
353 CLOCKFLAGS="--hctosys"
362 CLOCKFLAGS="$CLOCKFLAGS -u";
369 CLOCKFLAGS="$CLOCKFLAGS -A";
375 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
377 show "`nls "Date set to"` `date`"; ok
379 # Right, now turn on swap in case we swap to files.
380 swapon -a >/dev/null 2>&1
381 run_cmd "Enabling swap space" /bin/true
382 #show "Enabling swap space"; busy
383 #if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" = "" ]; then
389 # Initialize the serial ports.
390 if [ -f /etc/rc.d/rc.serial ]; then
391 . /etc/rc.d/rc.serial
394 # If a SCSI tape has been detected, load the st module unconditionally
395 # since many SCSI tapes don't deal well with st being loaded and unloaded
396 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
397 if cat /proc/devices | grep -qv ' 9 st' ; then
398 if [ -n "$USEMODULES" ] ; then
399 # Try to load the module. If it fails, ignore it...
400 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
405 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
407 #if [ -x /bin/ps ]; then
408 #show "Rebuilding /etc/psdevtab database"; busy
409 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
412 if ([ -f /proc/sys/kernel/panic -a "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
413 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
414 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
417 # Now that we have all of our basic modules loaded and the kernel going,
418 # let's dump the syslog ring somewhere so we can find it later
419 dmesg > /var/log/dmesg
420 chmod 640 /var/log/dmesg
422 # Feed entropy into the entropy pool
423 /etc/rc.d/init.d/random start