home *** CD-ROM | disk | FTP | other *** search
/ NeXTSTEP 3.0 / NeXTSTEP3.0.iso / private / etc / rc.standD6E < prev    next >
Text File  |  1992-05-28  |  16KB  |  498 lines

  1. #!/bin/sh -u
  2. #
  3. # This is the multi-user startup script.
  4. #
  5. # Copyright (C) 1992 by NeXT Computer, Inc.  All rights reserved.
  6. #
  7. # Note that all "echo" commands are in parentheses so that
  8. # the main shell does not open a tty and get its process group set.
  9.  
  10. HOME=/; export HOME
  11. PATH=/etc:/usr/etc:/bin:/usr/bin; export PATH
  12.  
  13. # Are we booting from a CD-ROM?  If so, switch over to /etc/rc.cdrom.
  14.  
  15. if [ -d /NextCD -a -D89tc/rc.cdrom ]; then
  16.     sh /etc/rc.cdrom $1
  17.     echo "CD-ROM boot procedure complete.  Shutting down..."
  18.     /etc/halt -e
  19.     exit 0
  20. fi
  21.  
  22. # Determine if the network is up; this is used later when deciding
  23. # whether various daemons should run.  netstat -i enumerates all the 
  24. # known interfaces. Those with a '*' in their names are configured down.
  25. # Count the interfaces which are up.
  26.  
  27. NINTERFACES=`/usr/ucb/netstat -i | egrep -v '^Name|\*' | /usr/ucb/wc -l`
  28.  
  29. # The loopback interface is always enabled.  Only if we find other
  30. # interfaces do we think we are really connected to a network.
  31.  
  32. if [  $NINTERFACES -ne 1 ]; then
  33.     NETWORKUP=-YES-
  34. else
  35.     NETWORKUP=-NO-
  36. fi
  37.  
  38. # Print out an appropriate message.  MESSAGE is used later in the log.
  39.  
  40. if  [ $1x = autobootx ]; then
  41.     # (echo Automatic reboot in progress...)        >/dev/console
  42.     MESSAGE="Reboot"
  43. else
  44.     (echo Multiuser startup in progress...)            >/dev/console
  45.     MESSAGE="Multi-user startup"
  46. fi
  47.  
  48. # Check for and mount swapdisks.
  49. sh /etc/rc.swap $1
  50.  
  51. # Mount local filesystems (according to /etc/fstab).
  52. mount -vat 4.3                        >/dev/console 2>&1
  53.  
  54. # Display a message in the iconic boot window.
  55. fbshow -A -B -E -I "Checking*System*Files..."
  56.  
  57. # Attempt to recover the passwd file, if needed.  This procedure is
  58. # primarily historical and makes sense only when the passwd file is edited
  59. # using the vipw command.  
  60.  
  61. if [ -s /etc/ptmp ]; then
  62.     if [ -s /etc/passwd ]; then
  63.         (echo 'Passwd file conflict with ptmp:')    >/dev/console
  64.         ls -l /etc/passwd /etc/ptmp            >/dev/console
  65.         (echo 'Moving ptmp to ptmp.save.')        >/dev/console
  66.         mv -f /etc/ptmp /etc/ptmp.save
  67.     else
  68.         (echo 'Passwd file recovered from ptmp.')     >/dev/console
  69.         mv /etc/ptmp /etc/passwd
  70.     fi
  71. elif [ -r /etc/ptmp ]; then
  72.     (echo 'Removing passwd lock file')            >/dev/console
  73.     /bin/rm -f /etc/ptmp
  74. fi
  75.  
  76. # Start the virtual memory system.
  77. /usr/etc/mach_swapon -av                >/dev/console 2>&1
  78.  
  79. (echo -n 'Cleaning up:')                >/dev/console
  80.  
  81. # If the shutdown command was used to shut the system down, the file
  82. # /etc/nologin may have been created to prevent users from logging in.  
  83. # Remove it so that logins are enabled when the system comes up.
  84.  
  85. /bin/rm -f /etc/nologin
  86. (echo -n ' /etc/nologin')                >/dev/console
  87.  
  88. # Reset pseudo-terminals (ptys) to their default states.
  89. /usr/etc/chown root.tty /dev/tty[pqrs]*
  90. /bin/chmod 666 /dev/tty[pqrs]*
  91. (echo -n ' ptys')                    >/dev/consoleD8@Recover files being edited by ex, vi, or e when the system was restarted.
  92. (cd /tmp; /usr/lib/ex3.7preserve -a)
  93. (echo -n ' editors')                     >/dev/console
  94.  
  95. # Clean out /tmp.
  96. (cd /tmp; find . ! -name . ! -name lost+found ! -name quotas \
  97.     -exec rm -r - {} \; )
  98. (echo -n ' /tmp')                    >/dev/console
  99.  
  100. # Clear empty subdirectories of /Net.
  101. (cd /private/Net; find . ! -name . -type d -exec rmdir {} \; ) 
  102.  
  103. # Clear symlinks from /Net, too.
  104. (cd /private/Net; find . ! -name . -type l -exec rm {} \; ) 
  105. (echo -n ' /Net')                    >/dev/console
  106.  
  107. (echo '.')                        >/dev/console
  108.  
  109. # Syslog must be started before daemons are launched from rc.local.
  110. # This allows appropriate log messages to find their way to the console.
  111.  
  112. (echo -n Starting early daemons:)                >/dev/console
  113. if [ -f /usr/etc/syslogd -a -f /etc/syslog.conf ]; then
  114.     /bin/rm -f /dev/log
  115.     # If you want a timestamp to be logged periodically,
  116.     # modify the invocation of syslogd below.  For example, 
  117.     # for a half-hourly timestamp, add the argument "-m30".
  118.     /usr/etc/syslogd  && (echo -n ' syslogd')        >/dev/console
  119. fi
  120. (echo '.')                            >/dev/console
  121.  
  122. # Read the configuration information set by the HostManager application.
  123. . /etc/hostconfig
  124.  
  125. # Set up NIS domain.
  126.  
  127. if [ "${YPDOMAIN=-NO-}" != "-NO-" -a $NETWORKUP = "-YES-" ]; then
  128.     (echo "Setting NIS domainname to $YPDOMAIN")        >/dev/console
  129.     domainname $YPDOMAIN                >/dev/console 2>&1
  130. fi
  131.  
  132. # Rpc and net services are the minimal set needed to use the network.
  133. (echo -n 'Starting RPC and network services:')            >/dev/console
  134.  
  135. # Start the Mach network message server, which forwards Mach IPC over the
  136. # network and provides a name-to-port mapping service.
  137.  
  138. if [ -f /usr/etc/nmserver ]; then
  139.     /usr/etc/nmserver &                >/dev/console 2>&1
  140.     (echo -n ' nmserver')                    >/dev/console
  141. fi
  142.  
  143. # portmap converts Sun RPC program numbers into IP port numbers.
  144.  
  145. if [ -f /usr/etc/portmap ]; then
  146.     /usr/etc/portmap && (echo -n ' portmap')         >/dev/console
  147. fi
  148.  
  149. # Turn on IP routing.  If an explicit route is specified (the '*'
  150. # clause), either an IP address must be used or the router's hostname 
  151. # and IP address must be specified in the /etc/hosts file.  
  152.  
  153. case ${ROUTER=-NO-} in
  154.     -ROUTED-)
  155.     if [ -f /usr/etc/routed -a $NETWORKUP = "-YES-" ]; then
  156.         /usr/etc/routed && (echo -n ' routed')        >/dev/console
  157.     fi
  158.     ;;
  159.     -NO-)
  160.     ;;
  161.     *)
  162.     if [ -f /usr/etc/route ]; then
  163.         /usr/etc/rD8A add default $ROUTER 1    >/dev/console 2>&1
  164.     fi
  165.     ;;
  166. esac
  167.  
  168. # Start up the netinfo daemons.  This will only complete when the
  169. # local domain has bound to its parent domain, if it has a parent
  170. # (that is, if the machine is on a NetInfo network).  The message:
  171. #
  172. #   Still searching for parent network administration (NetInfo) server.
  173. #   Please wait, or press 'c' to continue without network user accounts.
  174. #   See your system administrator if you need help.
  175. #
  176. # comes from the local domain's netinfod; typically, you can wait a minute
  177. # or two and the local domain will eventually find a parent. As the
  178. # message says, the system is still searching for a parent server.
  179. # Typing 'c' aborts that search, which is probably not what you want.  
  180. # (You're most likely to see this message on a network-wide NetInfo server.)
  181. #
  182. # If you would like to customize this message to include the name or
  183. # telephone number of a network administrator, edit the text of the
  184. # message in /usr/lib/NextStep/Resources/English.lproj/NetInfo.strings,
  185. # or its equivalent for your usual boot language.
  186.  
  187. if [ -f /usr/etc/nibindd ]; then
  188.     /usr/etc/nibindd && (echo -n ' netinfo')    >/dev/console 2>&1
  189. fi
  190.  
  191. # If we are in an NIS domain, start up the appropiate services.
  192.  
  193. if [ "$YPDOMAIN" != "-NO-" -a $NETWORKUP = "-YES-" ]; then
  194.     # ypserv is run on NIS servers - machines with an /etc/yp/XXX dir
  195.     if [ -f /usr/etc/ypserv -a -d /etc/yp/$YPDOMAIN ]; then
  196.         /usr/etc/ypserv && (echo -n ' ypserv')        >/dev/console
  197.     fi
  198.     if [ -f /usr/etc/ypbind ]; then
  199.         /usr/etc/ypbind && (echo -n ' ypbind')        >/dev/console
  200.     fi
  201. fi
  202.  
  203. # The lookup daemon, lookupd, provides information to client programs
  204. # through the standard C library (such as gethostbyname()).  It obtains
  205. # the information from various network services: NetInfo, DNS (also called
  206. # the Domain Name Service - named - and BIND), and NIS.
  207.  
  208. if [ -f /usr/etc/nibindd -a -f /usr/etc/lookupd ]; then
  209.     /usr/etc/lookupd && (echo -n ' lookupd')        >/dev/console
  210. fi
  211.  
  212. # Start up time service.  If you're doing any sort of network file 
  213. # access, be sure NTP is enabled and properly configured, or you may 
  214. # see very strange errors and file consistency problems.
  215. #
  216. # NeXT's ntpd has been modified to acquire the NTP server
  217. # configuration from NetInfo (the /locations/ntp directory).
  218.  
  219. case ${TIME=-AUTOMATIC-} in
  220.     -AUTOMATIC-)
  221.     if [ -f /usr/eD8Btpd -a $NETWORKUP = "-YES-" ]; then
  222.         # Synchronize our clock to the network's time.
  223.         /usr/etc/ntp -F             >/dev/null
  224.         # Fire off ntpd to keep the clock in sync.
  225.         /usr/etc/ntpd && (echo -n ' ntpd')    >/dev/console
  226.     fi
  227.     ;;
  228.     -NO-)
  229.     ;;
  230.     *)
  231.     ;;
  232. esac
  233.  
  234. # biod is the NFS asynchronous block I/O daemon, which implements
  235. # NFS read-ahead and write-behind caching on NFS clients.
  236.  
  237. if [ -f /usr/etc/biod -a $NETWORKUP = "-YES-" ]; then
  238.     /usr/etc/biod 4 && (echo -n ' biod')             >/dev/console
  239. fi
  240.  
  241. (echo '.')                            >/dev/console
  242.  
  243. # Mount remote filesystems.
  244. fbshow -A -B -E -I "Mounting*File*Systems..."
  245. (echo 'Mounting remote filesystems')                >/dev/console
  246. mount -at nfs                         >/dev/console 2>&1
  247.  
  248. fbshow -A -B -E -I "Starting*System*Services..."
  249.  
  250. # Fileservice daemons are needed to import and export filesystems.
  251. (echo -n 'Starting file service daemons:')            >/dev/console
  252.  
  253. # If AppleTalk (EtherTalk) is desired, start up the AppleTalk daemon.
  254.  
  255. if [ -f /usr/etc/atalkd ]; then
  256.     if /usr/etc/atalkd >/dev/console 2>&1; then
  257.     (echo -n ' atalkd')                >/dev/console
  258.       fi
  259. fi
  260.  
  261. # Start the automounter only if /Net is a directory that is not
  262. # a symlink (symlinks to directories qualify as directories to test's
  263. # -d operation).
  264.  
  265. if [ -h /Net -o -f /Net ]; then
  266.     (echo "Warning: NeXT NFS automounter did not run.")    >/dev/console
  267. else
  268.     if [ -f /usr/etc/autonfsmount -a $NETWORKUP = "-YES-" ]; then
  269.         # The autonfsmounter will attempt a remount every 10 seconds,
  270.         # cache names for 12 hours [43200 seconds], mount things in
  271.         # /private/Net, ignore any NIS auto.master map, be triggered
  272.         # by references in the /Net directory, and use the fstab
  273.         # map (i.e., look in the mounts database -- /mounts in NetInfo,
  274.         # for example) to locate remote filesystems.
  275.         /usr/etc/autonfsmount    -tm 10 -tl 43200 \
  276.                     -a /private -m /Net -fstab \
  277.         && (echo -n ' autonfsmount') >/dev/console 2>&1
  278.     fi
  279. fi
  280.  
  281. # If exportfs finds something to export (either using /etc/exports or the
  282. # exports NetInfo directory), then start the NFS daemons (which service
  283. # NFS requests) and the mount server (which services NFS mount requests).
  284.  
  285. if [ -f /usr/etc/exportfs ]; then
  286.     # Clear the table of exported filesystems before running exportfs.
  287.     > /etc/xtab
  288.     if /usr/etc/exportfs -a >/dev/console 2>&1; then
  289.     # There is no "right" number of nfsd's. Infrequently-accessed
  290. D8Cervers can get by with 4 or fewer.  8 is not excessive for 
  291.     # heavily-loaded servers.
  292.     /usr/etc/nfsd 6 && (echo -n ' nfsd')         >/dev/console
  293.     /usr/etc/rpc.mountd && (echo -n ' rpc.mountd')    >/dev/console 2>&1
  294.     fi
  295. fi
  296.  
  297. # If AppleShare is desired, start up the AppleShare daemon.
  298.  
  299. if [ -f /usr/etc/ashared ]; then
  300.     if /usr/etc/ashared >/dev/console 2>&1; then
  301.     (echo -n ' ashared')                >/dev/console
  302.       fi
  303. fi
  304.  
  305. # If we are a Network Master become a BOOTP and BOOTPARAM server.  This is
  306. # the only thing that depends on the value of NETMASTER from /etc/hostconfig.
  307.  
  308. if [ "${NETMASTER=-NO-}" = "-YES-" ]; then
  309.     # If /etc/bootptab file exists, become a BOOTP server.  Note
  310.     # that bootpd gets information from /etc/bootptab even when
  311.     # NetInfo is running (the per-client information comes from
  312.     # NetInfo; the global information comes from /etc/bootptab).
  313.     if [ -f /usr/etc/bootpd -a -f /etc/bootptab ]; then
  314.         /usr/etc/bootpd && (echo -n ' bootpd')        >/dev/console
  315.     fi
  316.  
  317.     # bootparamd doesn't need a flat file.  
  318.     if [ -f /usr/etc/rpc.bootparamd ]; then
  319.         /usr/etc/rpc.bootparamd && \
  320.         (echo -n ' rpc.bootparamd')            >/dev/console
  321.     fi
  322. fi
  323. (echo '.')                            >/dev/console
  324.  
  325. # Network daemons provide service to the outside world.
  326. (echo -n Starting network daemons:)                >/dev/console
  327.  
  328. # Run the Internet server daemon.
  329. if [ -f /usr/etc/inetd ]; then
  330.     /usr/etc/inetd && (echo -n ' inetd')            >/dev/console
  331. fi
  332.  
  333. # Remove junk from the outbound mail queue directory and start up
  334. # the sendmail daemon. /usr/spool/mqueue is assumed here even though
  335. # it can be changed in the sendmail configuration file.
  336. #
  337. # sendmail is started even if there's no configuration file
  338. # in /etc/sendmail/sendmail.cf.  sendmail can find a configuration file
  339. # based on information in NetInfo (the sendmail.cf property in the 
  340. # /locations/sendmail directory). If no sendmail configuration file 
  341. # exists, sendmail will exit with an appropriate error message.
  342. #
  343. # Any messages which end up in the queue, rather than being delivered
  344. # or forwarded immediately, will be processed once each hour.
  345.  
  346. if [ -f /usr/lib/sendmail ]; then
  347.     (cd /usr/spool/mqueue; rm -f nf* lf*)
  348.     /usr/lib/sendmail -bd -q1h 2>/dev/console && \
  349.         (echo -n ' sendmail')    >/dev/console
  350. fi
  351.  
  352. # lpd is the Berkeley line printer daemon.
  353.  
  354. if [ -f /usr/lib/lpd ]; then
  355.     rm -f /dev/printer
  356.     /usr/lib/lpd && (echo -n ' printeD8D        >/dev/console
  357. fi
  358.  
  359. # Start an SNMP agent if configured to do so.
  360.  
  361. if [ -f /usr/etc/snmpd ]; then
  362.     if /usr/etc/snmpd -N >/dev/console 2>&1; then
  363.         (echo -n ' snmpd')                >/dev/console
  364.     fi
  365. fi
  366.  
  367. (echo '.')                            >/dev/console
  368.  
  369. # NeXT services support the application environment
  370. (echo -n 'Starting NeXT services:')                >/dev/console
  371.  
  372. # The pasteboard server is used by the AppKit.
  373.  
  374. if [ -f /usr/etc/pbs ]; then
  375.     /usr/etc/pbs &&    (echo -n ' pbs')            >/dev/console
  376. fi
  377.  
  378. # exec_faxes starts up any appropriate fax modem daemons.
  379.  
  380. if [ -f /usr/lib/NextPrinter/exec_faxes ]; then
  381.     /usr/lib/NextPrinter/exec_faxes && (echo -n ' exec_faxes')    >/dev/console
  382. fi
  383.  
  384. # If ISDN Networking is desired, start up the PhoneConnector in daemon mode.
  385.  
  386. /usr/bin/niutil -read . /localconfig/ISDN/Networking >/dev/null 2>&1
  387. if [ $? -eq 0 ]; then
  388.     if [ -f /NextAdmin/PhoneConnector.app/PhoneConnector ]; then
  389.         /NextAdmin/PhoneConnector.app/PhoneConnector -Daemon YES && \
  390.             (echo -n ' PhoneConnector')     >/dev/console
  391.     fi
  392. fi
  393.  
  394. (echo '.')                            >/dev/console
  395.  
  396. # If NetWare Networking is desired, start it.
  397.  
  398. ( /usr/bin/niutil -read . /localconfig/NetWare | \
  399.     /usr/bin/egrep 'enable.+YES' ) >/dev/null 2>&1
  400. if [ $? -eq 0 ]; then
  401.     (echo -n "Starting NetWare:")            >/dev/console 2>&1
  402.     # Load and start the kernel server.
  403.     if [ -f /usr/lib/kern_loader/nuc/nuc_reloc ]; then
  404.     /usr/etc/kl_util -a /usr/lib/kern_loader/nuc/nuc_reloc \
  405.         >/tmp/nuc_log 2>&1
  406.     (echo -n ' nuc_reloc ')                >/dev/console 2>&1
  407.     fi
  408.     if [ -f /usr/netware/bin/nucinit ]; then
  409.     /usr/netware/bin/nucinit            >/dev/console 2>&1
  410.     (echo -n ' nucinit')                >/dev/console 2>&1
  411.     fi
  412.  
  413.     # Configure the protocol stack.
  414.     if [ -f /usr/netware/etc/npsd ]; then
  415.     /usr/netware/etc/npsd && (echo -n ' npsd')    >/dev/console 2>&1
  416.     fi
  417.  
  418.     # Start the Management Portal, an internal port for communicating
  419.     # with the kernel server.
  420.     if [ -f /usr/netware/bin/nwmp ]; then
  421.     /usr/netware/bin/nwmp start && (echo -n ' nwmp') >/dev/console 2>&1
  422.     fi
  423.  
  424.     # Start the Netware Service Advertisement Protocol Daemon, which looks for
  425.     # NetWare servers' advertisement packets.
  426.     if [ -f /usr/netware/etc/sapd ]; then
  427.     /usr/netware/etc/sapd && (echo -n ' sapd')    >/dev/console 2>&1
  428.     fi
  429.  
  430.     # Start the NetWare automounter.
  431.     if [ -f /usr/etc/autoNetWaremount ]; then
  432.     /usr/etc/autoNetWaremount && (echoD8E' autoNetWaremount') \
  433.         >/dev/console 2>&1
  434.     fi
  435.     (echo '.')                            >/dev/console
  436. fi
  437.  
  438. # InputManager startup procedure (Japanese)
  439.  
  440. if [ -d /NextLibrary/InputManager ]; then
  441.     (echo -n 'Starting input servers:')                >/dev/console
  442.     for i in /NextLibrary/InputManager/*
  443.     do
  444.         if [ -d $i ]; then
  445.             if [ $i = "/Nextlibrary/InputManager/Resources" ]; then
  446.                 continue
  447.             fi
  448.             rcfile=`basename $i`
  449.             if [ -f $i/${rcfile}.rc ]; then
  450.                 sh $i/${rcfile}.rc $1
  451.             fi
  452.         fi
  453.     done
  454.     (echo '.')                            >/dev/console
  455. fi
  456.  
  457. # Any customizations to the startup sequence you would like to make should
  458. # be placed in /etc/rc.local; this way they can be preserved when your 
  459. # system is later upgraded to a new version of system software.
  460.  
  461. if [ -f /etc/rc.local ]; then
  462.     sh /etc/rc.local $1
  463. fi
  464.  
  465. # Unlock tip lines.  tip and UUCP share lock files so they don't get in
  466. # each other's way.
  467.  
  468. if [ -d /usr/spool/uucp ]; then
  469.     rm -f /usr/spool/uucp/LCK.*
  470.     rm -f /usr/spool/uucp/LCK/LCK.*
  471. fi
  472.  
  473. # Start standaard daemons that should always run
  474. (echo -n Starting standard daemons:)                >/dev/console
  475.  
  476. # update flushes the cached blocks from the filesystem using
  477. # the sync system call every 30 seconds.  This ensures the
  478. # disk is reasonably up-to-date in the event of a system crash.
  479.  
  480. update && (echo -n ' update')                    >/dev/console
  481.  
  482. # cron executes commands listed in /etc/crontab at specified times.
  483.  
  484. cron && (echo -n ' cron')                    >/dev/console
  485.  
  486. # accton is here for historical reasons.
  487.  
  488. # if [ -f /usr/adm/acct ]; then
  489. #    accton /usr/adm/acct && (echo -n ' accounting')        >/dev/console
  490. # fi
  491.  
  492. (echo '.')                            >/dev/console
  493.  
  494. # Submit a syslog note to indicate that we've successfully rebooted.
  495. /usr/ucb/logger -t reboot -p kern.crit "$MESSAGE complete"
  496.  
  497. exit 0
  498.