Skip to content

Instantly share code, notes, and snippets.

@SamEureka
Created October 24, 2017 15:50
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save SamEureka/97b8b6dbcc950fdbfec73f742fa9d12d to your computer and use it in GitHub Desktop.
Save SamEureka/97b8b6dbcc950fdbfec73f742fa9d12d to your computer and use it in GitHub Desktop.
stop script for multiple MC servers // not DRY yet
#!/bin/bash
# Check to see if direwolf is runing
dire=`screen -list | grep direwolf`
# TODO put this in a while loop to make it better
# (it's good enough for now)
# TODO make it all DRY
if [[ -z $dire ]]
then
echo "Direwolf20 is not running..."
else
echo "Shutting Direwolf20 down..."
screen -S direwolf -p 0 -X stuff "stop$(printf \\r)" &&
sleep 10
dire=`screen -list | grep direwolf`
if [[ -z $dire ]]
then
echo "Direwolf20 has shutdown!"
else
echo "Trying to shut this shit down again..."
screen -S direwolf -p 0 -X stuff "stop$(printf \\r)"
sleep 30
dire=`screen -list | grep direwolf`
if [[ -z $dire ]]
then
echo "Geesus... it finally shutdown properly."
else
echo "Something ain\'t right here... try \'sudo reboot\' or \'kill\'"
fi
fi
fi
# Check to see if infinity is runing
inf=`screen -list | grep infinity`
if [[ -z $inf ]]
then
echo "FTB Infinity is not running..."
else
echo "Shutting FTB Infinity down..."
screen -S infinity -p 0 -X stuff "stop$(printf \\r)" &&
sleep 10
inf=`screen -list | grep infinity`
if [[ -z $inf ]]
then
echo "FTB Infinity has shutdown!"
else
echo "Trying to shut this shit down again..."
screen -S infinity -p 0 -X stuff "stop$(printf \\r)" &&
sleep 30
inf=`screen -list | grep infinity`
if [[ -z $inf ]]
then
echo "Geesus... it finally shutdown properly."
else
echo "Something ain\'t right here... try \'sudo reboot\' or \'kill\'"
fi
fi
fi
# Check to see if skyfactory is runing
sky=`screen -list | grep skyfactory`
if [[ -z $sky ]]
then
echo "Sky Factory is not running..."
else
echo "Shutting Sky Factory down..."
screen -S skyfactory -p 0 -X stuff "stop$(printf \\r)" &&
sleep 10
sky=`screen -list | grep skyfactory`
if [[ -z $sky ]]
then
echo "Sky Factory has shutdown!"
else
echo "Trying to shut this shit down again..."
screen -S skyfactory -p 0 -X stuff "stop$(printf \\r)"
sleep 30
sky=`screen -list | grep skyfactory`
if [[ -z $sky ]]
then
echo "Geesus... it finally shutdown properly."
else
echo "Something ain\'t right here... try \'sudo reboot\' or \'kill\'"
fi
fi
fi
# Check to see if challenges is runing
challenges=`screen -list | grep challenges`
if [[ -z $challenges ]]
then
echo "Sky Factory Challenges is not running..."
else
echo "Shutting Sky Factory Challenges down..."
screen -S challenges -p 0 -X stuff "stop$(printf \\r)" &&
sleep 10
challenges=`screen -list | grep challenges`
if [[ -z $challenges ]]
then
echo "Sky Factory Challenges has shutdown!"
else
echo "Trying to shut this shit down again..."
screen -S challenges -p 0 -X stuff "stop$(printf \\r)"
sleep 30
challenges=`screen -list | grep challenges`
if [[ -z $challenges ]]
then
echo "Geesus... it finally shutdown properly."
else
echo "Something ain\'t right here... try \'sudo reboot\' or \'kill\'"
fi
fi
fi
# Check to see if beyond is runing
beyond=`screen -list | grep beyond`
if [[ -z $beyond ]]
then
echo "FTB Beyond is not running..."
else
echo "Shutting FTB Beyond down..."
screen -S beyond -p 0 -X stuff "stop$(printf \\r)" &&
sleep 10
beyond=`screen -list | grep beyond`
if [[ -z $beyond ]]
then
echo "FTB Beyond has shutdown!"
else
echo "Trying to shut this shit down again..."
screen -S beyond -p 0 -X stuff "stop$(printf \\r)"
sleep 30
beyond=`screen -list | grep beyond`
if [[ -z $beyond ]]
then
echo "Geesus... it finally shutdown properly."
else
echo "Something ain\'t right here... try \'sudo reboot\' or \'kill\'"
fi
fi
fi
# Let everyone know that we are done
echo "I think we are done here..."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment