Last active
August 29, 2015 14:13
-
-
Save magnetik/83e144959a73e9ce8b50 to your computer and use it in GitHub Desktop.
Script to auto restart server after a certain duration (like 20 days)
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 | |
SERVER_DIRECTORY="/opt/maniaplanet-server/" | |
SERVER_TIMEOUT="298h" #298h ~= 12.4d | |
if [ "$(groups | grep games)" ]; | |
then | |
cd $SERVER_DIRECTORY | |
while true; do | |
timeout --foreground $SERVER_TIMEOUT ./ManiaPlanetServer "$@" | |
RETVAL=$? | |
if [[ $RETVAL -ne 124 ]]; then | |
break | |
fi | |
done | |
exec | |
else | |
echo "You are not member of the group 'games'" | |
echo "Please type :" | |
echo "sudo usermod -a -G games <username>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment