Last active
August 29, 2015 14:09
-
-
Save e0da/e1475ec3b032c02f9af5 to your computer and use it in GitHub Desktop.
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/sh | |
# Example usage: | |
# lctl stop mysql | |
# lctl start solr | |
# lctl restart rabbitmq | |
# lctl rabbitmq <- no action argument is equivalent to a restart argument | |
set -ex | |
if [ -z "$2" ]; then | |
command=restart | |
job=$1 | |
else | |
command=$1 | |
job=$2 | |
fi | |
start_or_stop() { | |
local job_name | |
launchctl list | grep $job | awk '{print $3}' | | |
while read job_name; do | |
launchctl $command $job_name | |
done | |
} | |
case $command in | |
start|stop) | |
start_or_stop | |
;; | |
restart) | |
command=stop | |
start_or_stop | |
command=start | |
start_or_stop | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment