3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.14 1999/07/15 13:29:43 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 . /etc/rc.d/init.d/functions
17 # Read network config data.
18 if [ -f /etc/sysconfig/network ]; then
19 . /etc/sysconfig/network
25 # Read system config data.
26 if [ -f /etc/sysconfig/system ]; then
27 . /etc/sysconfig/system
29 RUN_SULOGIN_ON_ERR=yes
38 # Set console loglevel
39 /sbin/loglevel $CONSOLE_LOGLEVEL
42 run_cmd "Activating swap partitions" swapon -a
45 run_cmd "Host: ${HOSTNAME}" hostname ${HOSTNAME}
47 # Set the NIS domain name
48 if [ -n "$NISDOMAIN" ]; then
49 run_cmd "NIS Domain: ${NISDOMAIN}" domainname $NISDOMAIN
54 if [ -f /fsckoptions ]; then
55 fsckoptions=`cat /fsckoptions`
60 if [ -f /forcefsck ]; then
61 fsckoptions="-f $fsckoptions"
64 # we need /proc mounted before starting fsck
65 mount -t proc /proc /proc
68 if [ ! -f /fastboot ]; then
69 show "Checking root filesystems."; started
70 initlog -c "fsck -T -a $fsckoptions /"
74 # A return of 2 or higher means there were serious problems.
75 if [ $rc -gt 1 ]; then
78 echo "*** An error occurred during the file system check."
79 echo "*** Dropping you to a shell; the system will reboot"
80 echo "*** when you leave the shell."
82 PS1='(Repair filesystem) #'; export PS1
83 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
89 run_cmd "Unmounting file systems" umount -a
90 mount -n -o remount,ro /
91 run_cmd "Automatic reboot in progress." reboot
92 elif [ "$rc" == "1" ]; then
97 if [ -x /sbin/quotaon ]; then
98 run_cmd "Turning on quotas on root filesystem" /sbin/quotaon /
101 # check for arguments
102 if grep -i nopnp /proc/cmdline >/dev/null ; then
109 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
110 if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
111 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
115 # Remount the root filesystem read-write.
116 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
118 # Update quotas if fsck was run on /.
119 if [ X"$_RUN_QUOTACHECK" == "X1" -a -x /sbin/quotacheck ]; then
120 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
123 # /etc/nologin when starting system
124 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
126 if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
127 show "Enabling Delay Login"; busy
129 echo "[EN] System bootup in progress - please wait" >> /etc/nologin
130 echo "[PL] Startowanie systemu w toku - proszê czekaæ" >> /etc/nologin
132 chmod 644 /etc/nologin
133 cp -fp /etc/nologin /etc/nologin.boot
141 # Enter root and /proc into mtab.
145 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
151 # Set up kernel version-dependent symlinks.
152 rm -f /lib/modules/preferred
153 if [ -n "$USEMODULES" ]; then
154 ktag="`cat /proc/version`"
155 mtag="`grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null`"
156 if [ -n "$mtag" ]; then
157 mver="`echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'`"
158 ln -sf /lib/modules/$mver /lib/modules/preferred
159 ln -sf /boot/System.map-$mver /boot/System.map
160 ln -sf /boot/module-info-$mver /boot/module-info
164 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
165 # Get ready for kerneld if module support in the kernel
166 if [ -e /lib/modules/preferred ]; then
167 run_cmd "Finding module dependencies" depmod -a preferred
169 run_cmd "Finding module dependencies" depmod -a
174 if (! grep -i nomodules /proc/cmdline >/dev/null) && [ "$LOAD_SOUND" == "yes" ]; then
175 if [ -n "$USEMODULES" ]; then
176 if grep -s "alias sound" /etc/modules.conf > /dev/null ; then
177 run_cmd "Loading sound module" modprobe sound
178 if grep -s "alias midi" /etc/conf.modules > /dev/null ; then
179 run_cmd "Loading midi module" modprobe midi
185 if [ -f /proc/sys/kernel/modprobe ]; then
186 # /proc/sys/kernel/modprobe indicates built-in kmod instead
187 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
191 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidstart ]; then
192 show "Starting up RAID devices."; started
193 initlog -c "raidstart -a"
197 # A non-zero return means there were problems.
198 if [ $rc -gt 0 ]; then
201 echo "*** An error occurred during the RAID startup"
202 echo "*** Dropping you to a shell; the system will reboot"
203 echo "*** when you leave the shell."
205 PS1='(RAID Repair) #'; export PS1
206 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
212 run_cmd "Unmounting file systems" umount -a
213 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
214 run_cmd "Automatic reboot in progress" reboot
219 if [ ! -f /fastboot ]; then
220 show "Checking filesystems."; started
221 initlog -c "fsck -T -R -A -a $fsckoptions"
225 # A return of 2 or higher means there were serious problems.
226 if [ $rc -gt 1 ]; then
229 echo "*** An error occurred during the file system check."
230 echo "*** Dropping you to a shell; the system will reboot"
231 echo "*** when you leave the shell."
233 PS1='(Repair filesystem) #'; export PS1
234 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
240 run_cmd "Unmounting file systems" umount -a
241 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
242 run_cmd "Automatic reboot in progress." reboot
243 elif [ "$rc" == "1" -a -x /sbin/quotacheck ]; then
244 run_cmd "Checking filesystem quotas"/sbin/quotacheck -v -R -a
248 # Mount all other filesystems (except for NFS and /proc, which is already
249 # mounted). Contrary to standard usage,
250 # filesystems are NOT unmounted in single user mode.
251 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
253 # set the console font
254 if [ -x /sbin/setsysfont ]; then
255 show "Loading default system font"; busy
256 if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
259 if [ -x /sbin/quotaon ]; then
260 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
263 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
264 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
267 chown root.utmpx /var/run/utmpx
268 chmod 0664 /var/run/utmpx /var/log/wtmpx
271 if [ "$CLEAN_TMP" == "yes" ]; then
275 # Delete UUCP lock files.
278 # Delete stale subsystem files.
279 rm -f /var/lock/subsys/*
281 # Delete stale pam_console locks.
282 rm -f /var/lock/console/*
283 rm -f /var/lock/console.lock
285 # Delete stale pid files
287 rm -f /var/spool/postoffice/.pid.*
292 # Delete Postgres sockets
293 rm -f /tmp/.s.PGSQL.*
295 # Set the system clock.
296 show "Setting clock"; busy
300 if [ -f /etc/sysconfig/clock ]; then
301 . /etc/sysconfig/clock
303 # convert old style clock config to new values
304 if [ "${CLOCKMODE}" == "GMT" ]; then
306 elif [ "${CLOCKMODE}" == "ARC" ]; then
311 if [ -x /sbin/hwclock ]; then
312 CLOCKFLAGS="--hctosys"
321 CLOCKFLAGS="$CLOCKFLAGS -u";
328 CLOCKFLAGS="$CLOCKFLAGS -A";
334 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
336 show "Date set to `date`"; ok
338 # Right, now turn on swap in case we swap to files.
339 show "Enabling swap space"; busy
340 if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
346 # Initialize the serial ports.
347 if [ -f /etc/rc.d/rc.serial ]; then
348 . /etc/rc.d/rc.serial
351 # If a SCSI tape has been detected, load the st module unconditionally
352 # since many SCSI tapes don't deal well with st being loaded and unloaded
353 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
354 if cat /proc/devices | grep -qv ' 9 st' ; then
355 if [ -n "$USEMODULES" ] ; then
356 # Try to load the module. If it fails, ignore it...
357 insmod -p st >/dev/null 2>&1 && modprobe st >/dev/null 2>&1
362 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
364 #if [ -x /bin/ps ]; then
365 #show "Rebuilding /etc/psdevtab database"; busy
366 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
369 if [ -x /sbin/ldconfig ]; then
370 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
373 if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
374 show "Sending val. $PANIC_REBOOT_TIME to /proc/sys/kernel/panic"; busy
375 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
378 # Now that we have all of our basic modules loaded and the kernel going,
379 # let's dump the syslog ring somewhere so we can find it later
380 dmesg > /var/log/dmesg
381 chmod 640 /var/log/dmesg
383 # Feed entropy into the entropy pool
384 /etc/rc.d/init.d/random start