mirror of
https://github.com/TotalFreedomMC/TF-Scripts.git
synced 2024-12-22 16:05:03 +00:00
Various updates, reset mostly works now
Just need to hook the MySQL up and then the bare minimum reset works, next step then will be to unzip maps and all that shite.
This commit is contained in:
parent
8e4545653d
commit
53b0fa94df
5 changed files with 140 additions and 49 deletions
15
FreeOP Servers/gettemplates.sh
Normal file
15
FreeOP Servers/gettemplates.sh
Normal file
|
@ -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
|
||||
|
57
FreeOP Servers/reset.sh
Normal file
57
FreeOP Servers/reset.sh
Normal file
|
@ -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
|
|
@ -3,6 +3,11 @@
|
|||
#Pull in the .env file for variables.
|
||||
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
|
||||
sleep 10
|
||||
if screen -list | grep -q "$SCREEN_NAME";
|
||||
then
|
||||
|
@ -24,12 +29,16 @@ 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
|
|
@ -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
|
||||
|
||||
|
||||
|
|
|
@ -3,6 +3,11 @@
|
|||
#Pull in the .env file for variables.
|
||||
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
|
||||
screen -X -S "$SCREEN_NAME" stuff "stop^M"
|
||||
sleep 5
|
||||
|
@ -17,9 +22,13 @@ if screen -list | grep -q "$SCREEN_NAME"; then
|
|||
|
||||
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
|
Loading…
Reference in a new issue