Skip to content

Instantly share code, notes, and snippets.

@JAW-Dev
Created July 16, 2017 14:39
Show Gist options
  • Save JAW-Dev/d5f8ec74b01dddb63013ac3f9ca2600e to your computer and use it in GitHub Desktop.
Save JAW-Dev/d5f8ec74b01dddb63013ac3f9ca2600e to your computer and use it in GitHub Desktop.
Bash script for strating and stopping Valet and MySQL
#!/bin/sh
# Check if a service is running.
function running() {
if ps ax | grep -v grep | grep "$1" &> /dev/null; then
return 0
else
return 1
fi;
}
if running "nginx" && ! running "mysqld"; then
brew services start mysql
elif ! running "nginx" && running "mysqld"; then
valet start
elif ! running "nginx" && ! running "mysqld"; then
valet start
brew services start mysql
else running "nginx" && running "mysqld";
valet stop
brew services stop mysql
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment