Last active
March 22, 2016 19:54
-
-
Save dwelch2344/d25270f44bf2917cdf97 to your computer and use it in GitHub Desktop.
Depending on the environment variables, this script either runs a script that is on the local machine or downloads one from the web to run. It also *SHOULD* clean up by killing the java process when terminated, but it doesn't
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/bash | |
function die { | |
curl -X POST -d "killed=true" http://requestb.in/qqvaouqq | |
echo "Ending on signal $1" | |
if [ -n "$EXIT_SCRIPT" ]; then | |
echo "Executing exit script $EXIT_SCRIPT" | |
/bin/bash $EXIT_SCRIPT | |
else | |
echo "No exit script found. Executing: pkill -f 'java'" | |
pkill -f 'java' | |
fi | |
exit 0 | |
} | |
trap 'die "SIGINT"' SIGINT | |
trap 'die "SIGQUIT"' SIGQUIT | |
if [ -n "$RUN_SCRIPT" ]; then | |
echo "Copying RUN_SCRIPT $RUN_SCRIPT" | |
SCRIPT=__runscript.sh | |
cp $RUN_SCRIPT $SCRIPT | |
fi | |
if [ -n "$WEB_SCRIPT" ]; then | |
echo "Pulling WEB_SCRIPT $WEB_SCRIPT" | |
SCRIPT=__runscript.sh | |
curl -fsSL $WEB_SCRIPT > $SCRIPT | |
fi | |
[ -z "$SCRIPT" ] && echo "No environment variable SCRIPT specified; failing" && exit 1; | |
if [ -n "$EXIT_RUN_SCRIPT" ]; then | |
echo "Copying EXIT_RUN_SCRIPT $EXIT_RUN_SCRIPT" | |
EXIT_SCRIPT=__exit.sh | |
cp $EXIT_RUN_SCRIPT $EXIT_SCRIPT | |
fi | |
if [ -n "$EXIT_WEB_SCRIPT" ]; then | |
echo "Pulling EXIT_WEB_SCRIPT $EXIT_WEB_SCRIPT" | |
EXIT_SCRIPT=__exit.sh | |
curl -fsSL $WEB_SCRIPT > $EXIT_SCRIPT | |
fi | |
/bin/bash __runscript.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment