xref: /original-bsd/etc/rc (revision a8f82b20)
1*a8f82b20Sbostic#	@(#)rc	8.2 (Berkeley) 03/17/94
2b0a74f6eSbostic
3f7313c2cSkarels# System startup script run by init on autoboot
4f7313c2cSkarels# or after single-user.
5f7313c2cSkarels# Output and error are redirected to console by init,
6f7313c2cSkarels# and the console is the controlling terminal.
7f7313c2cSkarels
8a6b497d8Skarelsstty status '^T'
9a6b497d8Skarels
10f7313c2cSkarels# Set shell to ignore SIGINT (2), but not children;
11f7313c2cSkarels# shell catches SIGQUIT (3) and returns to single user after fsck.
12f7313c2cSkarelstrap : 2
13a6b497d8Skarelstrap : 3	# shouldn't be needed
14f7313c2cSkarels
1518430759SbosticHOME=/; export HOME
169d8024f0SkarelsPATH=/sbin:/bin:/usr/sbin:/usr/bin
17b07395eeSbosticexport PATH
1818430759Sbostic
1918430759Sbosticif [ -r /fastboot ]
2018430759Sbosticthen
21*a8f82b20Sbostic	echo "Fast boot: skipping disk checks."
2218430759Sbosticelif [ $1x = autobootx ]
2318430759Sbosticthen
24*a8f82b20Sbostic	echo "Automatic boot in progress: starting file system checks."
259fcfa9a4Sbostic	fsck -p
2618430759Sbostic	case $? in
2718430759Sbostic	0)
2818430759Sbostic		;;
2918430759Sbostic	2)
3018430759Sbostic		exit 1
3118430759Sbostic		;;
3218430759Sbostic	4)
33*a8f82b20Sbostic		echo "Rebooting..."
34f7313c2cSkarels		reboot
35*a8f82b20Sbostic		echo "Reboot failed; help!"
36fb6f6a15Skarels		exit 1
3718430759Sbostic		;;
3818430759Sbostic	8)
39*a8f82b20Sbostic		echo "Automatic file system check failed; help!"
4018430759Sbostic		exit 1
4118430759Sbostic		;;
4218430759Sbostic	12)
43*a8f82b20Sbostic		echo "Boot interrupted."
4418430759Sbostic		exit 1
4518430759Sbostic		;;
46fb6f6a15Skarels	130)
47fb6f6a15Skarels		# interrupt before catcher installed
48fb6f6a15Skarels		exit 1
49fb6f6a15Skarels		;;
5018430759Sbostic	*)
51*a8f82b20Sbostic		echo "Unknown error; help!"
5218430759Sbostic		exit 1
5318430759Sbostic		;;
5418430759Sbostic	esac
5518430759Sbosticfi
5618430759Sbostic
57*a8f82b20Sbostictrap "echo 'Boot interrupted.'; exit 1" 3
58f7313c2cSkarels
599fcfa9a4Sbosticswapon -a
60641647ccSbostic
6168d26ac7Skarelsumount -a >/dev/null 2>&1
629fcfa9a4Sbosticmount -a -t nonfs
63c62cfa9aSkarelsrm -f /fastboot		# XXX (root now writeable)
64641647ccSbostic
6518430759Sbostic# set hostname, turn on network
666ab85d47Skarelsecho 'starting network'
6718430759Sbostic. /etc/netstart
6818430759Sbostic
6968d26ac7Skarelsmount -a -t nfs >/dev/null 2>&1 &	# XXX shouldn't need background
7047697e4dSkarels
71c62cfa9aSkarels# clean up left-over files
72c62cfa9aSkarelsrm -f /etc/nologin
73c62cfa9aSkarelsrm -f /var/spool/uucp/LCK.*
74c62cfa9aSkarelsrm -f /var/spool/uucp/STST/*
75cc247718Skarels(cd /var/run && { rm -rf -- *; install -c -m 664 -g utmp /dev/null utmp; })
76c62cfa9aSkarels
779fcfa9a4Sbosticecho -n 'starting system logger'
7818430759Sbosticrm -f /dev/log
7918430759Sbosticsyslogd
8018430759Sbostic
8147697e4dSkarels# $timedflags is imported from /etc/netstart;
8247697e4dSkarels# if $timedflags == NO, timed isn't run.
8347697e4dSkarelsif [ X${timedflags} != X"NO" ]; then
849fcfa9a4Sbostic	echo -n ', time daemon'; timed $timedflags
8547697e4dSkarelsfi
869fcfa9a4Sbosticecho '.'
8747697e4dSkarels
889d8024f0Skarels# /var/crash should be a directory or a symbolic link
899d8024f0Skarels# to the crash directory if core dumps are to be saved.
9018430759Sbosticif [ -d /var/crash ]; then
91a6b497d8Skarels	echo checking for core dump...
929fcfa9a4Sbostic	savecore /var/crash
9318430759Sbosticfi
9418430759Sbostic
959fcfa9a4Sbostic				echo -n 'checking quotas:'
969fcfa9a4Sbosticquotacheck -a
979fcfa9a4Sbostic				echo ' done.'
989fcfa9a4Sbosticquotaon -a
99fe7d6e7cSbostic
1009f9a3525Sbostic# build ps databases
1017bedd39dSbostickvm_mkdb
10279af7f9cSbosticdev_mkdb
103fe7d6e7cSbostic
104fe7d6e7cSbosticchmod 666 /dev/tty[pqrs]*
105fe7d6e7cSbostic
106fb6f6a15Skarels# check the password temp/lock file
107fb6f6a15Skarelsif [ -f /etc/ptmp ]
108fb6f6a15Skarelsthen
109fb6f6a15Skarels	logger -s -p auth.err \
1109fcfa9a4Sbostic	'password file may be incorrect -- /etc/ptmp exists'
111fb6f6a15Skarelsfi
112fb6f6a15Skarels
1139fcfa9a4Sbosticecho preserving editor files
114c62cfa9aSkarels(cd /var/tmp && /usr/libexec/ex3.7preserve -a &&
115c62cfa9aSkarels     rm -f Ex[0-9][0-9][0-9][0-9][0-9] Rx[0-9][0-9][0-9][0-9][0-9])
11647697e4dSkarels
1179fcfa9a4Sbosticecho clearing /tmp
1189fcfa9a4Sbostic
11986f4db70Sbostic# Prune quickly with one rm, then use find to clean up /tmp/[lq]* (this
12086f4db70Sbostic# is not needed with mfs /tmp, but doesn't hurt anything).
121c62cfa9aSkarels(cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
12286f4db70Sbostic    find . ! -name . ! -name lost+found ! -name quotas -type d -prune \
12386f4db70Sbostic	-exec rm -rf -- {} \;)
12418430759Sbostic
1259fcfa9a4Sbosticecho 'turning on accounting';	accton /var/account/acct
12618430759Sbostic
1279fcfa9a4Sbosticecho -n standard daemons:
1289fcfa9a4Sbosticecho -n ' update';		update
1299fcfa9a4Sbosticecho -n ' cron';		cron
1309fcfa9a4Sbosticecho '.'
1319fcfa9a4Sbostic
1329fcfa9a4Sbosticecho -n starting network daemons:
13318430759Sbostic
134c741f5fcSkarels# $gated and $routedflags are imported from /etc/netstart.
135c741f5fcSkarels# If $gated == YES, gated is used; otherwise routed.
136c741f5fcSkarels# If $routedflags == NO, routed isn't run.
137c741f5fcSkarelsif [ X${gated} = X"YES" -a -r /etc/gated.conf ]; then
138c62cfa9aSkarels	echo -n ' gated';	gated $gatedflags
139c741f5fcSkarelselif [ X${routedflags} != X"NO" ]; then
1409fcfa9a4Sbostic	echo -n ' routed';	routed $routedflags
14118430759Sbosticfi
14218430759Sbostic
1439fcfa9a4Sbosticecho -n ' named';		named
14418430759Sbostic
14518430759Sbostic# $rwhod is imported from /etc/netstart;
14618430759Sbostic# if $rwhod is set to something other than NO, rwhod is run.
14718430759Sbosticif [ ${rwhod-NO} != "NO" ]; then
1489fcfa9a4Sbostic	echo -n ' rwhod';	rwhod
14918430759Sbosticfi
15018430759Sbostic
1519fcfa9a4Sbosticecho -n ' printer';		lpd
1529fcfa9a4Sbostic
15368d26ac7Skarelsecho -n ' portmap';		portmap
1549fcfa9a4Sbosticecho -n ' mountd';		mountd
1550df51a00Sbosticecho -n ' nfsd';		nfsd -u -t 6
1569fcfa9a4Sbosticecho -n ' nfsiod';		nfsiod 4
1579fcfa9a4Sbostic
1589fcfa9a4Sbosticecho -n ' sendmail';		sendmail -bd -q30m
159a6b497d8Skarelsecho -n ' inetd';		inetd
1600df51a00Sbosticecho -n ' amd';
1610df51a00Sbostic	cd /; amd -l /var/log/amd -r -a /amd -p > /var/run/amd.pid \
1620df51a00Sbostic	/home /etc/amd-home \
1634b56c766Sbostic	/n /etc/amd-n \
1640df51a00Sbostic	&
1650df51a00Sbostic
1669fcfa9a4Sbosticecho '.'
16718430759Sbostic
16818430759Sbosticsh /etc/rc.local
16918430759Sbostic
1709fcfa9a4Sbosticdate
17118430759Sbosticexit 0
172