-
Notifications
You must be signed in to change notification settings - Fork 5
/
mamp_pro_start_stop_script.sh
94 lines (76 loc) · 2.86 KB
/
mamp_pro_start_stop_script.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#!/bin/sh
##
# Apache HTTP Server
##
. /etc/rc.common
MAMP_mysql_error_log_MAMP="/Applications/MAMP/logs/mysql_error_log.err"
MAMP_php_error_log_MAMP="/Applications/MAMP/logs/php_error.log"
mysqlPath="/Library/Application Support/appsolute/MAMP PRO/db/mysql"
mysqlTmpPath=/Applications/MAMP/tmp/mysql
mysqlTmpdirPath=/Applications/MAMP/tmp/mysql/tmpdir
phpTmpPath=/Applications/MAMP/tmp/php
eacceleratorTmpPath=/Applications/MAMP/tmp/eaccelerator
xCacheMmapPath=/Applications/MAMP/tmp/xcache
xCacheCoredumpDirectory=/Applications/MAMP/tmp/phpcore
fcgiTmpPath=/Applications/MAMP/tmp/fcgi_ipc
mysqlLogPath="/Applications/MAMP/logs/mysql_error_log.err"
phpLogPath="/Applications/MAMP/logs/php_error.log"
mysqlConfPath=/Applications/MAMP/tmp/mysql/my.cnf
apacheUser="www"
mysqlUser="mysql"
Log()
{
logger -t "MAMP" $1
}
Stop ()
{
if test -f /Applications/MAMP/Library/logs/httpd.pid; then
Log "Stopping MAMP Apache server"
/Applications/MAMP/Library/bin/apachectl -f"/Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf" -k stop
fi
if test -f /Applications/MAMP/tmp/mysql/mysql.pid; then
Log "Stopping MAMP MySQL server"
/bin/kill `cat /Applications/MAMP/tmp/mysql/mysql.pid`
fi
}
Start ()
{
Log "Starting MAMP Apache web server"
Stop
chmod -R a+w /Applications/MAMP/db/sqlite
if test -d ${phpTmpPath}; then chown -R ${apacheUser} ${phpTmpPath}; fi
if test -d ${eacceleratorTmpPath}; then chown -R ${apacheUser} ${eacceleratorTmpPath}; fi
if test -d ${fcgiTmpPath}; then chown -R ${apacheUser} ${fcgiTmpPath}; fi
if test -f ${xCacheMmapPath}; then chown ${apacheUser} ${xCacheMmapPath}; fi
if test -d ${xCacheCoredumpDirectory}; then chown -R ${apacheUser} ${xCacheCoredumpDirectory}; fi
touch "${phpLogPath}"
chown ${apacheUser} "${phpLogPath}"
/Applications/MAMP/Library/bin/apachectl -f"/Library/Application Support/appsolute/MAMP PRO/conf/httpd.conf" -k start
Log "Starting MAMP MySQL server"
chown ${mysqlUser} "${mysqlLogPath}"
chmod 0640 "${mysqlLogPath}"
chown -R ${mysqlUser} "${mysqlPath}"
if [ ! -d ${mysqlTmpdirPath} ]; then mkdir ${mysqlTmpdirPath}; fi
chown -R ${mysqlUser} ${mysqlTmpPath}
for i in "${mysqlPath}"/*; do
if [ -f "$i" ]; then
chmod 0660 "$i"
else
if [ -d "$i" ]; then
chmod -R 0600 "$i"
chmod 0775 "$i"
fi
fi
done
if [ -f ${mysqlConfPath} ]; then
chown ${mysqlUser} ${mysqlConfPath}
chmod 0660 ${mysqlConfPath}
fi
/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
}
Restart ()
{
Stop
Start
}
"$1" &