mirror of
https://github.com/TotalFreedomMC/TF-Scripts.git
synced 2024-12-23 00:15:10 +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,33 +3,42 @@
|
||||||
#Pull in the .env file for variables.
|
#Pull in the .env file for variables.
|
||||||
source .env.sh
|
source .env.sh
|
||||||
|
|
||||||
sleep 10
|
if test -f "$RESET_FILE";
|
||||||
if screen -list | grep -q "$SCREEN_NAME";
|
|
||||||
then
|
then
|
||||||
screen -X -S "$SCREEN_NAME" stuff "stop^M"
|
echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete."
|
||||||
sleep 5
|
exit 1
|
||||||
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"
|
|
||||||
else
|
else
|
||||||
screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME
|
sleep 10
|
||||||
echo "Server Started"
|
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
|
fi
|
|
@ -6,14 +6,15 @@ source .env.sh
|
||||||
if test -f "$RESET_FILE";
|
if test -f "$RESET_FILE";
|
||||||
then
|
then
|
||||||
echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete."
|
echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete."
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
if screen -list | grep -q "$SCREEN_NAME";
|
if screen -list | grep -q "$SCREEN_NAME";
|
||||||
then
|
then
|
||||||
echo "ERROR - There is an instance of the server already running. Make sure it is killed first and try again"
|
echo "ERROR - There is an instance of the server already running. Make sure it is killed first and try again"
|
||||||
|
exit 1
|
||||||
else
|
else
|
||||||
screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME
|
screen -dmS $SCREEN_NAME java -Xms$JVM_HEAP -Xmx$JVM_HEAP $JVM_LAUNCH_OPTS -jar $PAPER_JAR_NAME
|
||||||
echo "Server Started"
|
echo "Server Started"
|
||||||
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -3,23 +3,32 @@
|
||||||
#Pull in the .env file for variables.
|
#Pull in the .env file for variables.
|
||||||
source .env.sh
|
source .env.sh
|
||||||
|
|
||||||
if screen -list | grep -q "$SCREEN_NAME"; then
|
if test -f "$RESET_FILE";
|
||||||
screen -X -S "$SCREEN_NAME" stuff "stop^M"
|
then
|
||||||
sleep 5
|
echo "CRITICAL ERORR - Server is currently re-setting. Please wait for this action to complete."
|
||||||
if screen -list | grep -q "$SCREEN_NAME"; then
|
exit 1
|
||||||
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
|
|
||||||
else
|
else
|
||||||
echo "$SARCASTIC_MESSAGE"
|
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
|
fi
|
Loading…
Reference in a new issue