Skip to content

Instantly share code, notes, and snippets.

@saamich
Created March 12, 2015 13:33
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 saamich/ab0eb33a53390892b638 to your computer and use it in GitHub Desktop.
Save saamich/ab0eb33a53390892b638 to your computer and use it in GitHub Desktop.
#!/bin/bash -e
SERVICE=$1
case "$2" in
run|start )
STATUS=run ;;
stop|down )
STATUS=down ;;
* )
STATUS=run ;;
esac
if [ -z "$SERVICE" ]; then
echo "Service not defined"; exit 1
fi
curStatus=$(sv check "$SERVICE")
if [ $? -ne 0 ]; then
echo "Service $SERVICE not exists"; exit 1
fi
until (echo $curStatus|grep $STATUS 1>/dev/null 2>&1) ; do
echo "Wait for service $SERVICE $STATUS"
sleep 1
curStatus=$(sv check "$SERVICE")
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment