home *** CD-ROM | disk | FTP | other *** search
/ H4CK3R 4 / hacker04 / 04_HACK04.ISO / darwin / darwinx86.iso / System / Library / StartupItems / SystemTuning / SystemTuning < prev   
Encoding:
Text File  |  2001-09-20  |  2.1 KB  |  92 lines

  1. #!/bin/sh
  2.  
  3. ##
  4. # Change the tunable parameters
  5. ##
  6.  
  7. . /etc/rc.common
  8.  
  9. ConsoleMessage "Tuning system parameters:"
  10.  
  11. ##
  12. # Set boot-command option for server configuration
  13. ##
  14.  
  15. if [ -z "${SERVER:=-NO-}" ]; then
  16.     if [ "${AFPSERVER}" = "-YES-" ] ||
  17.        [ "${QTSSERVER}" = "-YES-" ]; then
  18.     SERVER=-YES-
  19.     else
  20.     SERVER=-NO-
  21.     fi
  22. fi
  23.  
  24. NewWorld=$(sysctl hw.epoch | sed 's/^hw.epoch = //')
  25.  
  26. if [ "${NewWorld}" = "1" ]; then
  27.     BootArgsVar=boot-args
  28. else
  29.     BootArgsVar=boot-command
  30. fi
  31.  
  32. SetBootCommand()
  33. {
  34.     local BootCommand="$*"
  35.  
  36.     if [ $ARCH = "powerpc" ]; then
  37.         if nvram "${BootArgsVar}"="${BootCommand}"; then
  38.         shutdown -r now
  39.         else
  40.         echo "Warning: Failed to set boot-command"
  41.         echo "Warning: Continuing startup"
  42.         fi
  43.     fi
  44. }
  45.  
  46. if [ $ARCH = "powerpc" ]; then
  47.     if boot_command=$(nvram "${BootArgsVar}" | cut -f 2-); then
  48.  
  49.         case ${SERVER} in
  50.  
  51.           -YES-)
  52.         if [ -n "$( echo ${boot_command} | sed -n '/srv=/p' )" ]; then
  53.             if [ -n "$( echo ${boot_command} | sed -n '/srv=0/p' )" ]; then
  54.             ConsoleMessage "Rebooting with server configuration"
  55.             SetBootCommand $(echo ${boot_command} | sed 's/srv=0/srv=1/')
  56.             fi
  57.         else
  58.             ConsoleMessage "Rebooting with server configuration"
  59.             SetBootCommand ${boot_command} srv=1
  60.         fi
  61.         ;;
  62.     
  63.           -NO-)
  64.         if [ -n "$( echo ${boot_command} | sed -n '/srv=1/p' )" ]; then
  65.             ConsoleMessage "Rebooting without server configuration"
  66.             SetBootCommand $(echo ${boot_command} | sed 's/srv=1//')
  67.         fi
  68.         ;;
  69.     
  70.         esac
  71.     
  72.         nvram boot-command
  73.     
  74.     else
  75.         echo "Warning: Unable to access OpenFirmware to set boot-command"
  76.     fi
  77. fi
  78. ##
  79. # Scale number of vnodes based on RAM
  80. # base memory is 32MB and each 32MB gets 512 vnodes
  81. ##
  82.  
  83.      base=32
  84. addvnodes=512
  85.       mem=$(hostinfo | sed -n '/Primary memory available/p' | sed -e 's/Primary memory available: *//' -e 's/\.[0-9][0-9] *megabytes.$//')
  86.    excess=$((${mem} - ${base}))
  87.    factor=$((${excess} / ${base}))
  88. defvnodes=$(sysctl kern.maxvnodes | sed -e 's/^[^0-9]*//')
  89. newvnodes=$((${addvnodes} * ${factor} + ${defvnodes}))
  90.  
  91. sysctl -w kern.maxvnodes=${newvnodes}
  92.