Add fetch and help options to configure.sh

This commit is contained in:
Leonard Steppy 2025-12-22 17:18:32 +01:00
parent c385743ccf
commit 401212cade

View File

@ -1,33 +1,102 @@
#!/usr/bin/env bash #!/usr/bin/env bash
if [ "$1" == "velocity" ]; then function main {
#disable online-mode
sed -ie "/online-mode/c\online-mode=false" server.properties # parse arguments
#change port to 25566 velocity=false
sed -ie "/server-port/c\server-port=25566" server.properties bungeecord=false
#enable velocity standalone=false
yq -iy ".proxies.velocity.enabled = true" config/paper-global.yml fetch=false
#disable bungeecord help=false
yq -iy ".settings.bungeecord = false" spigot.yml
elif [ "$1" == "bungeecord" ]; then for arg in "@$"; do
#disable online-mode case "$arg" in
sed -ie "/online-mode/c\online-mode=false" server.properties "velocity")
#change port to 25566 velocity=true
sed -ie "/server-port/c\server-port=25566" server.properties if $bungeecord || $standalone; then
#disable velocity echo "argument velocity can't be used together with bungeecord or standalone"
yq -iy ".proxies.velocity.enabled = false" config/paper-global.yml exit 1
#enable bungeecord fi
yq -iy ".settings.bungeecord = true" spigot.yml ;;
elif [ "$1" == "standalone" ]; then "benugeecord")
#enable online-mode bungeecord=true
sed -ie "/online-mode/c\online-mode=true" server.properties if $velocity || $standalone; then
#change port to 25565 echo "argument bungeecord can't be used together with velocity or standalone"
sed -ie "/server-port/c\server-port=25565" server.properties exit 1
#disable velocity fi
yq -iy ".proxies.velocity.enabled = false" config/paper-global.yml ;;
#disable bungeecord "standalone")
yq -iy ".settings.bungeecord = false" spigot.yml standalone=true
else if $bungeecord || $velocity; then
echo "Invalid argument, possible values are: [velocity, standalone, bungeecord]" echo "argument standalone can't be used together with bungeecord or velocity"
exit 1 exit 1
fi fi
;;
"--fetch")
fetch=true
;;
"--help")
help=true
;;
esac
done
if $help; then
echo "Configure the server to be used with BungeeCord, Velcity or in standalone mode."
echo ""
echo "Usage $0 [OPTIONS] <mode>"
echo ""
echo "mode:"
echo " velocity"
echo " bungeecord"
echo " standalone"
echo ""
echo "OPTIONS:"
echo " --fetch - print the current mode before reconfiguring the server. Nothing else will be printed."
echo " --help - show this message"
exit 0
fi
# fetch current configuration
if $fetch; then
if [ "$(yq '.proxies.velocity.enabled // false' config/paper-global.yml)" = "true" ]; then
echo "velocity"
elif [ "$(yq '.settings.bungeecord // false' spigot.yml)" = "true" ]; then
echo "bungeecord"
else
echo "standalone"
fi
fi
# TODO clean this part up a bit
if $velocity; then
#disable online-mode
sed -ie "/online-mode/c\online-mode=false" server.properties
#change port to 25566
sed -ie "/server-port/c\server-port=25566" server.properties
#enable velocity
yq -iy ".proxies.velocity.enabled = true" config/paper-global.yml
#disable bungeecord
yq -iy ".settings.bungeecord = false" spigot.yml
elif $bungeecord; then
#disable online-mode
sed -ie "/online-mode/c\online-mode=false" server.properties
#change port to 25566
sed -ie "/server-port/c\server-port=25566" server.properties
#disable velocity
yq -iy ".proxies.velocity.enabled = false" config/paper-global.yml
#enable bungeecord
yq -iy ".settings.bungeecord = true" spigot.yml
elif $standalone; then
#enable online-mode
sed -ie "/online-mode/c\online-mode=true" server.properties
#change port to 25565
sed -ie "/server-port/c\server-port=25565" server.properties
#disable velocity
yq -iy ".proxies.velocity.enabled = false" config/paper-global.yml
#disable bungeecord
yq -iy ".settings.bungeecord = false" spigot.yml
fi
}
main