diff --git a/FreeOP Servers/gettemplates.sh b/FreeOP Servers/gettemplates.sh new file mode 100644 index 0000000..6c2a534 --- /dev/null +++ b/FreeOP Servers/gettemplates.sh @@ -0,0 +1,15 @@ +#! + +declare -a dirs +i=1 +for d in /home/tfserver/template/*/ +do + d=${d#"/home/tfserver/template/"} + dirs[i++]="${d%/}" +done +echo "There are ${#dirs[@]} templates to chose from" +for((i=1;i<=${#dirs[@]};i++)) +do + echo $i")" "${dirs[i]}" +done + diff --git a/FreeOP Servers/reset.sh b/FreeOP Servers/reset.sh new file mode 100644 index 0000000..b2fc143 --- /dev/null +++ b/FreeOP Servers/reset.sh @@ -0,0 +1,57 @@ +#! + +#Pull in the .env file for variables. +source .env.sh + +TIMESTAMP=`date +%Y-%m-%d_%H-%M-%S` +WORLDS=("adminworld" "flatlands" "masterbuilderworld" "plotworld" "world" "world_nether" "world_the_end") + +if test -f "/home/tfserver/.noresets" +then +echo "Resets are not permitted on this server." +exit 1 +else + if [ -z "$1" ] + then + echo "Invalid Selection" + exit 1 + else + if [ -d "/home/tfserver/archives" ] + then + echo "Archives will be stored in /home/tfserver/archives" + else + mkdir -p /home/tfserver/archives + fi + + if [ -d "/home/tfserver/template/$1" ] + then + echo "The folder exists so this would run." + if screen -list | grep -q "$SCREEN_NAME"; + then + source /home/tfserver/stop.sh + fi + # Write the reset file to disk so we make sure if someone is stupid and tries to now re-start the server, the world doesn't fucking end... + touch $RESET_FILE + + for world in ${WORLDS[@]}; + do + if [ -d "/home/tfserver/$world" ] + then + tar -zcvf $world-$TIMESTAMP.tar.gz /home/tfserver/$world + mv /home/tfserver/$world-$TIMESTAMP.tar.gz /home/tfserver/archives//$world-$TIMESTAMP.tar.gz + rm -rf /home/tfserver/$world + echo "The world named $world has now been archived" + fi + done + + # Need to add something around handling the MySQL shit here + + echo "Something Something restore the template to be the world, something something I'll get around to this..." + sleep 20 + rm -f $RESET_FILE + source /home/tfserver/start.sh + else + echo "ERROR - The template: $1 you have attempted to restore, does not exist." + fi + fi +fi \ No newline at end of file diff --git a/FreeOP Servers/spigot-restart.sh b/FreeOP Servers/spigot-restart.sh index 032d000..b6c30ef 100644 --- a/FreeOP Servers/spigot-restart.sh +++ b/FreeOP Servers/spigot-restart.sh @@ -3,33 +3,42 @@ #Pull in the .env file for variables. source .env.sh -sleep 10 -if screen -list | grep -q "$SCREEN_NAME"; +if test -f "$RESET_FILE"; then - screen -X -S "$SCREEN_NAME" stuff "stop^M" - sleep 5 -fi - -if screen -list | grep -q "$SCREEN_NAME"; -then - screen -X -S "$SCREEN_NAME" stuff "^C" - sleep 5 -fi - -if screen -list | grep -q "$SCREEN_NAME"; -then - screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C" -fi - -if screen -list | grep -q "$SCREEN_NAME"; -then - echo "Graceful Shutdown Failed. Please run tf!kill" -fi - -if screen -list | grep -q "$SCREEN_NAME"; -then - echo "ERROR - We have been unable to re-start the server... Please execute this manually" + echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete." + exit 1 else - screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME - echo "Server Started" -fi + sleep 10 + if screen -list | grep -q "$SCREEN_NAME"; + then + screen -X -S "$SCREEN_NAME" stuff "stop^M" + sleep 5 + fi + + if screen -list | grep -q "$SCREEN_NAME"; + then + screen -X -S "$SCREEN_NAME" stuff "^C" + sleep 5 + fi + + if screen -list | grep -q "$SCREEN_NAME"; + then + screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C" + fi + + if screen -list | grep -q "$SCREEN_NAME"; + then + echo "Graceful Shutdown Failed. Please run tf!kill" + exit 1 + fi + + if screen -list | grep -q "$SCREEN_NAME"; + then + echo "ERROR - We have been unable to re-start the server... Please execute this manually" + exit 1 + else + screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME + echo "Server Started" + exit 0 + fi +fi \ No newline at end of file diff --git a/FreeOP Servers/start.sh b/FreeOP Servers/start.sh index 72406d8..7bab46e 100644 --- a/FreeOP Servers/start.sh +++ b/FreeOP Servers/start.sh @@ -6,14 +6,15 @@ source .env.sh if test -f "$RESET_FILE"; then echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete." + exit 1 else 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" + exit 1 else screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME echo "Server Started" + exit 0 fi fi - - diff --git a/FreeOP Servers/stop.sh b/FreeOP Servers/stop.sh index 0cd5a8e..9e80772 100644 --- a/FreeOP Servers/stop.sh +++ b/FreeOP Servers/stop.sh @@ -3,23 +3,32 @@ #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 - if screen -list | grep -q "$SCREEN_NAME"; then - screen -X -S "$SCREEN_NAME" stuff "^C" - sleep 5 - fi - - if screen -list | grep -q "$SCREEN_NAME"; then - screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C" - fi - - if screen -list | grep -q "$SCREEN_NAME"; then - echo "Graceful Shutdown Failed. Please run tf!kill" - else - echo "Server has been shut down succesfully." - fi +if test -f "$RESET_FILE"; +then + echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete." + exit 1 else - echo "$SARCASTIC_MESSAGE" -fi + if screen -list | grep -q "$SCREEN_NAME"; then + screen -X -S "$SCREEN_NAME" stuff "stop^M" + sleep 5 + if screen -list | grep -q "$SCREEN_NAME"; then + screen -X -S "$SCREEN_NAME" stuff "^C" + sleep 5 + fi + + if screen -list | grep -q "$SCREEN_NAME"; then + screen -X -S "$SCREEN_NAME" stuff "^C^C^C^C^C^C^C^C" + fi + + if screen -list | grep -q "$SCREEN_NAME"; then + echo "Graceful Shutdown Failed. Please run tf!kill" + exit 1 + else + echo "Server has been shut down succesfully." + exit 0 + fi + else + echo "$SARCASTIC_MESSAGE" + exit 0 + fi +fi \ No newline at end of file