Skip to content

Instantly share code, notes, and snippets.

@hayakawa
Created July 10, 2014 15:58
Show Gist options
  • Save hayakawa/7dd983495d36f69e169a to your computer and use it in GitHub Desktop.
Save hayakawa/7dd983495d36f69e169a to your computer and use it in GitHub Desktop.
devenv.sh
#!/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