Skip to content

Instantly share code, notes, and snippets.

@akkijp
Created October 17, 2015 21:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akkijp/2e0e6ff478e6d1a99061 to your computer and use it in GitHub Desktop.
Save akkijp/2e0e6ff478e6d1a99061 to your computer and use it in GitHub Desktop.
macからlinuxのサービスコマンドみたいに扱えるようにした
_mservice_nginx() {
case $1 in
"start" ) nginx -t && nginx;;
"stop" ) nginx -s stop;;
"reload" ) nginx -s reload;;
"restart" ) nginx -t && nginx -s stop && nginx;;
"check" ) nginx -t;;
* ) echo "Usage: mservice nginx {start|stop|reload|restart|check}" 1>&2;;
esac
}
_mservice_mysql() {
case $1 in
"start" ) mysql.server start;;
"stop" ) mysql.server stop;;
"status" ) mysql.server status;;
"configure" ) mysql_secure_installation;;
* ) echo "Usage: mservice mysql {start|stop|status|configure}" 1>&2;;
esac
}
_mservice_php-fpm() {
case $1 in
"start" ) php56-fpm start;;
"stop" ) php56-fpm stop;;
"force-quit" ) php56-fpm force-quit;;
"restart" ) php56-fpm restart;;
"reload" ) php56-fpm reload;;
"status" ) php56-fpm status;;
* ) echo "Usage: mservice php-fpm {start|stop|force-quit|restart|reload|status}" 1>&2;;
esac
}
function mservice {
case $1 in
"nginx" ) _mservice_nginx $2;;
"mysql" ) _mservice_mysql $2;;
"php-fpm" ) _mservice_php-fpm $2;;
* ) echo "Usage: mservice [service] [action]" 1>&2;
echo "service: nginx mysql php-fpm";;
esac
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment