#!/bin/sh
#
# $Id: brc,v 4.1 1993/03/23 16:16:51 mike Exp $
#
# Boot time system setup

# Load the general library functions and find some programs.
. /etc/init.d/LIB
update=`pathof update`

# Get the proc filesystem up early.
if [ ! -d /proc ]; then
	rm -f /proc
	mkdir /proc
	chmod 555 /proc
fi
mount -t proc /proc /proc

# If there are one or more update lines in the inittab then we assume
# they are there because this init handles periodic syncs itself,
# otherwise we start an update daemon to do it. This heuristic rather
# assumes that we use an update line even if we just want the frequency
# hardcoded in to init.
if [ X`awk '/^[^:]*:[^:]*:update:/ { print "Y" }' /etc/inittab` != XY ]; then
	if [ -n "$update" ]; then
		$update &
	else
		echo "IMPORTANT: Inittab contains no update lines and no update program was found"
		echo "IMPORTANT: unless init has a default update hardcoded NO SYNCS WILL BE DONE!"
	fi
fi

# Clean temporary directories, lock files etc. in preparation for the
# system going multiuser. Do *not* delete /fastboot or /etc/fastboot
# here. They are deleted after mounting filesystems.

echo $use_escapes "Cleaning system...\c"

# If we can see an elvprsv out there run it to pick up any files that
# were being editted when the system crashed. Do it *before* we wipe
# the temporary directories!
it=`pathof elvprsv`
if [ -n "$it" ]; then
	$it
fi

rm -f /usr/spool/uucp/LCK*
rm -rf /tmp/* /usr/tmp/*
rm -f /etc/nologin
> /etc/utmp

# Permissions fixing. Shutdowns tend to be violent and don't necessarily
# give processes time to reset permissions. Xdm is one culprit leaving
# the console owned by the wrong user.
chown root /dev/console
chmod 622 /dev/console

echo " done"
