rc revision 17998
1257453Sian#!/bin/sh 2257453Sian# $Id: rc,v 1.97 1996/08/21 23:15:36 jkh Exp $ 3266201Sian# From: @(#)rc 5.27 (Berkeley) 6/5/91 4257453Sian 5257453Sian# System startup script run by init on autoboot 6257453Sian# or after single-user. 7257453Sian# Output and error are redirected to console by init, 8257453Sian# and the console is the controlling terminal. 9257453Sian 10257453Sian# Note that almost all the user-configurable behavior is no longer in 11257453Sian# this file, but rather in /etc/sysconfig. Please check this file 12257453Sian# first before contemplating any changes here. 13257453Sian 14257453Sianstty status '^T' 15257453Sian 16257453Sian# Set shell to ignore SIGINT (2), but not children; 17257453Sian# shell catches SIGQUIT (3) and returns to single user after fsck. 18257453Siantrap : 2 19257453Siantrap : 3 # shouldn't be needed 20257453Sian 21257453SianHOME=/; export HOME 22257453SianPATH=/sbin:/bin:/usr/sbin:/usr/bin 23257453Sianexport PATH 24257453Sian 25257453Sian# Configure ccd devices. 26257453Sianif [ -f /etc/ccd.conf ] 27257453Sianthen 28257453Sian ccdconfig -C 29257453Sianfi 30257453Sian 31257453Sianswapon -a 32257453Sian 33266201Sianif [ $1x = autobootx ] 34266201Sianthen 35257453Sian echo Automatic reboot in progress... 36257453Sian fsck -p 37257453Sian case $? in 38257453Sian 0) 39257453Sian ;; 40257453Sian 2) 41257453Sian exit 1 42257453Sian ;; 43257453Sian 4) 44257453Sian reboot 45257453Sian echo "reboot failed... help!" 46257453Sian exit 1 47257453Sian ;; 48266201Sian 8) 49266201Sian echo "Automatic file system check failed... help!" 50266201Sian exit 1 51266201Sian ;; 52266201Sian 12) 53266201Sian echo "Reboot interrupted" 54257453Sian exit 1 55257453Sian ;; 56257453Sian 130) 57257453Sian # interrupt before catcher installed 58266201Sian exit 1 59257453Sian ;; 60266352Sian *) 61266201Sian echo "Unknown error in reboot" 62257453Sian exit 1 63257453Sian ;; 64257453Sian esac 65257453Sianelse 66257453Sian echo Skipping disk checks ... 67257453Sianfi 68257453Sian 69257453Siantrap "echo 'Reboot interrupted'; exit 1" 3 70266207Sian 71257453Sian# root must be read/write both for NFS diskless and for VFS LKMs before 72266348Sian# proceeding any further. 73266201Sianmount -u -o rw / 74266201Sianif [ $? != 0 ]; then 75257453Sian echo "Filesystem mount failed, startup aborted" 76257453Sian exit 1 77257453Sianfi 78266352Sian 79266352Sianumount -a >/dev/null 2>&1 80266201Sian 81266201Sianmount -a -t nonfs 82266201Sianif [ $? != 0 ]; then 83266201Sian echo "Filesystem mount failed, startup aborted" 84266201Sian exit 1 85266201Sianfi 86266201Sian 87266201Sianadjkerntz -i 88257453Sian 89257453Sian# If there is a global system configuration file, suck it in. 90266201Sianif [ -f /etc/sysconfig ]; then 91266201Sian . /etc/sysconfig 92266207Sianfi 93266352Sian 94266207Sian# Add additional swapfile, if configured. 95266352Sianif [ "x$swapfile" != "xNO" -a -w $swapfile -a -f /dev/vn0b ]; then 96266207Sian echo "Adding $swapfile as additional swap." 97266352Sian /usr/sbin/vnconfig /dev/vn0b $swapfile && swapon /dev/vn0b 98266352Sianfi 99266352Sian 100266201Sian# configure serial devices 101266201Sianif [ -f /etc/rc.serial ]; then 102266201Sian . /etc/rc.serial 103266201Sianfi 104266201Sian 105266201Sian# start up PC-card configuration 106266201Sianif [ -f /etc/rc.pccard ]; then 107266201Sian . /etc/rc.pccard 108266201Sianfi 109266201Sian 110257453Sian# start up the network 111257453Sianif [ -f /etc/netstart ]; then 112257453Sian sh /etc/netstart 113257453Sianfi 114266201Sian 115266352Sianmount -a -t nfs >/dev/null 2>&1 116266352Sian 117266201Sian# Whack the pty perms back into shape. 118266352Sianchmod 666 /dev/tty[pqrs]* 119266352Sian 120266352Sian# clean up left-over files 121266352Sianrm -f /etc/nologin 122266352Sianrm -f /var/spool/lock/* 123266352Sianrm -rf /var/spool/uucp/.Temp/* 124266352Sianrm -f /dev/log 125266352Sian(cd /var/run && { cp /dev/null utmp; chmod 644 utmp; }) 126266352Sian 127266201Sian# 128266201Sian# Clearing /tmp at boot-time is essentially stupid, but seems to have 129266352Sian# a long tradition. It doesn't help in any way for long-living systems, 130266352Sian# and it might accidentally clobber files you would rather like to have 131266352Sian# preserved after a crash (if not using mfs /tmp anyway). 132266352Sian# 133266352Sian# See also the commented out example of another cleanup policy in 134266352Sian# /etc/daily. 135266352Sian# 136266201Sianecho clearing /tmp 137266201Sian 138257453Sian# prune quickly with one rm, then use find to clean up /tmp/[lq]* 139257453Sian# (not needed with mfs /tmp, but doesn't hurt there...) 140257453Sian(cd /tmp && rm -rf [a-km-pr-zA-Z]* && 141257453Sian find -d . ! -name . ! -name lost+found ! -name quotas -exec rm -rf -- {} \;) 142266201Sian 143266201Sian# The above is even more stupid since it prevents you from restarting 144266201Sian# X11 after a system crash. If you disable the above, make sure to 145257453Sian# uncomment the line below. 146257453Sian# 147257453Sian# clean up leftover X lock files and local connection sockets 148257453Sian#rm -f /tmp/.X*-lock /tmp/.X11-unix/* 149257453Sian 150257453Sian 151266201Sian# enable dumpdev so that savecore can see it 152266201Sianif [ "X${dumpdev}" != X"NO" ]; then 153266201Sian dumpon ${dumpdev} 154257453Sianfi 155257453Sian 156266207Sian# /var/crash should be a directory or a symbolic link 157266207Sian# to the crash directory if core dumps are to be saved. 158266207Sianif [ "X${savecore}" = X"YES" -a -d /var/crash ]; then 159266207Sian echo -n checking for core dump... 160266207Sian savecore /var/crash 161266207Sianfi 162266207Sian 163266207Sian# snapshot any kernel -c changes back to disk 164266207Sianecho 'recording kernel -c changes' 165266207Sian/sbin/dset -q 166266207Sian 167266207Sian# Check the quotas 168266207Sianif [ "X${check_quotas}" = X"YES" ]; then 169266207Sian echo 'checking quotas:' 170266207Sian quotacheck -a 171266207Sian echo ' done.' 172266207Sian quotaon -a 173266207Sianfi 174266207Sian 175266207Sian# start system logging and name service (named needs to start before syslogd 176266207Sian# if you don't have a /etc/resolv.conf) 177266207Sian# 178266207Sianecho -n starting system daemons: 179266207Sian 180266207Sianecho ' syslogd.'; syslogd 181266207Sian 182266207Sianecho -n starting network daemons: 183266207Sian 184266207Sian# $namedflags is imported from /etc/sysconfig 185266207Sianif [ "X${namedflags}" != X"NO" ]; then 186266207Sian echo -n ' named'; named $namedflags 187266207Sianfi 188266207Sian 189266207Sian# $ntpdate and $xntpdflags are imported from /etc/sysconfig. 190266207Sian# If $ntpdate != NO, run ntpdate $ntpdate to set the date correctly. 191266207Sian# If $xntpdflags != NO, start xntpd. 192266207Sianif [ "X${ntpdate}" != X"NO" -o "X${xntpdflags}" != X"NO" ]; then 193266207Sian if [ "X${tickadjflags}" != X"NO" ]; then 194266207Sian echo -n ' tickadj'; tickadj ${tickadjflags--Aq} 195266207Sian fi 196266207Sian 197266207Sian if [ "X${ntpdate}" != X"NO" ]; then 198266207Sian echo -n ' ntpdate'; ntpdate ${ntpdate} >/dev/null 2>&1 199266207Sian fi 200266207Sian 201266207Sian if [ "X${xntpdflags}" != X"NO" ]; then 202266207Sian echo -n ' xntpd'; xntpd ${xntpdflags} 203266207Sian fi 204266207Sianfi 205266207Sian 206266207Sian# $timedflags is imported from /etc/sysconfig; 207266207Sian# if $timedflags == NO, timed isn't run. 208266207Sianif [ "X${timedflags}" != X"NO" ]; then 209266207Sian echo -n ' timed'; timed $timedflags 210266207Sianfi 211266207Sian 212266207Sian# Portmapper should always be run, to provide RPC services for inetd. 213266201Sianif [ -x /usr/sbin/portmap ]; then 214266352Sian echo -n ' portmap'; portmap 215266201Sianfi 216266201Sian 217266352Sian# Start ypserv if we're an NIS server. 218266201Sian# Run yppasswdd only on the NIS master server 219266201Sianif [ "X${nis_serverflags}" != X"NO" ]; then 220266201Sian echo -n ' ypserv'; ypserv ${nis_serverflags} 221266352Sian 222266201Sian if [ "X${yppasswddflags}" != X"NO" ]; then 223266201Sian echo -n ' yppasswdd'; rpc.yppasswdd ${yppasswddflags} 224266352Sian fi 225266201Sianfi 226266201Sian 227266201Sian# Start ypbind if we're an NIS client 228266352Sianif [ "X${nis_clientflags}" != X"NO" ]; then 229266201Sian echo -n ' ypbind'; ypbind ${nis_clientflags} 230266201Sian if [ "X${nis_ypsetflags}" != X"NO" ]; then 231266352Sian echo -n ' ypset'; ypset ${nis_ypsetflags} 232266201Sian fi 233266201Sianfi 234266352Sian 235266352Sian# $rwhod is imported from /etc/sysconfig; 236266352Sian# if $rwhod is set to YES, rwhod is run. 237266352Sianif [ "X${rwhod}" = X"YES" ]; then 238266352Sian echo -n ' rwhod'; rwhod 239266352Sianfi 240266352Sian 241266352Sianif [ "X${nfs_server}" = X"YES" -a -r /etc/exports ]; then 242266352Sian echo -n ' mountd' 243266352Sian if [ "X${weak_mountd_authentication}" = X"YES" ]; then 244266352Sian mountd -n 245266352Sian else 246266352Sian mountd 247266352Sian fi 248266352Sian echo -n ' nfsd'; nfsd -u -t 4 249266352Sianfi 250266352Sian 251266352Sianif [ "X${nfs_client}" = X"YES" ]; then 252266352Sian echo -n ' nfsiod'; nfsiod -n 4 253266352Sianfi 254266201Sian 255266352Sianif [ "X${amdflags}" != X"NO" ]; then 256266201Sian echo -n ' amd' 257266352Sian amd ${amdflags} > /var/run/amd.pid 258266201Sianfi 259266352Sian 260266352Sian# Kerberos runs ONLY on the Kerberos server machine 261266352Sianif [ "X${kerberos_server}" = X"YES" ]; then 262266352Sian echo -n ' kerberos'; kerberos >> /var/log/kerberos.log & 263266201Sian echo -n ' kadmind'; \ 264266201Sian (sleep 20; kadmind -n >/dev/null 2>&1 &) & 265266201Sianfi 266266201Sian 267266201Sian# IP multicast routing daemon 268266201Sianif [ "X${mrouted}" != X"NO" -a -x /usr/sbin/mrouted ]; then 269266201Sian echo -n ' mrouted'; mrouted ${mrouted} 270266201Sianfi 271266352Sian 272266201Sianecho -n ' inetd'; inetd 273266201Sianecho '.' 274266201Sian 275266201Sian# build ps databases 276266201Siankvm_mkdb 277266201Siandev_mkdb 278266201Sian 279266201Sian# check the password temp/lock file 280266352Sianif [ -f /etc/ptmp ] 281266201Sianthen 282266201Sian logger -s -p auth.err \ 283266201Sian "password file may be incorrect -- /etc/ptmp exists" 284266201Sianfi 285266201Sian 286266201Sianif [ "X${accounting}" = X"YES" -a -d /var/account ]; then 287266201Sian echo 'turning on accounting' 288266201Sian if [ ! -e /var/account/acct ]; then 289266201Sian touch /var/account/acct 290266201Sian fi 291266348Sian accton /var/account/acct 292266352Sianfi 293266352Sian 294266352Sian# Make shared lib searching a little faster. Leave /usr/lib first if you 295266352Sian# add your own entries or you may come to grief. 296266352Sianif [ -x /sbin/ldconfig ]; then 297266352Sian _LDC=/usr/lib 298266352Sian if [ -d /usr/lib/compat ]; then _LDC="${_LDC} /usr/lib/compat" ; fi 299266352Sian if [ -d /usr/X11R6/lib ]; then _LDC="${_LDC} /usr/X11R6/lib" ; fi 300266201Sian if [ -d /usr/X386/lib ]; then _LDC="${_LDC} /usr/X386/lib" ; fi 301266201Sian if [ -d /usr/local/lib ]; then _LDC="${_LDC} /usr/local/lib" ; fi 302266352Sian echo 'setting ldconfig path:' ${_LDC} 303266352Sian ldconfig ${_LDC} 304266352Sianfi 305266352Sian 306266352Sian# Now start up miscellaneous daemons that don't belong anywhere else 307266352Sian# 308266352Sianecho -n standard daemons: 309266352Sianecho -n ' cron'; cron 310266352Sian 311266352Sianif [ "X${lpd}" != X"NO" -a -x /usr/sbin/lpd ]; then 312266352Sian echo -n ' printer'; lpd 313266352Sianfi 314266352Sian 315266352Sian# $sendmail_flags is imported from /etc/sysconfig; 316266352Sian# if $sendmail_flags is something other than NO, sendmail is run. 317266352Sianif [ "X${sendmail_flags}" != X"NO" -a -r /etc/sendmail.cf ]; then 318266352Sian echo -n ' sendmail'; /usr/sbin/sendmail ${sendmail_flags} 319266352Sianfi 320266352Sian 321266352Sianecho '.' 322266352Sian 323266352Sian# configure implementation specific stuff 324266352Sianarch=`uname -m` 325266352Sianif [ -f /etc/rc.${arch} ]; then 326266352Sian . /etc/rc.${arch} 327266352Sianfi 328266352Sian 329266352Sian# Recover vi editor files. 330266352Sianvirecovery=`echo /var/tmp/vi.recover/recover.*` 331266352Sianif [ "$virecovery" != '/var/tmp/vi.recover/recover.*' ]; then 332266352Sian echo 'Recovering vi editor sessions' 333266352Sian for i in $virecovery; do 334266352Sian sendmail -t < $i 335266352Sian done 336266352Sianfi 337266352Sian 338266352Sian# for each valid dir in $local_startup, search for init scripts matching *.sh 339266352Sianif [ "X${local_startup}" != X"NO" ]; then 340266352Sian echo -n 'Local package startup:' 341266352Sian for dir in ${local_startup}; do 342266352Sian [ -d ${dir} ] && for script in ${dir}/*.sh; do 343266352Sian [ -x ${script} ] && ${script} start 344266352Sian done 345266352Sian done 346266352Sian echo . 347266352Sianfi 348266352Sian 349266352Sian# Do traditional (but rather obsolete) rc.local file if it exists. 350266352Sian[ -f /etc/rc.local ] && sh /etc/rc.local 351266352Sian 352266352Siandate 353266352Sianexit 0 354266352Sian