home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / private / etc / rc < prev    next >
Encoding:
Text File  |  2001-09-20  |  4.3 KB  |  215 lines

  1. #!/bin/sh
  2.  
  3. ##
  4. # Multi-user startup script.
  5. #
  6. # Wilfredo Sanchez | wsanchez@opensource.apple.com
  7. # Copyright 1997-2001 Apple Computer, Inc.
  8. #
  9. # Customize system startup by adding scripts to the startup 
  10. # directory, rather than editing this file.
  11. ##
  12.  
  13. ##
  14. # Set shell to ignore Control-C, etc.
  15. # Prevent lusers from shooting themselves in the foot.
  16. ##
  17.  
  18. stty intr  undef
  19. stty kill  undef
  20. stty quit  undef
  21. stty susp  undef
  22. stty start undef
  23. stty stop  undef
  24. stty dsusp undef
  25.  
  26. . /etc/rc.common
  27.  
  28. stty status '^T'
  29.  
  30. ##
  31. # Handle arguments passed from init.
  32. ##
  33.  
  34. BootType=$1; shift;
  35.  
  36. if [ -z "${BootType}" ]; then BootType="multiuser"; fi
  37.  
  38. ##
  39. # Handle options
  40. ##
  41.  
  42. VerboseFlag=""
  43.    SafeBoot=""
  44.  
  45. args=$(getopt vx $*)
  46. set -- ${args};
  47. for option; do
  48.     case "${option}" in
  49.       -v)
  50.         VerboseFlag="-v"
  51.     ;;
  52.       -x)
  53.         SafeBoot="-x"
  54.     ;;
  55.     esac;
  56. done;
  57.  
  58. echo ""
  59.  
  60. case "${BootType}" in
  61.   "autoboot")
  62.     ConsoleMessage "Automatic reboot in progress"
  63.     ;;
  64.   "multiuser")
  65.     ConsoleMessage "Multiuser startup in progress"
  66.     ;;
  67.   *)
  68.     ConsoleMessage "Unknown boot request: multiuser startup in progress"
  69.     ;;
  70. esac
  71.  
  72. ##
  73. # Are we booting from a CD-ROM?  If so, switch over to /etc/rc.cdrom.
  74. ##
  75.  
  76. if [ -d /System/Installation ] && [ -f /etc/rc.cdrom ]; then
  77.  
  78.     # Hand off to installation script
  79.     /etc/rc.cdrom ${BootType}
  80.  
  81.     # All done; shut down
  82.     # We shouldn't get here; CDIS should reboot the machine when done
  83.     ConsoleMessage "CD-ROM boot procedure complete"
  84.     halt
  85.     exit 0
  86.  
  87. fi
  88.  
  89. ##
  90. # Mount essential local filesystems (according to /etc/fstab).
  91. ##
  92.  
  93. ConsoleMessage "Mounting local filesystems"
  94.  
  95. mount -vat hfs
  96. mount -vat ufs
  97. mount -t fdesc -o union stdin /dev
  98. mkdir -p -m 0555 /.vol && chmod 0555 /.vol && mount_volfs /.vol
  99.  
  100. ##
  101. # Create mach symbol file
  102. ##
  103.  
  104. rm -f /mach.sym
  105.  
  106. sysctl -n kern.symfile
  107.  
  108. if [ -f /mach.sym ]; then
  109.   rm -f /mach
  110.   ln -s /mach.sym /mach
  111. else
  112.   rm -f /mach
  113.   ln -s /mach_kernel /mach
  114. fi
  115.  
  116. sync
  117.  
  118. ##
  119. # See if the system is unconfigured.  If so, ask for root passwd
  120. ##
  121. if [ ! -d /var/db/netinfo/local.nidb ]; then
  122.         VerboseFlag="-v"
  123.        ConsoleMessage "The system is unconfigured."
  124.        ConsoleMessage "You must enter a root password.  Leaving the password "
  125.        ConsoleMessage "blank or not entering one will result in you being "
  126.        ConsoleMessage "unable to log into this machine.  If this happens, "
  127.        ConsoleMessage "please reboot the machine to single user mode and "
  128.        ConsoleMessage "set your password."
  129.        passwd -i file root
  130. fi
  131.  
  132.  
  133. ##
  134. # Start kextd
  135. ##
  136.  
  137. if [ "${SafeBoot}" = "-x" ]; then
  138.     ConsoleMessage "Configuring kernel extensions for safe boot"
  139.     kextd -x
  140. else
  141.     ConsoleMessage "Configuring kernel extensions"
  142.     kextd
  143. fi
  144.  
  145. ##
  146. # Create or update the mkext cache, which will make subsequent
  147. # boots slightly faster.
  148. ##
  149.  
  150. if [ ! -f /System/Library/Extensions.mkext -o \
  151.      /System/Library/Extensions.mkext -ot /System/Library/Extensions ]; then
  152.  
  153.     if [ "${SafeBoot}" != "-x" ]; then
  154.         ConsoleMessage "Updating kernel extensions cache"
  155.         rm -f /System/Library/Extensions.mkext
  156.         /usr/sbin/mkextcache -l -t `arch` -o /System/Library/Extensions.mkext \
  157.             -d /System/Library/Extensions
  158.     fi
  159. fi
  160.  
  161. ##
  162. # Startup the ATS Server
  163. ## 
  164.  
  165. if [ -x /System/Library/CoreServices/StartATSServer ]; then
  166.     ConsoleMessage "Starting ATS Server"
  167.     /System/Library/CoreServices/StartATSServer
  168. fi
  169.  
  170. if [ -z "${VerboseFlag}" ] &&
  171.    [ -x /System/Library/CoreServices/WindowServer ]; then
  172.     ConsoleMessage "Starting Window Server"
  173.     /System/Library/CoreServices/WindowServer ${SafeBoot}
  174. fi
  175.  
  176. ##
  177. # update flushes the cached blocks from the filesystem using
  178. # the sync system call every 30 seconds.  This ensures the
  179. # disk is reasonably up-to-date in the event of a system crash.
  180. ##
  181.  
  182. update
  183.  
  184. ##
  185. # Start the virtual memory system.
  186. ##
  187.  
  188. ConsoleMessage "Starting virtual memory"
  189.  
  190. swapdir=/private/var/vm
  191.  
  192. # Make sure the swapfile exists
  193. if [ ! -d ${swapdir} ]; then
  194.     ConsoleMessage "Creating default swap directory"
  195.     mount -uw /
  196.     mkdir -p -m 755 ${swapdir}
  197.     chown root:wheel ${swapdir}
  198. else
  199.     rm -rf ${swapdir}/swap*
  200. fi
  201.             
  202. dynamic_pager -H 40000000 -L 160000000 -S 80000000 -F ${swapdir}/swapfile
  203.  
  204. ##
  205. # Start System Services
  206. ##
  207.  
  208. # Set language from CDIS.custom - assumes this is parse-able by sh
  209. . /var/log/CDIS.custom 
  210. export LANGUAGE
  211.  
  212. SystemStarter ${VerboseFlag}
  213.  
  214. exit 0
  215.