home *** CD-ROM | disk | FTP | other *** search
/ PC PowerPlay 49 / PCPP49b.iso / freebies / BeOS5-PersonalEdition / data1.cab / Data_Files / image.be / beos / system / boot / Bootscript < prev    next >
Encoding:
Text File  |  2000-03-24  |  5.1 KB  |  242 lines

  1. #
  2. # This is the system startup file.  It manages starting up
  3. # all the necessary servers and ensuring a sane system state.
  4. #
  5. # Do not edit or change this file.
  6. #
  7. # If you want to add startup customizations, add them to the file
  8. # $HOME/config/boot/UserBootscript.  This script checks for that
  9. # file and makes sure that it gets executed if it exists (that is 
  10. # done as the last thing before exiting).
  11. #
  12. # Shell customizations (aliases, etc) do not belong in this file
  13. # or UserBootscript.
  14. #
  15. # If you want to add customizations to your shell environment
  16. # you should create a file $HOME/.profile and put your customizations
  17. # there.
  18. #
  19.  
  20. # ++++++++++
  21. #    function: launch executable_path [ thread_to_wait_for ]
  22. # +++++
  23.  
  24. launch () {
  25.     if [ -f "/boot/$1" ]
  26.     then
  27.         "/boot/$1" &
  28.         [ "$2" != "" ] && waitfor "$2"
  29.         return 1
  30.     else
  31.         echo There is no "$1"
  32.     fi
  33.     return 0
  34. }
  35.  
  36. # ++++++++++
  37. #    function: launchscript script_path
  38. # +++++
  39.  
  40. launchscript() {
  41.     if [ -f "/boot/$1" ]
  42.     then
  43.         . "/boot/$1"
  44.     fi
  45. }
  46.  
  47.  
  48. # ++++++++++
  49. #    function: runprog executable_path
  50. #          Runs the program in the foreground.
  51. # +++++
  52.  
  53. runprog () {
  54.     if [ -f "/boot/$1" ]
  55.     then
  56.         "/boot/$1"
  57.         return 1
  58.     else
  59.         echo There is no "$1"
  60.     fi
  61.     return 0
  62. }
  63.  
  64. # ++++++++++
  65. #    function: vm_alert
  66. #          puts up the 'no swap file' alert
  67. # +++++
  68.  
  69. vm_alert( )
  70. {
  71.     alert --warning --modal "Not enough free disk space to create a swap file.  Virtual memory will be disabled." "More info" "Don't nag" "OK"
  72.     _retval=$?
  73.     [ $_retval -eq 0 ] && NetPositive file:///boot/beos/documentation/AlertInfo/VM.html
  74.     [ $_retval  -eq 1 ] && touch $HOME/config/settings/stop_swap_nagging
  75. }
  76.  
  77. # ++++++++++
  78. #    function: vga_alert
  79. #          puts up the 'unsupported video card' alert
  80. # +++++
  81.  
  82. vga_alert( )
  83. {
  84.     alert --info --modal "The graphics card in this machine is not supported by the BeOS." "More info" "Don't nag" "OK"
  85.     _retval=$?
  86.     [ $_retval -eq 1 ] && touch $HOME/config/settings/stop_vga_nagging
  87.     [ $_retval -eq 0 ] && NetPositive file:///boot/beos/documentation/AlertInfo/StubDriver.html
  88. }
  89.  
  90.  
  91. # ++++++++++
  92. #    function: safe_mode_alert
  93. #          puts up the 'safe mode' alert
  94. # +++++
  95.  
  96. safe_mode_alert( )
  97. {
  98.     alert --info --modal "You are running in safe mode.  Nonvital system services have been disabled." "More info" "Don't nag" "OK"
  99.     _retval=$?
  100.     [ $_retval -eq 1 ] && touch $HOME/config/settings/stop_safe_mode_nagging
  101.     [ $_retval -eq 0 ] && NetPositive file:///boot/beos/documentation/AlertInfo/SafeMode.html
  102. }
  103.  
  104.  
  105.  
  106. #
  107. # set up stdin/out/err
  108. #
  109.  
  110. exec </dev/null
  111. exec >/dev/null 2>&1
  112.  
  113. # this must be done here because SetupEnvironment depends on it
  114. #
  115. SAFEMODE=`/bin/safemode`
  116. export SAFEMODE
  117.  
  118. #
  119. # load up some useful environment variables...
  120. #
  121.  
  122. SCRIPTS=beos/system/boot
  123. launchscript $SCRIPTS/SetupEnvironment
  124.  
  125. #
  126. # create an empty tmp directory
  127. #
  128.  
  129. TMPDIR=/boot/var/tmp
  130. [ -f $TMPDIR ] && rm $TMPDIR
  131. if [ ! -d $TMPDIR ]
  132. then
  133.     mkdir -p $TMPDIR
  134.     chmod a+rwx $TMPDIR
  135.     [ ! -d $TMPDIR ] && echo Error creating tmp directory
  136. else
  137.     [ ! -f $TMPDIR/.noerase ] && rm -rf $TMPDIR/*
  138. fi
  139.  
  140. #
  141. # check if we are running from a cd, run another script if so
  142. #
  143.  
  144. iw=`/bin/isvolume -readonly /boot`
  145. if [ "$iw"x = "yes"x ]
  146. then
  147.     launchscript $SCRIPTS/Bootscript.cd
  148.     exit  # in case it returns...
  149. fi
  150.  
  151. SERVERS=beos/system/servers
  152.  
  153. #
  154. # Clock configuration MUST be first!
  155. #
  156. runprog beos/bin/clockconfig                # set timezone, etc.
  157.  
  158. launch $SERVERS/app_server picasso            # launch app_server
  159. launch $SERVERS/registrar _roster_thread_    # launch registrar
  160. launch $SERVERS/debug_server                # we hate crashing
  161. if [ "$SAFEMODE" != "yes" ]
  162. then
  163.     launch $SERVERS/syslog_daemon            # start system logger
  164. fi
  165. waitfor _input_server_event_loop_            # wait for input devices
  166.  
  167. if launch beos/system/Tracker    # start the Tracker
  168. then
  169.     launch beos/apps/Terminal    # no Tracker? try Terminal
  170. fi
  171.  
  172. sleep 1
  173.  
  174. launch beos/system/Deskbar        # launch DeskBar
  175.  
  176. if [ ! -e /boot/var/swap ]; then
  177.     x=`/bin/sysinfo -m | /bin/awk '{print $7}' | /bin/tr -d ')'`
  178.     if [ $x -le 40000000 ]; then
  179.         SAFEMODE=yes;
  180.     fi
  181. fi    
  182.  
  183. [ -e /bin/dstcheck ] && (/bin/dstcheck &)
  184.  
  185. if [ "$SAFEMODE" != "yes" ]
  186. then
  187.  
  188.     if [ "x$USE_OLD_AUDIO" != "x" ]; then
  189.         launch $SERVERS/audio_server            
  190.     else
  191.         launch $SERVERS/media_server
  192.     fi
  193.  
  194.     sleep 2                                # media_server is heavy on the disk
  195.     launch $SERVERS/print_server        # we own paper stocks
  196.     sleep 1                                # let things settle down a bit 
  197.                                         #and then continue
  198.     launch $SERVERS/midi_server
  199.  
  200.     if [ -e /dev/bus/pcmcia/sock/0 ]
  201.     then
  202.         launch $SERVERS/device_watcher
  203.     fi
  204.  
  205.     if [ "$PCMCIANETWORK" != "true" ]
  206.     then
  207.         launchscript $SCRIPTS/Netscript        # start up networking
  208.     fi
  209. else
  210.     sleep 1
  211. fi
  212.  
  213. # alert user if no swap file
  214.  
  215. if [ ! -e /boot/var/swap -a ! -e $HOME/config/settings/stop_swap_nagging ]
  216. then
  217.     vm_alert &
  218. fi
  219.  
  220. if [ "$SAFEMODE" != "yes" ]
  221. then
  222.     # alert user if using stub graphics driver
  223.     if [ -e /tmp/stub_vga_driver -a ! -e $HOME/config/settings/stop_vga_nagging ]
  224.     then
  225.         vga_alert &
  226.         rm -f /tmp/stub_vga_driver
  227.     fi
  228.  
  229.     if [ -f $HOME/config/boot/UserBootscript ]
  230.     then
  231.         . $HOME/config/boot/UserBootscript    # give users a shot too
  232.     fi
  233.  
  234.     # finish up after an installation
  235.     launchscript $SCRIPTS/InstallerRebootScript
  236. else
  237.     if [ ! -e $HOME/config/settings/stop_safe_mode_nagging ]
  238.     then
  239.         safe_mode_alert &
  240.     fi
  241. fi
  242.