xref: /original-bsd/etc/rc (revision 963f8367)
1#	@(#)rc	5.26 (Berkeley) 05/09/91
2
3# System startup script run by init on autoboot
4# or after single-user.
5# Output and error are redirected to console by init,
6# and the console is the controlling terminal.
7
8# Set shell to ignore SIGINT (2), but not children;
9# shell catches SIGQUIT (3) and returns to single user after fsck.
10trap : 2
11trap : 3
12
13HOME=/; export HOME
14PATH=/sbin:/bin:/usr/sbin:/usr/bin
15export PATH
16
17if [ -r /fastboot ]
18then
19	echo Fast boot ... skipping disk checks
20elif [ $1x = autobootx ]
21then
22	echo Automatic reboot in progress...
23	fsck -p
24	case $? in
25	0)
26		;;
27	2)
28		exit 1
29		;;
30	4)
31		reboot
32		echo "reboot failed... help!"
33		exit 1
34		;;
35	8)
36		echo "Automatic file system check failed... help!"
37		exit 1
38		;;
39	12)
40		echo "Reboot interrupted"
41		exit 1
42		;;
43	130)
44		# interrupt before catcher installed
45		exit 1
46		;;
47	*)
48		echo "Unknown error in reboot"
49		exit 1
50		;;
51	esac
52fi
53
54trap "echo 'Reboot interrupted'; exit 1" 3
55
56swapon -a
57
58umount -a >/dev/null 2>&1
59mount -a -t nonfs
60rm -f /fastboot		# XXX (root now writeable)
61
62# set hostname, turn on network
63echo 'starting network'
64. /etc/netstart
65
66mount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
67
68# clean up left-over files
69rm -f /etc/nologin
70rm -f /var/spool/uucp/LCK.*
71rm -f /var/spool/uucp/STST/*
72(cd /var/run && { rm -rf -- *; cp /dev/null utmp; chmod 644 utmp; })
73
74echo -n 'starting system logger'
75rm -f /dev/log
76syslogd
77
78# $timedflags is imported from /etc/netstart;
79# if $timedflags == NO, timed isn't run.
80if [ X${timedflags} != X"NO" ]; then
81	echo -n ', time daemon'; timed $timedflags
82fi
83echo '.'
84
85# /var/crash should be a directory or a symbolic link
86# to the crash directory if core dumps are to be saved.
87if [ -d /var/crash ]; then
88	savecore /var/crash
89fi
90
91				echo -n 'checking quotas:'
92quotacheck -a
93				echo ' done.'
94quotaon -a
95
96# build ps databases
97kvm_mkdb /vmunix
98dev_mkdb
99
100chmod 666 /dev/tty[pqrs]*
101
102# check the password temp/lock file
103if [ -f /etc/ptmp ]
104then
105	logger -s -p auth.err \
106	'password file may be incorrect -- /etc/ptmp exists'
107fi
108
109echo preserving editor files
110(cd /var/tmp && /usr/libexec/ex3.7preserve -a &&
111     rm -f Ex[0-9][0-9][0-9][0-9][0-9] Rx[0-9][0-9][0-9][0-9][0-9])
112
113echo clearing /tmp
114
115# prune quickly with one rm, then use find to clean up /tmp/[lq]*
116# (not needed with mfs /tmp, but doesn't hurt there...)
117(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
118    find . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;)
119
120echo 'turning on accounting';	accton /var/account/acct
121
122echo -n standard daemons:
123echo -n ' update';		update
124echo -n ' cron';		cron
125echo '.'
126
127echo -n starting network daemons:
128
129# $gated and $routedflags are imported from /etc/netstart.
130# If $gated == YES, gated is used; otherwise routed.
131# If $routedflags == NO, routed isn't run.
132if [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
133	echo -n ' gated';	gated $gatedflags
134elif [ X${routedflags} != X"NO" ]; then
135	echo -n ' routed';	routed $routedflags
136fi
137
138echo -n ' named';		named
139echo -n ' inetd';		inetd
140
141# $rwhod is imported from /etc/netstart;
142# if $rwhod is set to something other than NO, rwhod is run.
143if [ ${rwhod-NO} != "NO" ]; then
144	echo -n ' rwhod';	rwhod
145fi
146
147echo -n ' printer';		lpd
148
149echo -n ' portmap';		portmap
150echo -n ' mountd';		mountd
151echo -n ' nfsd';		nfsd -u 0,0,4 -t 0,0
152echo -n ' nfsiod';		nfsiod 4
153
154echo -n ' sendmail';		sendmail -bd -q30m
155
156echo '.'
157
158sh /etc/rc.local
159
160date
161exit 0
162