Deleted Added
full compact
rc (49453) rc (50357)
1#!/bin/sh
1#!/bin/sh
2# $Id: rc,v 1.192 1999/08/06 06:20:19 peter Exp $
2# $Id: rc,v 1.193 1999/08/06 06:22:43 peter Exp $
3# From: @(#)rc 5.27 (Berkeley) 6/5/91
4
5# System startup script run by init on autoboot
6# or after single-user.
7# Output and error are redirected to console by init,
8# and the console is the controlling terminal.
9
10# Note that almost all the user-configurable behavior is no longer in

--- 29 unchanged lines hidden (view full) ---

40 . /etc/rc.conf
41fi
42
43# Configure ccd devices.
44if [ -f /etc/ccd.conf ]; then
45 ccdconfig -C
46fi
47
3# From: @(#)rc 5.27 (Berkeley) 6/5/91
4
5# System startup script run by init on autoboot
6# or after single-user.
7# Output and error are redirected to console by init,
8# and the console is the controlling terminal.
9
10# Note that almost all the user-configurable behavior is no longer in

--- 29 unchanged lines hidden (view full) ---

40 . /etc/rc.conf
41fi
42
43# Configure ccd devices.
44if [ -f /etc/ccd.conf ]; then
45 ccdconfig -C
46fi
47
48if [ X$start_vinum = XYES ]; then
48if [ "${start_vinum}" = "YES" ]; then
49 vinum start
49 vinum start
50elif [ -n "$vinum_drives" ]; then
51 vinum read $vinum_drives
50elif [ -n "${vinum_drives}" ]; then
51 vinum read ${vinum_drives}
52fi
53
54swapon -a
55
52fi
53
54swapon -a
55
56if [ $1x = autobootx ]; then
56if [ "$1" = "autoboot" ]; then
57 echo Automatic reboot in progress...
58 fsck -p
59 case $? in
60 0)
61 ;;
62 2)
63 exit 1
64 ;;

--- 25 unchanged lines hidden (view full) ---

90
91set -T
92trap "echo 'Reboot interrupted'; exit 1" 3
93
94# root normally must be read/write, but if this is a BOOTP NFS
95# diskless boot it does not have to be.
96#
97
57 echo Automatic reboot in progress...
58 fsck -p
59 case $? in
60 0)
61 ;;
62 2)
63 exit 1
64 ;;

--- 25 unchanged lines hidden (view full) ---

90
91set -T
92trap "echo 'Reboot interrupted'; exit 1" 3
93
94# root normally must be read/write, but if this is a BOOTP NFS
95# diskless boot it does not have to be.
96#
97
98if [ "X$root_rw_mount" != "XNO" ]; then
98if [ "${root_rw_mount}" != "NO" ]; then
99 mount -u -o rw /
100fi
101
102if [ $? != 0 ]; then
103 echo "Filesystem mount failed, startup aborted"
104 exit 1
105fi
106
107umount -a >/dev/null 2>&1
108
99 mount -u -o rw /
100fi
101
102if [ $? != 0 ]; then
103 echo "Filesystem mount failed, startup aborted"
104 exit 1
105fi
106
107umount -a >/dev/null 2>&1
108
109if [ "X$early_nfs_mounts" != "XYES" ]; then
109if [ "${early_nfs_mounts}" != "YES" ]; then
110 mount -a -t nonfs
111else
112 mount -a
113fi
114if [ $? != 0 ]; then
115 echo "Filesystem mount failed, startup aborted"
116 exit 1
117fi
118
119# Run custom disk mounting function here
120#
121
110 mount -a -t nonfs
111else
112 mount -a
113fi
114if [ $? != 0 ]; then
115 echo "Filesystem mount failed, startup aborted"
116 exit 1
117fi
118
119# Run custom disk mounting function here
120#
121
122if [ "X$diskless_mount" != "X" ]; then
123 if [ -f $diskless_mount ]; then
124 sh $diskless_mount
122if [ -n "${diskless_mount}" ]; then
123 if [ -f "${diskless_mount}" ]; then
124 sh ${diskless_mount}
125 fi
126fi
127
128adjkerntz -i
129
130clean_var() {
131 if [ ! -f /var/run/clean_var ]; then
132 rm -rf /var/run/*

--- 10 unchanged lines hidden (view full) ---

143if [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then
144 # network_pass1() *may* end up writing stuff to /var - we don't want to
145 # remove it immediately afterwards - *nor* to we want to fail to clean
146 # an nfs-mounted /var.
147 clean_var
148fi
149
150# Add additional swapfile, if configured.
125 fi
126fi
127
128adjkerntz -i
129
130clean_var() {
131 if [ ! -f /var/run/clean_var ]; then
132 rm -rf /var/run/*

--- 10 unchanged lines hidden (view full) ---

143if [ -d /var/run -a -d /var/spool/lock -a -d /var/spool/uucp/.Temp ]; then
144 # network_pass1() *may* end up writing stuff to /var - we don't want to
145 # remove it immediately afterwards - *nor* to we want to fail to clean
146 # an nfs-mounted /var.
147 clean_var
148fi
149
150# Add additional swapfile, if configured.
151if [ "x$swapfile" != "xNO" -a -w "$swapfile" -a -b /dev/vn0b ]; then
152 echo "Adding $swapfile as additional swap."
153 vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b
151if [ "${swapfile}" != "NO" -a -w "${swapfile}" -a -b /dev/vn0b ]; then
152 echo "Adding ${swapfile} as additional swap."
153 vnconfig /dev/vn0b ${swapfile} && swapon /dev/vn0b
154fi
155
156# set sysctl variables early as we can
157if [ -f /etc/rc.sysctl ]; then
158 . /etc/rc.sysctl
159fi
160
161# configure serial devices

--- 28 unchanged lines hidden (view full) ---

190#
191# Clearing /tmp at boot-time seems to have a long tradition. It doesn't
192# help in any way for long-living systems, and it might accidentally
193# clobber files you would rather like to have preserved after a crash
194# (if not using mfs /tmp anyway).
195#
196# See also the example of another cleanup policy in /etc/periodic/daily.
197#
154fi
155
156# set sysctl variables early as we can
157if [ -f /etc/rc.sysctl ]; then
158 . /etc/rc.sysctl
159fi
160
161# configure serial devices

--- 28 unchanged lines hidden (view full) ---

190#
191# Clearing /tmp at boot-time seems to have a long tradition. It doesn't
192# help in any way for long-living systems, and it might accidentally
193# clobber files you would rather like to have preserved after a crash
194# (if not using mfs /tmp anyway).
195#
196# See also the example of another cleanup policy in /etc/periodic/daily.
197#
198if [ "X${clear_tmp_enable}" = X"YES" ]; then
198if [ "${clear_tmp_enable}" = "YES" ]; then
199 echo clearing /tmp
200
201 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
202 # (not needed with mfs /tmp, but doesn't hurt there...)
203 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
204 find -d . ! -name . ! -name lost+found ! -name quota.user \
205 ! -name quota.group -exec rm -rf -- {} \;)
206

--- 5 unchanged lines hidden (view full) ---

212
213# snapshot any kernel -c changes back to disk here <someday>
214# this has changed with ELF and /kernel.config.
215
216echo -n 'additional daemons:'
217# start system logging and name service (named needs to start before syslogd
218# if you don't have a /etc/resolv.conf)
219#
199 echo clearing /tmp
200
201 # prune quickly with one rm, then use find to clean up /tmp/[lq]*
202 # (not needed with mfs /tmp, but doesn't hurt there...)
203 (cd /tmp && rm -rf [a-km-pr-zA-Z]* &&
204 find -d . ! -name . ! -name lost+found ! -name quota.user \
205 ! -name quota.group -exec rm -rf -- {} \;)
206

--- 5 unchanged lines hidden (view full) ---

212
213# snapshot any kernel -c changes back to disk here <someday>
214# this has changed with ELF and /kernel.config.
215
216echo -n 'additional daemons:'
217# start system logging and name service (named needs to start before syslogd
218# if you don't have a /etc/resolv.conf)
219#
220if [ "X${syslogd_enable}" = X"YES" ]; then
220if [ "${syslogd_enable}" = "YES" ]; then
221 # Transitional symlink (for the next couple of years :) until all
222 # binaries had a chance to move towards /var/run/log.
223 if [ ! -h /dev/log ] ; then
224 # might complain for r/o root f/s
225 ln -sf /var/run/log /dev/log
226 fi
227
228 rm -f /var/run/log
229 echo -n ' syslogd'; syslogd ${syslogd_flags}
230fi
231echo '.'
232
233# enable dumpdev so that savecore can see it
234# /var/crash should be a directory or a symbolic link
235# to the crash directory if core dumps are to be saved.
221 # Transitional symlink (for the next couple of years :) until all
222 # binaries had a chance to move towards /var/run/log.
223 if [ ! -h /dev/log ] ; then
224 # might complain for r/o root f/s
225 ln -sf /var/run/log /dev/log
226 fi
227
228 rm -f /var/run/log
229 echo -n ' syslogd'; syslogd ${syslogd_flags}
230fi
231echo '.'
232
233# enable dumpdev so that savecore can see it
234# /var/crash should be a directory or a symbolic link
235# to the crash directory if core dumps are to be saved.
236if [ "X${dumpdev}" != X"NO" -a -e ${dumpdev} -a -d /var/crash ]; then
236if [ "${dumpdev}" != "NO" -a -e ${dumpdev} -a -d /var/crash ]; then
237 dumpon ${dumpdev}
238 echo -n checking for core dump...
239 savecore /var/crash
240fi
241
237 dumpon ${dumpdev}
238 echo -n checking for core dump...
239 savecore /var/crash
240fi
241
242if [ -n "$network_pass1_done" ]; then
242if [ -n "${network_pass1_done}" ]; then
243 network_pass2
244fi
245
246# Enable/Check the quotas (must be after ypbind if using NIS)
243 network_pass2
244fi
245
246# Enable/Check the quotas (must be after ypbind if using NIS)
247if [ "X${enable_quotas}" = X"YES" ]; then
247if [ "${enable_quotas}" = "YES" ]; then
248
249 # Only check quotas if they have been previously enabled, and requested
248
249 # Only check quotas if they have been previously enabled, and requested
250 if [ "X${check_quotas}" = X"YES" ]; then
250 if [ "${check_quotas}" = "YES" ]; then
251 echo -n 'checking quotas:'
252 quotacheck -a
253 echo ' done.'
254 fi
255
256 echo -n 'enabling quotas:'
257 quotaon -a
258 echo ' done.'
259fi
260
251 echo -n 'checking quotas:'
252 quotacheck -a
253 echo ' done.'
254 fi
255
256 echo -n 'enabling quotas:'
257 quotaon -a
258 echo ' done.'
259fi
260
261if [ -n "$network_pass2_done" ]; then
261if [ -n "${network_pass2_done}" ]; then
262 network_pass3
263fi
264
265
266# build ps databases
267kvm_mkdb
268dev_mkdb
269
270# check the password temp/lock file
271if [ -f /etc/ptmp ]
272then
273 logger -s -p auth.err \
274 "password file may be incorrect -- /etc/ptmp exists"
275fi
276
262 network_pass3
263fi
264
265
266# build ps databases
267kvm_mkdb
268dev_mkdb
269
270# check the password temp/lock file
271if [ -f /etc/ptmp ]
272then
273 logger -s -p auth.err \
274 "password file may be incorrect -- /etc/ptmp exists"
275fi
276
277if [ "X${accounting_enable}" = X"YES" -a -d /var/account ]; then
277if [ "${accounting_enable}" = "YES" -a -d /var/account ]; then
278 echo 'turning on accounting'
279 if [ ! -e /var/account/acct ]; then
280 touch /var/account/acct
281 fi
282 accton /var/account/acct
283fi
284
285# Make shared lib searching a little faster. Leave /usr/lib first if you
286# add your own entries or you may come to grief.
287if [ -x /sbin/ldconfig ]; then
278 echo 'turning on accounting'
279 if [ ! -e /var/account/acct ]; then
280 touch /var/account/acct
281 fi
282 accton /var/account/acct
283fi
284
285# Make shared lib searching a little faster. Leave /usr/lib first if you
286# add your own entries or you may come to grief.
287if [ -x /sbin/ldconfig ]; then
288 if [ X"`/usr/bin/objformat`" = X"elf" ]; then
288 if [ "`/usr/bin/objformat`" = "elf" ]; then
289 _LDC=/usr/lib
289 _LDC=/usr/lib
290 for i in $ldconfig_paths; do
291 if test -d $i; then
292 _LDC="${_LDC} $i"
290 for i in ${ldconfig_paths}; do
291 if test -d ${i}; then
292 _LDC="${_LDC} ${i}"
293 fi
294 done
295 echo 'setting ELF ldconfig path:' ${_LDC}
296 ldconfig -elf ${_LDC}
297 fi
298
299 # Legacy aout support for i386 only
293 fi
294 done
295 echo 'setting ELF ldconfig path:' ${_LDC}
296 ldconfig -elf ${_LDC}
297 fi
298
299 # Legacy aout support for i386 only
300 if [ X"`sysctl -n hw.machine`" = X"i386" ]; then
300 if [ "`sysctl -n hw.machine`" = "i386" ]; then
301 # Default the a.out ldconfig path.
302 : ${ldconfig_paths_aout=${ldconfig_paths}}
303 _LDC=/usr/lib/aout
301 # Default the a.out ldconfig path.
302 : ${ldconfig_paths_aout=${ldconfig_paths}}
303 _LDC=/usr/lib/aout
304 for i in $ldconfig_paths_aout; do
305 if test -d $i; then
306 _LDC="${_LDC} $i"
304 for i in ${ldconfig_paths_aout}; do
305 if test -d ${i}; then
306 _LDC="${_LDC} ${i}"
307 fi
308 done
309 echo 'setting a.out ldconfig path:' ${_LDC}
310 ldconfig -aout ${_LDC}
311 fi
312fi
313
314# Now start up miscellaneous daemons that don't belong anywhere else
315#
316echo -n starting standard daemons:
307 fi
308 done
309 echo 'setting a.out ldconfig path:' ${_LDC}
310 ldconfig -aout ${_LDC}
311 fi
312fi
313
314# Now start up miscellaneous daemons that don't belong anywhere else
315#
316echo -n starting standard daemons:
317if [ "X${inetd_enable}" != X"NO" ]; then
317if [ "${inetd_enable}" != "NO" ]; then
318 echo -n ' inetd'; inetd ${inetd_flags}
319fi
320
318 echo -n ' inetd'; inetd ${inetd_flags}
319fi
320
321if [ "X${cron_enable}" != X"NO" ]; then
321if [ "${cron_enable}" != "NO" ]; then
322 echo -n ' cron'; cron
323fi
324
322 echo -n ' cron'; cron
323fi
324
325if [ "X${lpd_enable}" = X"YES" ]; then
325if [ "${lpd_enable}" = "YES" ]; then
326 echo -n ' printer'; ${lpd_program} ${lpd_flags}
327fi
328
326 echo -n ' printer'; ${lpd_program} ${lpd_flags}
327fi
328
329if [ "X${sendmail_enable}" = X"YES" -a -r /etc/sendmail.cf ]; then
329if [ "${sendmail_enable}" = "YES" -a -r /etc/sendmail.cf ]; then
330 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
331fi
332
330 echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags}
331fi
332
333if [ "X${usbd_enable}" = X"YES" ]; then
333if [ "${usbd_enable}" = "YES" ]; then
334 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags}
335fi
336
337echo '.'
338
339# configure implementation specific stuff
340arch=`uname -m`
341if [ -f /etc/rc.${arch} ]; then
342 . /etc/rc.${arch}
343fi
344
345# Recover vi editor files.
346vibackup=`echo /var/tmp/vi.recover/vi.*`
334 echo -n ' usbd'; /usr/sbin/usbd ${usbd_flags}
335fi
336
337echo '.'
338
339# configure implementation specific stuff
340arch=`uname -m`
341if [ -f /etc/rc.${arch} ]; then
342 . /etc/rc.${arch}
343fi
344
345# Recover vi editor files.
346vibackup=`echo /var/tmp/vi.recover/vi.*`
347if [ "$vibackup" != '/var/tmp/vi.recover/vi.*' ]; then
347if [ "${vibackup}" != '/var/tmp/vi.recover/vi.*' ]; then
348 echo 'Recovering vi editor sessions'
348 echo 'Recovering vi editor sessions'
349 for i in $vibackup; do
349 for i in ${vibackup}; do
350 # Only test files that are readable.
350 # Only test files that are readable.
351 if test ! -r $i; then
351 if test ! -r ${i}; then
352 continue
353 fi
354
355 # Unmodified nvi editor backup files either have the
356 # execute bit set or are zero length. Delete them.
352 continue
353 fi
354
355 # Unmodified nvi editor backup files either have the
356 # execute bit set or are zero length. Delete them.
357 if test -x $i -o ! -s $i; then
358 rm -f $i
357 if test -x ${i} -o ! -s ${i}; then
358 rm -f ${i}
359 fi
360 done
361
362 # It is possible to get incomplete recovery files, if the editor
363 # crashes at the right time.
364 virecovery=`echo /var/tmp/vi.recover/recover.*`
359 fi
360 done
361
362 # It is possible to get incomplete recovery files, if the editor
363 # crashes at the right time.
364 virecovery=`echo /var/tmp/vi.recover/recover.*`
365 if [ "$virecovery" != "/var/tmp/vi.recover/recover.*" ]; then
366 for i in $virecovery; do
365 if [ "${virecovery}" != "/var/tmp/vi.recover/recover.*" ]; then
366 for i in ${virecovery}; do
367 # Only test files that are readable.
367 # Only test files that are readable.
368 if test ! -r $i; then
368 if test ! -r ${i}; then
369 continue
370 fi
371
372 # Delete any recovery files that are zero length,
373 # corrupted, or that have no corresponding backup file.
374 # Else send mail to the user.
369 continue
370 fi
371
372 # Delete any recovery files that are zero length,
373 # corrupted, or that have no corresponding backup file.
374 # Else send mail to the user.
375 recfile=`awk '/^X-vi-recover-path:/{print $2}' < $i`
376 if test -n "$recfile" -a -s "$recfile"; then
377 sendmail -t < $i
375 recfile=`awk '/^X-vi-recover-path:/{print $2}' < ${i}`
376 if test -n "${recfile}" -a -s "${recfile}"; then
377 sendmail -t < ${i}
378 else
378 else
379 rm -f $i
379 rm -f ${i}
380 fi
381 done
382 fi
383fi
384
385# make a bounds file for msgs(1) if there isn't one already
386if [ ! -f /var/msgs/bounds ]; then
387 echo 0 > /var/msgs/bounds
388fi
389
390# for each valid dir in $local_startup, search for init scripts matching *.sh
380 fi
381 done
382 fi
383fi
384
385# make a bounds file for msgs(1) if there isn't one already
386if [ ! -f /var/msgs/bounds ]; then
387 echo 0 > /var/msgs/bounds
388fi
389
390# for each valid dir in $local_startup, search for init scripts matching *.sh
391if [ "X${local_startup}" != X"NO" ]; then
391if [ "${local_startup}" != "NO" ]; then
392 echo -n 'Local package initialization:'
393 for dir in ${local_startup}; do
394 [ -d ${dir} ] && for script in ${dir}/*.sh; do
395 [ -x ${script} ] && \
396 (set -T ; trap 'exit 1' 2 ; ${script} start)
397 done
398 done
399 echo .
400fi
401
392 echo -n 'Local package initialization:'
393 for dir in ${local_startup}; do
394 [ -d ${dir} ] && for script in ${dir}/*.sh; do
395 [ -x ${script} ] && \
396 (set -T ; trap 'exit 1' 2 ; ${script} start)
397 done
398 done
399 echo .
400fi
401
402if [ "X${update_motd}" != X"NO" ]; then
402if [ "${update_motd}" != "NO" ]; then
403 T=`mktemp /tmp/_motd.XXXXXX`
404 if [ $? -eq 0 ]; then
403 T=`mktemp /tmp/_motd.XXXXXX`
404 if [ $? -eq 0 ]; then
405 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > $T
406 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> $T
407 cmp -s $T /etc/motd || {
408 cp $T /etc/motd
405 uname -v | sed -e 's,^\([^#]*\) #\(.* [1-2][0-9][0-9][0-9]\).*/\([^\]*\) $,\1 (\3) #\2,' > ${T}
406 awk '{if (NR == 1) {if ($1 == "FreeBSD") {next} else {print "\n"$0}} else {print}}' < /etc/motd >> ${T}
407 cmp -s ${T} /etc/motd || {
408 cp ${T} /etc/motd
409 chmod 644 /etc/motd
410 }
409 chmod 644 /etc/motd
410 }
411 rm -f $T
411 rm -f ${T}
412 fi
413fi
414
415# Run rc.devfs if present to customize devfs
416[ -f /etc/rc.devfs ] && sh /etc/rc.devfs
417
418# Do traditional (but rather obsolete) rc.local file if it exists. If you
419# use this file and want to make it programmatic, source /etc/defaults/rc.conf

--- 12 unchanged lines hidden (view full) ---

432if [ -f /etc/rc.local ]; then
433 echo -n 'starting local daemons:'
434 sh /etc/rc.local
435 echo '.'
436fi
437
438# Raise kernel security level. This should be done only after `fsck' has
439# repaired local file systems if you want the securelevel to be greater than 1.
412 fi
413fi
414
415# Run rc.devfs if present to customize devfs
416[ -f /etc/rc.devfs ] && sh /etc/rc.devfs
417
418# Do traditional (but rather obsolete) rc.local file if it exists. If you
419# use this file and want to make it programmatic, source /etc/defaults/rc.conf

--- 12 unchanged lines hidden (view full) ---

432if [ -f /etc/rc.local ]; then
433 echo -n 'starting local daemons:'
434 sh /etc/rc.local
435 echo '.'
436fi
437
438# Raise kernel security level. This should be done only after `fsck' has
439# repaired local file systems if you want the securelevel to be greater than 1.
440if [ "X${kern_securelevel_enable}" = X"YES" -a "${kern_securelevel}" -ge 0 ];
440if [ "${kern_securelevel_enable}" = "YES" -a "${kern_securelevel}" -ge 0 ];
441then
442 echo 'Raising kernel security level'
443 sysctl -w kern.securelevel=${kern_securelevel}
444fi
445
446date
447exit 0
441then
442 echo 'Raising kernel security level'
443 sysctl -w kern.securelevel=${kern_securelevel}
444fi
445
446date
447exit 0