First stab at getting the scripts in a slightly better setup ready for future expansion work

This commit is contained in:
Wild1145 2021-06-27 18:35:05 +01:00
parent cdeb526da4
commit cdeff8c58c
5 changed files with 59 additions and 26 deletions

10
FreeOP Servers/.env.sh Normal file
View file

@ -0,0 +1,10 @@
#!
# These ones should be server specific
JVM_HEAP="18G"
PAPER_JAR_NAME="paperclip.jar"
# DO NOT Change these ones
SCREEN_NAME="TotalFreedom"
SARCASTIC_MESSAGE="The server is not running... Why don't you try starting it? <3"
RESET_FILE=/home/tfserver/.resetting

View file

@ -1,13 +1,17 @@
#! #!
if screen -list | grep -q "TotalFreedom";
#Pull in the .env file for variables.
source .env.sh
if screen -list | grep -q "$SCREEN_NAME";
then then
screen -X -S "TotalFreedom" stuff "^C^C^C^C^C^C^C^C^C^C^C^C^C" screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C^C^C^C^C^C"
sleep 5 sleep 5
else else
echo "The server is not running... Try starting it <3" echo "$SARCASTIC_MESSAGE"
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
fuser -k 25565/tcp fuser -k 25565/tcp
rm -f /home/tfserver/world/session.lock rm -f /home/tfserver/world/session.lock
@ -20,7 +24,7 @@ then
sleep 5 sleep 5
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
echo "Kill Command Failed. Please try again" echo "Kill Command Failed. Please try again"
else else

View file

@ -1,31 +1,35 @@
#! #!
#Pull in the .env file for variables.
source .env.sh
sleep 10 sleep 10
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
screen -X -S "TotalFreedom" stuff "stop^M" screen -X -S "$SCREEN_NAME" stuff "stop^M"
sleep 5 sleep 5
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
screen -X -S "TotalFreedom" stuff "^C" screen -X -S "$SCREEN_NAME" stuff "^C"
sleep 5 sleep 5
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
screen -X -S "TotalFreedom" stuff "^C^C^C^C^C^C^C^C" screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C"
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
echo "Graceful Shutdown Failed. Please run tf!kill" echo "Graceful Shutdown Failed. Please run tf!kill"
fi fi
if screen -list | grep -q "TotalFreedom"; if screen -list | grep -q "$SCREEN_NAME";
then then
echo "ERROR - We have been unable to re-start the server... Please execute this manually" echo "ERROR - We have been unable to re-start the server... Please execute this manually"
else else
screen -dmS TotalFreedom java -Xms18G -Xmx18G -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar paperclip.jar screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar $PAPER_JAR_NAME
echo "Server Started" echo "Server Started"
fi fi

View file

@ -1,8 +1,19 @@
#! #!
if screen -list | grep -q "TotalFreedom";
#Pull in the .env file for variables.
source .env.sh
if test -f "$RESET_FILE";
then then
echo "ERROR - There is an instance of the server already running. Make sure it is killed first and try again" echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete."
else else
screen -dmS TotalFreedom java -Xms18G -Xmx18G -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar paperclip.jar if screen -list | grep -q "$SCREEN_NAME";
then
echo "ERROR - There is an instance of the server already running. Make sure it is killed first and try again"
else
screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP -XX:+CMSClassUnloadingEnabled -XX:ParallelGCThreads=2 -XX:MinHeapFreeRatio=5 -XX:MaxHeapFreeRatio=10 -jar $PAPER_JAR_NAME
echo "Server Started" echo "Server Started"
fi
fi fi

View file

@ -1,21 +1,25 @@
#! #!
if screen -list | grep -q "TotalFreedom"; then
screen -X -S "TotalFreedom" stuff "stop^M" #Pull in the .env file for variables.
source .env.sh
if screen -list | grep -q "$SCREEN_NAME"; then
screen -X -S "$SCREEN_NAME" stuff "stop^M"
sleep 5 sleep 5
if screen -list | grep -q "TotalFreedom"; then if screen -list | grep -q "$SCREEN_NAME"; then
screen -X -S "TotalFreedom" stuff "^C" screen -X -S "$SCREEN_NAME" stuff "^C"
sleep 5 sleep 5
fi fi
if screen -list | grep -q "TotalFreedom"; then if screen -list | grep -q "$SCREEN_NAME"; then
screen -X -S "TotalFreedom" stuff "^C^C^C^C^C^C^C^C" screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C"
fi fi
if screen -list | grep -q "TotalFreedom"; then if screen -list | grep -q "$SCREEN_NAME"; then
echo "Graceful Shutdown Failed. Please run tf!kill" echo "Graceful Shutdown Failed. Please run tf!kill"
else else
echo "Server has been shut down succesfully." echo "Server has been shut down succesfully."
fi fi
else else
echo "The server is not running... Try starting it <3" echo "$SARCASTIC_MESSAGE"
fi fi