once compiling these scripts i suggest saving it as an application bundle that you can simply double-click or make into a startup item so that your server starts automatically when you log-in.
i am playing around with some cocoa ideas to make a preference pane and/or standalone application for controlling elements of mampp individually since this will be a much better solution. in the meantime:
to start/restart/stop mampp and all components (also checks to make sure MacOsX server is not activated to avoid conflicts):
- Code: Select all
set Check to 0
try
set s to do shell script "ps -ax | grep /usr/sbin/httpd|grep -v grep"
on error errMsg number errNum
set Check to 1
end try
if Check is 0 then
display dialog "Apple's Apache is running! Please turn it off in the System Preferences first then rerun this script."
return
end if
try
set httpdstatus to do shell script "ps -ax | grep /Applications/xampp/xamppfiles/bin/httpd|grep -v grep"
set dialogReply to display dialog ¬
"XAMPP's Apache is running — Do you want to Stop or Restart XAMPP?" buttons {"Stop", "Restart", "Cancel"} default button 1
if button returned of dialogReply is "Cancel" then
return
end if
on error
set status to "XAMPP does not seem to be running"
set dialogReply to display dialog ¬
"XAMPP's Apache is not running— Do you want to start XAMPP?" buttons {"Start", "Cancel"} default button 1
if button returned of dialogReply is "Cancel" then
return
else
display dialog ¬
"This may take up to half a minute. " & ¬
"Do not Force Quit unless it has been more than a minute" giving up after 5
end if
end try
if button returned of dialogReply is "Stop" then
do shell script ¬
" /Applications/xampp/xamppfiles/mampp stop" with administrator privileges -- stop xampp
else
if button returned of dialogReply is "Restart" then
do shell script ¬
" /Applications/xampp/xamppfiles/mampp restart" with administrator privileges -- restart xampp
else
if button returned of dialogReply is "Start" then
do shell script ¬
" /Applications/xampp/xamppfiles/mampp start" with administrator privileges -- start xampp
end if
end if
end if
activate
display dialog "Finished Action!" giving up after 5
to switch the version of php from 4 to 5 or back:
- Code: Select all
set dialogReply to display dialog " Choose which PHP version you want XAMPP to use" buttons {"PHP5", "PHP4", "Cancel"} default button 1
try
if button returned of dialogReply is "PHP5" then
do shell script "/Applications/xampp/xamppfiles/mampp php5" with administrator privileges -- stop xampp
else
if button returned of dialogReply is "PHP4" then
do shell script " /Applications/xampp/xamppfiles/mampp php4" with administrator privileges -- restart xampp
end if
end if
on error errMsg number errNum from errFrom partial result errResult to errTo
display dialog errMsg
end try
activate
display dialog " The PHP Switch is complete!" giving up after 5
will post more scripts or modifications of scripts if i find more or make/modify some additional code.
cheers,
Bo