--
-- XAMPP AppleScript Controller
set isAppleApacheRunning to 1
set isXamppApacheRunning to 1
-- Apple Apache check
try
set s to do shell script "ps -ax | grep /usr/sbin/httpd|grep -v grep"
on error errMsg number errNum
set isAppleApacheRunning to 0
end try
-- XAMPP Apache check
try
set s to do shell script "ps -ax | grep /Applications/xampp/xamppfiles/bin/httpd|grep -v grep"
on error errMsg number errNum
set isXamppApacheRunning to 0
end try
if isAppleApacheRunning is 1 then
set dialogReply to display dialog ¬
"Apple's Apache is running. Stop this process first." buttons {"Exit"} default button 1
return
end if
-- If XAMPP is not running
if isXamppApacheRunning is 0 then
set dialogReply to display dialog ¬
"XAMPP is not running." buttons {"Start", "Exit"} default button 1
if button returned of dialogReply is "Start" then
do shell script ¬
"/Applications/xampp/xamppfiles/mampp start" with administrator privileges
return
else if button returned of dialogReply is "Exit" then
return
end if
end if
-- If XAMPP is running
if isXamppApacheRunning is 1 then
set dialogReply to display dialog ¬
"XAMPP is currently running." buttons {"Stop", "Restart", "Exit"} default button 1
if button returned of dialogReply is "Stop" then
do shell script ¬
"/Applications/xampp/xamppfiles/mampp stop" with administrator privileges
return
else if button returned of dialogReply is "Restart" then
do shell script ¬
"/Applications/xampp/xamppfiles/mampp restart" with administrator privileges
else if button returned of dialogReply is "Exit" then
return
end if
end if