home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 15 / 15.iso / s / s053 / 5.ddi / sbin / rc0 < prev    next >
Encoding:
Text File  |  1990-12-08  |  2.5 KB  |  133 lines

  1.  
  2.  
  3.  
  4. #    "Run Commands" for init state 0
  5. #    Leaves the system in a state where it is safe to turn off the power
  6. #    or reboot.
  7. #
  8. #    Takes an optional argument of either off or reboot
  9. #    to specify if this is being run for init 0 or init 5.
  10. #
  11. #    In SVR4.0, inittab has been changed to no longer do the
  12. #    uadmin to shutdown or enter firmware.  Instead, this script
  13. #    is responsible.  By using an optional argument,
  14. #    compatibility is maintained while still providing the needed
  15. #    functionality to perform the uadmin call.
  16.  
  17.  
  18. umask 022
  19. echo 'The system is coming down.  Please wait.'
  20.  
  21. # make sure /usr is mounted before proceeding since init scripts
  22. # and this shell depend on things on /usr file system
  23. /sbin/mount /usr > /dev/null 2>&1
  24.  
  25. #    The following segment is for historical purposes.
  26. #    There should be nothing in /etc/shutdown.d.
  27. if [ -d /etc/shutdown.d ]
  28. then
  29.     for f in /etc/shutdown.d/*
  30.     {
  31.         if [ -s $f ]
  32.         then
  33.             /sbin/sh ${f}
  34.         fi
  35.     }
  36. fi
  37. #    End of historical section
  38.  
  39. if [ -d /etc/rc0.d ]
  40. then
  41.     for f in /etc/rc0.d/K*
  42.     {
  43.         if [ -s ${f} ]
  44.         then
  45.             /sbin/sh ${f} stop
  46.         fi
  47.     }
  48.  
  49. #    system cleanup functions ONLY (things that end fast!)    
  50.  
  51.     for f in /etc/rc0.d/S*
  52.     {
  53.         if [ -s ${f} ]
  54.         then
  55.             /sbin/sh ${f} start
  56.         fi
  57.     }
  58. fi
  59.  
  60. # PC 6300+ Style Installation - execute shutdown scripts from driver packages
  61. if [ -d /etc/idsd.d ]
  62. then
  63.     for f in /etc/idsd.d/*
  64.     {
  65.         if [ -s ${f} ]
  66.         then
  67.             /sbin/sh ${f}
  68.         fi
  69.     }
  70. fi
  71.  
  72. trap : 15
  73. /usr/sbin/killall
  74. /usr/bin/sleep 10
  75.  
  76.  
  77. if [ -f /etc/.copy_unix ]
  78. then
  79.     if [ -f /etc/conf/cf.d/unix ]
  80.     then
  81.         mv /stand/unix /stand/unix.old 
  82.         if [ $? -eq 0 ]
  83.         then
  84.             echo Saved the old unix kernel
  85.             rm -f /etc/.copy_unix
  86.         else
  87.             echo Can not save the old unix kernel.  Not enough space in /stand
  88.         fi
  89.  
  90.         ok=0
  91.         cp /etc/conf/cf.d/unix /stand/unix 
  92.         if [ ! $? -eq 0 ]
  93.         then
  94.             echo Failed to install the new unix kernel in /stand
  95.             echo Retrying after removing the old unix kernel
  96.             rm -f /stand/unix.old
  97.             cp /etc/conf/cf.d/unix /stand/unix 
  98.             if [ ! $? -eq 0 ]
  99.             then
  100.                 ok=1
  101.                 echo Failed to install the new unix kernel in /stand
  102.                 echo Linking /etc/conf/cf.d/unix to /unix instead
  103.                 rm -f /unix
  104.                 ln /etc/conf/cf.d/unix /unix
  105.             fi
  106.         fi
  107.         
  108.         if [ $ok -eq 0 ]
  109.         then        
  110.             rm -f /unix
  111.             ln -s /stand/unix /unix
  112.             echo Installed new unix kernel 
  113.         fi
  114.     fi
  115. fi
  116.  
  117. /sbin/sync;/sbin/sync;/sbin/sync
  118. /sbin/umountall
  119. rm -rf /tmp/*
  120. /sbin/sync;/sbin/sync;/sbin/sync
  121. echo '
  122. The system is down.'
  123.  
  124. # check if user wants machine brought down or reboot
  125. case "$1" in
  126.     off)    /sbin/uadmin 2 0
  127.         ;;
  128.  
  129.     reboot)    /sbin/uadmin 2 2
  130.         ;;
  131. esac
  132.  
  133.