rc revision 323
155682Smarkm#	@(#)rc	5.27 (Berkeley) 6/5/91
2233294Sstas
355682Smarkm# System startup script run by init on autoboot
455682Smarkm# or after single-user.
5233294Sstas# Output and error are redirected to console by init,
655682Smarkm# and the console is the controlling terminal.
755682Smarkm
855682Smarkmstty status '^T'
9233294Sstas
1055682Smarkm# Set shell to ignore SIGINT (2), but not children;
1155682Smarkm# shell catches SIGQUIT (3) and returns to single user after fsck.
12233294Sstastrap : 2
1355682Smarkmtrap : 3	# shouldn't be needed
1455682Smarkm
1555682SmarkmHOME=/; export HOME
16233294SstasPATH=/sbin:/bin:/usr/sbin:/usr/bin
1755682Smarkmexport PATH
1855682Smarkm
1955682Smarkmif [ -e /fastboot ]
20233294Sstasthen
2155682Smarkm	echo Fast boot ... skipping disk checks
2255682Smarkmelif [ $1x = autobootx ]
2355682Smarkmthen
2455682Smarkm	echo Automatic reboot in progress...
2555682Smarkm	fsck -p
2655682Smarkm	case $? in
2755682Smarkm	0)
2855682Smarkm		;;
2955682Smarkm	2)
3055682Smarkm		exit 1
3155682Smarkm		;;
3255682Smarkm	4)
3355682Smarkm		reboot
34233294Sstas		echo "reboot failed... help!"
3555682Smarkm		exit 1
3655682Smarkm		;;
3755682Smarkm	8)
3855682Smarkm		echo "Automatic file system check failed... help!"
3955682Smarkm		exit 1
4055682Smarkm		;;
4155682Smarkm	12)
4255682Smarkm		echo "Reboot interrupted"
4355682Smarkm		exit 1
4455682Smarkm		;;
4555682Smarkm	130)
4655682Smarkm		# interrupt before catcher installed
4755682Smarkm		exit 1
4855682Smarkm		;;
4955682Smarkm	*)
5055682Smarkm		echo "Unknown error in reboot"
5155682Smarkm		exit 1
5255682Smarkm		;;
5355682Smarkm	esac
5455682Smarkmfi
5555682Smarkm
5655682Smarkmtrap "echo 'Reboot interrupted'; exit 1" 3
5755682Smarkm
5855682Smarkmswapon -a
5955682Smarkm
6055682Smarkmumount -a >/dev/null 2>&1
6155682Smarkmmount -a -t nonfs
6255682Smarkmrm -f /fastboot		# XXX (root now writeable)
6355682Smarkm
6455682Smarkm# set hostname, turn on network
6555682Smarkmecho 'starting network'
6655682Smarkm. /etc/netstart
6755682Smarkm
6855682Smarkmmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
6955682Smarkm
7055682Smarkm# clean up left-over files
7155682Smarkmrm -f /etc/nologin
7255682Smarkmrm -f /var/spool/uucp/LCK.*
7355682Smarkmrm -f /var/spool/uucp/STST/*
7455682Smarkm(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
7555682Smarkm
7655682Smarkmecho -n 'starting system logger'
7755682Smarkmrm -f /dev/log
7855682Smarkmsyslogd
7955682Smarkm
8055682Smarkm# $timedflags is imported from /etc/netstart;
8155682Smarkm# if $timedflags == NO, timed isn't run.
8255682Smarkmif [ X${timedflags} != X"NO" ]; then
8355682Smarkm	echo -n ', time daemon'; timed $timedflags
8455682Smarkmfi
8555682Smarkmecho '.'
8655682Smarkm
8755682Smarkm# /var/crash should be a directory or a symbolic link
8855682Smarkm# to the crash directory if core dumps are to be saved.
8955682Smarkmif [ -d /var/crash ]; then
9055682Smarkm	echo checking for core dump...
9155682Smarkm	savecore /var/crash
9255682Smarkmfi
9355682Smarkm
9455682Smarkm#				echo -n 'checking quotas:'
9555682Smarkm#quotacheck -a
9655682Smarkm#				echo ' done.'
9755682Smarkm#quotaon -a
9855682Smarkm
9955682Smarkm# build ps databases
10055682Smarkmkvm_mkdb /386bsd
10155682Smarkmdev_mkdb
10255682Smarkm
10355682Smarkmchmod 666 /dev/tty[pqrs]*
10455682Smarkm
10555682Smarkm# check the password temp/lock file
10655682Smarkmif [ -f /etc/ptmp ]
10755682Smarkmthen
10855682Smarkm	logger -s -p auth.err \
10955682Smarkm	'password file may be incorrect -- /etc/ptmp exists'
11055682Smarkmfi
11155682Smarkm
11255682Smarkmecho preserving editor files
11355682Smarkm(cd /var/tmp && /usr/libexec/elvispreserve "-the system rebooted" elvis* &&
11455682Smarkm     rm -f elvis[0-9a-f][0-9a-f][0-9a-f][0-9a-f]* \
11555682Smarkm	 elvis_[0-9a-f][0-9a-f][0-9a-f][0-9a-f]*)
11655682Smarkm
11755682Smarkmecho clearing /tmp
11855682Smarkm
11955682Smarkm# prune quickly with one rm, then use find to clean up /tmp/[lq]*
12055682Smarkm# (not needed with mfs /tmp, but doesn't hurt there...)
12155682Smarkm(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
12255682Smarkm    find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
12355682Smarkm
12455682Smarkm# echo 'turning on accounting';	accton /var/account/acct
12555682Smarkm
12655682Smarkmecho -n standard daemons:
12755682Smarkmecho -n ' update';		update
12855682Smarkmecho -n ' crond';		/usr/libexec/crond
12955682Smarkmecho '.'
13055682Smarkm
13155682Smarkmecho -n starting network daemons:
13255682Smarkm
13378536Sassar# $gated and $routedflags are imported from /etc/netstart.
134103426Snectar# If $gated == YES, gated is used; otherwise routed.
13578536Sassar# If $routedflags == NO, routed isn't run.
13655682Smarkmif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
13755682Smarkm	echo -n ' gated';	gated $gatedflags
13855682Smarkmelif [ X${routedflags} != X"NO" ]; then
13955682Smarkm	echo -n ' routed';	routed $routedflags
14055682Smarkmfi
14155682Smarkm
142if [ X${name_server} = X"YES" -a -r /etc/named.boot ]; then
143	echo -n ' named';		named
144fi
145
146# $rwhod is imported from /etc/netstart;
147# if $rwhod is set to something other than NO, rwhod is run.
148if [ ${rwhod-NO} != "NO" ]; then
149	echo -n ' rwhod';	rwhod
150fi
151
152echo -n ' printer';		lpd
153
154
155if [ X${nfs_server} = X"YES" -a -r /etc/exports ]; then
156	echo -n ' portmap';		portmap
157	echo -n ' mountd';		mountd
158	echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
159	echo -n ' nfsiod';		nfsiod 4
160fi
161
162echo -n ' sendmail';		sendmail -bd -q30m
163echo -n ' inetd';		inetd
164echo '.'
165
166sh /etc/rc.local
167
168date
169
170exit 0
171