#!/bin/ash
mkdir -p /mnt/server
LATEST_LIMBO_NAME=$(curl -s https://ci.loohpjames.com/job/Limbo/lastSuccessfulBuild/api/json | jq -r .artifacts[1].displayPath)
cd /mnt/server || exit
if [ -f "${SERVER_JARFILE}" ]; then
mv "${SERVER_JARFILE}" "${SERVER_JARFILE}".old
fi
echo "Downloading Limbo server jar..."
curl -o "${SERVER_JARFILE}" https://ci.loohpjames.com/job/Limbo/lastSuccessfulBuild/artifact/target/$LATEST_LIMBO_NAME
if [ ! -f server.properties ]; then
echo "Downloading Limbo server.properties"
curl -o server.properties https://raw.githubusercontent.com/LOOHP/Limbo/master/src/main/resources/server.properties
fi