PickShadow/server/debugstart.sh
2024-04-23 17:15:46 +02:00

31 lines
881 B
Bash
Executable file

#!/bin/bash
set -eo pipefail
if [ -z "${TIMEOUT}" ]; then
echo "-> Set \$TIMEOUT"
export "TIMEOUT=1s"
fi
while true; do
clear
echo "-> Removing plugin data"
rm -rfv /tmp/pssp-plugin-data
echo "-> Creating plugin directory"
mkdir -p /tmp/pssp-plugin-data
echo "-> Downloading server"
if [ ! -f "server.jar" ]; then
if ! wget "https://api.purpurmc.org/v2/purpur/1.20.4/latest/download" -O server.jar.tmp; then
echo "-> Failed to download server, exiting"
rm -rf server.jar.tmp
exit 1
fi
mv server.jar.tmp server.jar
fi
echo "-> Starting server"
if java --add-modules=jdk.incubator.vector -jar server.jar nogui --nogui; then
echo "-> Server shut down."
echo " Restarting in ${TIMEOUT}. Press CTRL+C to cancel."
else
echo "-> Server stopped with code ${?}."
echo " Restarting in ${TIMEOUT}. Press CTRL+C to cancel."
fi
sleep "${TIMEOUT}"
done