3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.20 1999/08/14 12:39:07 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
31 . /etc/rc.d/init.d/functions
33 # Read network config data.
34 if [ -f /etc/sysconfig/network ]; then
35 . /etc/sysconfig/network
41 # Read system config data.
42 if [ -f /etc/sysconfig/system ]; then
43 . /etc/sysconfig/system
45 RUN_SULOGIN_ON_ERR=yes
55 # Set console loglevel
56 /sbin/loglevel $CONSOLE_LOGLEVEL
59 run_cmd "`nls "Activating swap partitions"`" swapon -a
62 run_cmd "`nls "Host:"` ${HOSTNAME}" hostname ${HOSTNAME}
64 # Set the NIS domain name
65 if [ -n "$NISDOMAIN" ]; then
66 run_cmd "`nls "NIS Domain:"` ${NISDOMAIN}" domainname $NISDOMAIN
71 if [ -f /fsckoptions ]; then
72 fsckoptions=`cat /fsckoptions`
77 if [ -f /forcefsck ]; then
78 fsckoptions="-f $fsckoptions"
81 # we need /proc mounted before starting fsck
82 mount -t proc /proc /proc
85 if [ ! -f /fastboot ]; then
86 show "Checking root filesystems."; started
87 initlog -c "fsck -T -a $fsckoptions /"
91 # A return of 2 or higher means there were serious problems.
92 if [ $rc -gt 1 ]; then
95 nls "*** An error occurred during the file system check."
96 nls "*** Dropping you to a shell; the system will reboot"
97 nls "*** when you leave the shell."
99 PS1="`nls '(Repair filesystem) #'`"; export PS1
100 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
106 run_cmd "Unmounting file systems" umount -a
107 mount -n -o remount,ro /
108 run_cmd "Automatic reboot in progress." reboot
109 elif [ "$rc" == "1" ]; then
114 # check for arguments
115 if grep -i nopnp /proc/cmdline >/dev/null ; then
122 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
123 if [ -n "$PNP" ] && [ "$RUN_ISAPNP" == "yes" ]; then
124 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
128 # Remount the root filesystem read-write.
129 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
131 # Update quotas if fsck was run on /.
132 if [ X"$_RUN_QUOTACHECK" == "X1" -a -x /sbin/quotacheck ]; then
133 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
136 # /etc/nologin when starting system
137 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
139 if [ "$DELAY_LOGIN" == "yes" ] && [ ! -f /etc/nologin ]; then
140 show "Enabling Delay Login"; busy
142 nls "System bootup in progress - please wait" >> /etc/nologin
144 chmod 644 /etc/nologin
145 cp -fp /etc/nologin /etc/nologin.boot
153 # Enter root and /proc into mtab.
157 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
163 # Kernel dependent links
164 rm -f /lib/modules/preferred
165 rm -f /lib/modules/default
166 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
167 if [ "$SET_SLINKS" != "no" ]; then
168 # Get ready for kmod if module support in the kernel
169 if [ -z `uname -r | grep "-"` ]; then
170 # we're using a new kernel, no preferred needed
173 ktag="`cat /proc/version`"
174 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
175 if [ -n "$mtag" ]; then
176 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'
178 if [ -n "$mver" ]; then
179 ln -sf /lib/modules/$mver /lib/modules/default
183 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && ln -sf /boot/module-info-$mver /boot/module-info
184 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && ln -sf /boot/System.map-$mver /boot/System.map
185 run_cmd "Finding module dependencies" depmod -as
189 if [ -n "$USEMODULES" ] && [ "$LOAD_SOUND" == "yes" ]; then
190 if grep -s -q "^alias sound" /etc/conf.modules ; then
191 run_cmd "Loading sound module" modprobe sound
193 if grep -s -q "^alias midi" /etc/conf.modules ; then
194 run_cmd "Loading midi module" modprobe midi
198 if [ -f /proc/sys/kernel/modprobe ]; then
199 # /proc/sys/kernel/modprobe indicates built-in kmod instead
200 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
204 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
205 show "Starting up RAID devices."; started
206 initlog -c "raidadd -a"
216 # A non-zero return means there were problems.
217 if [ $rc -gt 0 ]; then
220 nls "*** An error occurred during the RAID startup"
221 nls "*** Dropping you to a shell; the system will reboot"
222 nls "*** when you leave the shell."
224 PS1='(RAID Repair) #'; export PS1
225 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
231 run_cmd "Unmounting file systems" umount -a
232 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
233 run_cmd "Automatic reboot in progress" reboot
238 if [ ! -f /fastboot ]; then
239 show "Checking filesystems."; started
240 initlog -c "fsck -T -R -A -a $fsckoptions"
244 # A return of 2 or higher means there were serious problems.
245 if [ $rc -gt 1 ]; then
248 nls "*** An error occurred during the file system check."
249 nls "*** Dropping you to a shell; the system will reboot"
250 nls "*** when you leave the shell."
252 PS1="`nls '(Repair filesystem) #'`"; export PS1
253 if [ "$RUN_SULOGIN_ON_ERR" == "yes" ]; then
259 run_cmd "Unmounting file systems" umount -a
260 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
261 run_cmd "Automatic reboot in progress." reboot
262 elif [ "$rc" == "1" -a -x /sbin/quotacheck ]; then
263 run_cmd "Checking filesystem quotas"/sbin/quotacheck -v -R -a
267 # Mount all other filesystems (except for NFS and /proc, which is already
268 # mounted). Contrary to standard usage,
269 # filesystems are NOT unmounted in single user mode.
270 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
272 # set the console font
273 if [ -x /sbin/setsysfont ]; then
274 show "Loading default system font"; busy
275 if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
278 if [ -x /sbin/quotaon ]; then
279 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
282 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
283 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
286 chown root.utmp /var/run/utmpx
287 chmod 0664 /var/run/utmpx /var/log/wtmpx
290 if [ "$CLEAN_TMP" == "yes" ]; then
294 # Delete UUCP lock files.
297 # Delete stale subsystem files.
298 rm -f /var/lock/subsys/*
300 # Delete stale pam_console locks.
301 rm -f /var/lock/console/*
302 rm -f /var/lock/console.lock
304 # Delete stale pid files
306 rm -f /var/spool/postoffice/.pid.*
311 # Delete Postgres sockets
312 rm -f /tmp/.s.PGSQL.*
314 # Set the system clock.
315 show "Setting clock"; busy
319 if [ -f /etc/sysconfig/clock ]; then
320 . /etc/sysconfig/clock
322 # convert old style clock config to new values
323 if [ "${CLOCKMODE}" == "GMT" ]; then
325 elif [ "${CLOCKMODE}" == "ARC" ]; then
330 if [ -x /sbin/hwclock ]; then
331 CLOCKFLAGS="--hctosys"
340 CLOCKFLAGS="$CLOCKFLAGS -u";
347 CLOCKFLAGS="$CLOCKFLAGS -A";
353 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
355 show "`nls "Date set to"` `date`"; ok
357 # Right, now turn on swap in case we swap to files.
358 show "Enabling swap space"; busy
359 if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" == "" ]; then
365 # Initialize the serial ports.
366 if [ -f /etc/rc.d/rc.serial ]; then
367 . /etc/rc.d/rc.serial
370 # If a SCSI tape has been detected, load the st module unconditionally
371 # since many SCSI tapes don't deal well with st being loaded and unloaded
372 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
373 if cat /proc/devices | grep -qv ' 9 st' ; then
374 if [ -n "$USEMODULES" ] ; then
375 # Try to load the module. If it fails, ignore it...
376 insmod -p st >/dev/null 2>&1 && modprobe st >/dev/null 2>&1
381 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
383 #if [ -x /bin/ps ]; then
384 #show "Rebuilding /etc/psdevtab database"; busy
385 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
388 if [ -x /sbin/ldconfig ]; then
389 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
392 if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
393 show "Sending val. $PANIC_REBOOT_TIME to /proc/sys/kernel/panic"; busy
394 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
397 # Now that we have all of our basic modules loaded and the kernel going,
398 # let's dump the syslog ring somewhere so we can find it later
399 dmesg > /var/log/dmesg
400 chmod 640 /var/log/dmesg
402 # Feed entropy into the entropy pool
403 /etc/rc.d/init.d/random start