velocity-dockerized/velocity/bin/configure_and_start

39 lines
966 B
Bash
Executable File

#!/bin/sh
meta_dir="docker_meta"
apiURL=https://api.papermc.io/v2/projects/velocity
version=$(curl -X GET $apiURL | jq -r ".versions[-1]")
echo "Version is $version"
build=$(curl -X GET $apiURL/versions/$version/builds | jq -r ".builds[-1].build")
echo "Build is $build"
url=$apiURL/versions/$version/builds/$build/downloads/velocity-$version-$build.jar
echo "Full URL is: $url"
echo "Downloading to $PWD"
wget -O velocity.jar $url
if test ! -f "$meta_dir/setup_done"; then
if test "$VELOCITY_SECRET" = "REPLACE_THIS_WITH_A_RANDOM_SECRET"; then
echo "Refusing to configure Velocity with insecure secret"
exit 1
fi
echo "$VELOCITY_SECRET" > forwarding.secret
echo "Running velocity to generate configs"
echo shutdown | java -jar velocity.jar
sed -i 's/player-info-forwarding-mode.*$/player-info-forwarding-mode = "MODERN"/g' velocity.toml
mkdir -p "$meta_dir" && touch "$meta_dir/setup_done"
else
echo "Setup is done"
fi
echo "> $@"
exec "$@"