Created
July 10, 2014 15:58
-
-
Save hayakawa/7dd983495d36f69e169a to your computer and use it in GitHub Desktop.
devenv.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
function apache() { | |
case "$1" in | |
"start" | "stop") | |
sudo /usr/sbin/apachectl $1; | |
;; | |
"status" ) | |
apachestat=`ps -efww|grep "httpd"|grep -v grep|wc -l`; | |
if [ ${apachestat} -gt 0 ]; then | |
echo "[Apache] start"; | |
else | |
echo "[Apache] stop"; | |
fi | |
;; | |
* ) | |
echo "Error! Unsupported command: $1"; | |
;; | |
esac | |
} | |
function mysql() { | |
case "$1" in | |
"start" | "stop") | |
sudo /usr/local/mysql/support-files/mysql.server $1; | |
;; | |
"status" ) | |
apachestat=`ps -efww|grep "mysql"|grep -v grep|wc -l`; | |
if [ ${apachestat} -gt 0 ]; then | |
echo "[Mysqld] start"; | |
else | |
echo "[Mysqld] stop"; | |
fi | |
;; | |
* ) | |
echo "Error! Unsupported command: $1"; | |
;; | |
esac | |
} | |
function usage() { | |
echo "Usage: $1 {start|stop|status|apachestart|apachestop|apachestatus|mysqlstart|mysqlstop|mysqlstatus}"; | |
} | |
if [ -z $1 ]; then | |
usage $0; | |
exit -1; | |
fi | |
case "$1" in | |
"start" ) | |
mysql start; | |
apache start; | |
;; | |
"stop" ) | |
apache stop; | |
mysql stop; | |
;; | |
"status" ) | |
apache status; | |
mysql status; | |
;; | |
"apachestart" ) | |
apache start; | |
;; | |
"apachestop" ) | |
apache stop; | |
;; | |
"apachestatus" ) | |
apache status; | |
;; | |
"mysqlstart" ) | |
mysql start; | |
;; | |
"mysqlstop" ) | |
mysql stop; | |
;; | |
"mysqlstatus" ) | |
mysql status; | |
;; | |
* ) | |
usage $1; | |
exit -1; | |
;; | |
esac | |
exit 0; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment