Created
December 10, 2013 19:16
-
-
Save lsheng/7896425 to your computer and use it in GitHub Desktop.
Hook to automatically stop Bento cluster instances on suspend.
This file contains 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/bash | |
# Put this file in /etc/pm/sleep.d for Ubuntu machines. | |
BENTO=$(ps aux | grep 'bento' | grep 'java') | |
if [[ ! -z $BENTO ]]; then | |
BENTO_PID=$(echo $BENTO | awk '{print $2}') | |
BENTO_PID_FILE=$(echo $BENTO | sed -e 's/.*-cp ://g' | sed -e 's/cluster.*/cluster/')/state/bento-cluster.pid | |
else | |
exit $NA | |
fi | |
case $1 in | |
hibernate|suspend) | |
echo "Shutting down bento" | |
kill -9 $BENTO_PID | |
rm ${BENTO_PID_FILE} | |
;; | |
*) exit $NA | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment