Guest User

Untitled

a guest
Oct 30th, 2013
4
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2.  
  3. ##
  4. # Apache HTTP Server
  5. ##
  6.  
  7. . /etc/rc.common
  8. MAMP_mysql_error_log_MAMP="/Applications/MAMP/logs/mysql_error_log.err"
  9. MAMP_php_error_log_MAMP="/Applications/MAMP/logs/php_error.log"
  10.  
  11. mysqlPath="/Library/Application Support/appsolute/MAMP PRO/db/mysql"
  12. mysqlTmpPath=/Applications/MAMP/tmp/mysql
  13. mysqlTmpdirPath=/Applications/MAMP/tmp/mysql/tmpdir
  14. phpTmpPath=/Applications/MAMP/tmp/php
  15. eacceleratorTmpPath=/Applications/MAMP/tmp/eaccelerator
  16. xCacheMmapPath=/Applications/MAMP/tmp/xcache
  17. xCacheCoredumpDirectory=/Applications/MAMP/tmp/phpcore
  18. fcgiTmpPath=/Applications/MAMP/tmp/fcgi_ipc
  19. mysqlLogPath="/Applications/MAMP/logs/mysql_error_log.err"
  20. phpLogPath="/Applications/MAMP/logs/php_error.log"
  21. mysqlConfPath=/Applications/MAMP/tmp/mysql/my.cnf
  22. apacheUser="www"
  23. mysqlUser="mysql"
  24.  
  25. Log()
  26. {
  27.     logger -t "MAMP" $1
  28. }
  29.  
  30.  
  31. Stop ()
  32. {
  33.     if test -f /Applications/MAMP/Library/logs/httpd.pid; then
  34.         Log "Stopping MAMP Apache server"
  35.         /Applications/MAMP/Library/bin/apachectl -f"/Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf" -k stop
  36.     fi
  37.    
  38.     if test -f /Applications/MAMP/tmp/mysql/mysql.pid; then
  39.         Log "Stopping MAMP MySQL server"
  40.         /bin/kill `cat /Applications/MAMP/tmp/mysql/mysql.pid`
  41.     fi
  42.    
  43. }
  44.  
  45. Start ()
  46. {
  47.     Log "Starting MAMP Apache web server"
  48.     Stop
  49.    
  50.     chmod -R a+w /Applications/MAMP/db/sqlite
  51.     if test -d ${phpTmpPath}; then chown -R ${apacheUser} ${phpTmpPath}; fi
  52.     if test -d ${eacceleratorTmpPath}; then chown -R ${apacheUser} ${eacceleratorTmpPath}; fi
  53.     if test -d ${fcgiTmpPath}; then chown -R ${apacheUser} ${fcgiTmpPath}; fi
  54.     if test -f ${xCacheMmapPath}; then chown ${apacheUser} ${xCacheMmapPath}; fi
  55.     if test -d ${xCacheCoredumpDirectory}; then chown -R ${apacheUser} ${xCacheCoredumpDirectory}; fi
  56.     touch "${phpLogPath}"
  57.     chown ${apacheUser} "${phpLogPath}"
  58.     /Applications/MAMP/Library/bin/apachectl -f"/Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf" -k start
  59.    
  60.     Log "Starting MAMP MySQL server"
  61.     chown ${mysqlUser} "${mysqlLogPath}"
  62.     chmod 0640 "${mysqlLogPath}"
  63.    
  64.     chown -R ${mysqlUser} "${mysqlPath}"
  65.     if [ ! -d ${mysqlTmpdirPath} ]; then mkdir ${mysqlTmpdirPath}; fi
  66.     chown -R ${mysqlUser} ${mysqlTmpPath}
  67.  
  68.     for i in "${mysqlPath}"/*; do
  69.         if [ -f "$i" ]; then
  70.             chmod 0660 "$i"
  71.         else
  72.             if [ -d "$i" ]; then
  73.                 chmod -R 0600 "$i"
  74.                 chmod 0775 "$i"
  75.             fi
  76.         fi
  77.     done
  78.    
  79.     if [ -f ${mysqlConfPath} ]; then
  80.         chown ${mysqlUser} ${mysqlConfPath}
  81.         chmod 0660 ${mysqlConfPath}
  82.     fi
  83.    
  84.     /Applications/MAMP/Library/bin/mysqld_safe --defaults-file=${mysqlConfPath} --user=${mysqlUser} --port=MAMP_MysqlPort_MAMP --socket=/Applications/MAMP/tmp/mysql/mysql.sock --pid-file=/Applications/MAMP/tmp/mysql/mysql.pid --log-error="$mysqlLogPath" --tmpdir=${mysqlTmpdirPath} --datadir=/Library/Application\ Support/appsolute/MAMP\ PRO/db/mysql
  85. }
  86.  
  87.  
  88. Restart ()
  89. {
  90.     Stop
  91.     Start
  92. }
  93.  
  94. "$1" &
RAW Paste Data