# /etc/rc - generic (to Linux) system startup file (runtime configuration)

echo "running /etc/rc..."

PATH=/sbin:/usr/sbin:/bin:/usr/bin; export PATH

# bdflush performs flushes dirty buffers back to disk and performs a syn
# every 30 seconds.  therefore, it replaces update.
bdflush &

if [ -f /fastboot ]
then
    echo Skipping fcsk
else
    fsck -AV -a
    # If there was a failure, drop into single-user mode.
    # NOTE: This is not secure.  If security is needed, make sure than
    #       /etc/securesinlge exists and "reboot single".  simipleinit
    #       will then prompt for root's password.
    if [ $? -gt 1 ]
    then
        echo "Warning: fsck FAILED"
        echo "         Starting single user shell"
        echo "         Fix filesystem and REBOOT"
        sh -si < /dev/console > /dev/console 2>&1
    fi
fi

# Remount the root filesystem in read-write mode
mount -n -o remount /dev/sda2 /

# remove /etc/mtab* so mount creates the /etc/mtab file
rm -f /etc/mtab* /etc/nologin /fastboot

# mount all partitions specified in /etc/fstab
mount -av
# mount swap partition specified in /etc/fstab
swapon -a

# Preserve elvis files in case of a crash
elvprsv "-the system went down" /tmp/elv_*.*

# tmp and usr may be mounted, so we do these rm's after mount
rm -f /var/lock/LCK*
rm -rf /tmp; mkdir /tmp; chmod 777 /tmp

# remove /etc/utmp and touch it
rm -f /etc/utmp
touch /etc/utmp

# start up cron if it exists
if [ -f /etc/crond ]; then
	/etc/crond
fi

# update ps database
if [ -f /sbin/psupdate ]; then
	/sbin/psupdate
fi

sh /etc/rc.local
