3 # /etc/rc.d/rc.sysinit - run once at boot time
4 # $Id: rc.sysinit,v 1.32 1999/10/13 09:06:50 waszi 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 NFSROOT=`cat /proc/mounts | awk '{ if ($2 ~ /^\/$/ && $3 ~ /^nfs$/) print $3 }'`
88 if [ ! -f /fastboot ] && [ ! -n "$NFSROOT" ]; then
89 show "Checking root filesystems."; started
90 initlog -c "fsck -T -a $fsckoptions /"
94 # A return of 2 or higher means there were serious problems.
95 if [ $rc -gt 1 ]; then
96 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"
98 PS1="`nls "(Repair filesystem) #"`"; export PS1
99 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
105 run_cmd "Unmounting file systems" umount -a
106 mount -n -o remount,ro /
107 run_cmd "Automatic reboot in progress." reboot
108 elif [ "$rc" = "1" ]; then
113 # check for arguments
114 if grep -i nopnp /proc/cmdline >/dev/null ; then
121 if [ -x /sbin/isapnp -a -f /etc/isapnp/isapnp.conf ]; then
122 if [ -n "$PNP" ] && [ "$RUN_ISAPNP" = "yes" ]; then
123 run_cmd "Setting up ISA PNP devices" /sbin/isapnp /etc/isapnp/isapnp.conf
127 # Remount the root filesystem read-write.
128 run_cmd "Remounting root filesystem in rw mode" mount -n -o remount,rw /
130 # Update quotas if fsck was run on /.
131 if [ X"$_RUN_QUOTACHECK" = "X1" -a -x /sbin/quotacheck ] && [ ! -n "$NFSROOT" ]; then
132 run_cmd "Checking root filesystem quotas" /sbin/quotacheck -v /
135 # /etc/nologin when starting system
136 [ -f /etc/nologin.boot ] && rm -f /etc/nologin /etc/nologin.boot
138 if [ "$DELAY_LOGIN" = "yes" ] && [ ! -f /etc/nologin ]; then
139 show "Enabling Delay Login"; busy
141 nls "System bootup in progress - please wait" >> /etc/nologin
143 chmod 644 /etc/nologin
144 cp -fp /etc/nologin /etc/nologin.boot
152 # Enter root and /proc into mtab.
156 if ! grep -i nomodules /proc/cmdline >/dev/null && [ -f /proc/ksyms ]; then
162 # Kernel dependent links
163 rm -f /lib/modules/preferred
164 rm -f /lib/modules/default
165 if [ -x /sbin/depmod -a -n "$USEMODULES" ]; then
166 if [ "$SET_SLINKS" != "no" ]; then
167 # Get ready for kmod if module support in the kernel
168 if [ -z `uname -r | grep "-"` ]; then
169 # we're using a new kernel, no preferred needed
172 ktag="`cat /proc/version`"
173 mtag=grep -l "$ktag" /lib/modules/*/.rhkmvtag 2> /dev/null
174 if [ -n "$mtag" ]; then
175 mver=echo $mtag | sed -e 's,/lib/modules/,,' -e 's,/.rhkmvtag,,' -e 's,[ ].*$,,'
177 if [ -n "$mver" ]; then
178 ln -sf /lib/modules/$mver /lib/modules/default
182 [ -n "$mver" -a -f "/boot/module-info-$mver" ] && ln -sf /boot/module-info-$mver /boot/module-info
183 [ -n "$mver" -a -f "/boot/System.map-$mver" ] && ln -sf /boot/System.map-$mver /boot/System.map
184 run_cmd "Finding module dependencies" depmod -a -s
188 if [ -n "$USEMODULES" ] && [ "$LOAD_SOUND" = "yes" ]; then
189 if grep -s -q "^alias sound" /etc/modules.conf ; then
190 run_cmd "Loading sound module" modprobe -s sound
192 if grep -s -q "^alias midi" /etc/modules.conf ; then
193 run_cmd "Loading midi module" modprobe -s midi
197 if [ -f /proc/sys/kernel/modprobe ]; then
198 # /proc/sys/kernel/modprobe indicates built-in kmod instead
199 echo "/sbin/modprobe" > /proc/sys/kernel/modprobe
203 if [ -f /proc/mdstat -a -f /etc/raidtab -a -x /sbin/raidadd ]; then
204 show "Starting up RAID devices."; busy
205 initlog -c 'raidadd -a'
213 # A non-zero return means there were problems.
214 if [ $rc -gt 0 ]; then
217 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"
219 PS1="`nls "(RAID Repair) #"`"; export PS1
220 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
226 run_cmd "Unmounting file systems" umount -a
227 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
228 run_cmd "Automatic reboot in progress" reboot
235 if [ ! -f /fastboot ]; then
236 show "Checking filesystems."; started
237 initlog -c "fsck -T -R -A -a $fsckoptions"
241 # A return of 2 or higher means there were serious problems.
242 if [ $rc -gt 1 ]; then
243 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"
245 PS1="`nls "(Repair filesystem) #"`"; export PS1
246 if [ "$RUN_SULOGIN_ON_ERR" = "yes" ]; then
252 run_cmd "Unmounting file systems" umount -a
253 run_cmd "Remounting root filesystem in ro mode" mount -n -o remount,ro /
254 run_cmd "Automatic reboot in progress." reboot
255 elif [ "$rc" = "1" -a -x /sbin/quotacheck ]; then
256 run_cmd "Checking filesystem quotas" /sbin/quotacheck -v -R -a
260 # Mount all other filesystems (except for NFS and /proc, which is already
261 # mounted). Contrary to standard usage,
262 # filesystems are NOT unmounted in single user mode.
263 run_cmd "Mounting local filesystems." mount -a -t nonfs,smbfs,ncpfs,proc
265 # set the console font
266 #if [ -x /sbin/setsysfont ]; then
267 # show "Loading default system font"; busy
268 # if (/sbin/setsysfont > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
271 if [ -x /sbin/quotaon ]; then
272 run_cmd "Turning on quotas for local filesystems" /sbin/quotaon -a
275 # Clean out /etc & /var/{run/*,log/{b,w}tmpx}}.
276 rm -f /etc/mtab~ /fastboot /fsckoptions /forcefsck
279 chown root.utmp /var/run/utmpx
280 chmod 0664 /var/run/utmpx /var/log/wtmpx
283 if [ "$CLEAN_TMP" = "yes" ]; then
287 # Delete UUCP lock files.
290 # Delete stale subsystem files.
291 rm -f /var/lock/subsys/*
293 # Delete stale pam_console locks.
294 rm -f /var/lock/console/*
295 rm -f /var/lock/console.lock
297 # Delete stale pid files
299 rm -f /var/spool/postoffice/.pid.*
304 # Delete Postgres sockets
305 rm -f /tmp/.s.PGSQL.*
307 # Set the system clock.
308 show "Setting clock"; busy
312 if [ -f /etc/sysconfig/clock ]; then
313 . /etc/sysconfig/clock
315 # convert old style clock config to new values
316 if [ "${CLOCKMODE}" = "GMT" ]; then
318 elif [ "${CLOCKMODE}" = "ARC" ]; then
323 if [ -x /sbin/hwclock ]; then
324 CLOCKFLAGS="--hctosys"
333 CLOCKFLAGS="$CLOCKFLAGS -u";
340 CLOCKFLAGS="$CLOCKFLAGS -A";
346 if ($CLOCK $CLOCKFLAGS); then deltext; ok; else deltext; fail; fi
348 show "`nls "Date set to"` `date`"; ok
350 # Right, now turn on swap in case we swap to files.
351 show "Enabling swap space"; busy
352 if [ "`LANG=C swapon -a 2>&1 | grep -v "busy"`" = "" ]; then
358 # Initialize the serial ports.
359 if [ -f /etc/rc.d/rc.serial ]; then
360 . /etc/rc.d/rc.serial
363 # If a SCSI tape has been detected, load the st module unconditionally
364 # since many SCSI tapes don't deal well with st being loaded and unloaded
365 if [ -f /proc/scsi/scsi ] && cat /proc/scsi/scsi | grep -q 'Type: Sequential-Access' 2>/dev/null ; then
366 if cat /proc/devices | grep -qv ' 9 st' ; then
367 if [ -n "$USEMODULES" ] ; then
368 # Try to load the module. If it fails, ignore it...
369 insmod -p st >/dev/null 2>&1 && modprobe -s st >/dev/null 2>&1
374 # there could be a new kernel version. reinit /etc/psdevtab, to be sure.
376 #if [ -x /bin/ps ]; then
377 #show "Rebuilding /etc/psdevtab database"; busy
378 #if (ps > /dev/null 2>&1); then deltext; ok; else deltext; fail; fi
381 if [ -x /sbin/ldconfig ]; then
382 run_cmd "Setting up /etc/ld.so.cache" /sbin/ldconfig -X
385 if ([ -f /proc/sys/kernel/panic ] && [ "$PANIC_REBOOT_TIME" -gt "0" ] 2>/dev/null); then
386 show "`nls "Sending val. %s to /proc/sys/kernel/panic" "$PANIC_REBOOT_TIME"`"; busy
387 if (echo $PANIC_REBOOT_TIME > /proc/sys/kernel/panic); then deltext; ok; else deltext; fail; fi
390 # Now that we have all of our basic modules loaded and the kernel going,
391 # let's dump the syslog ring somewhere so we can find it later
392 dmesg > /var/log/dmesg
393 chmod 640 /var/log/dmesg
395 # Feed entropy into the entropy pool
396 /etc/rc.d/init.d/random start