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
if [ "$1" == "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 [ "$1" == "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 [ "$1" == "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
else
echo "Invalid argument, possible values are: [velocity, standalone, bungeecord]"
exit 1
fi
function main {
# parse arguments
velocity=false
bungeecord=false
standalone=false
fetch=false
help=false
for arg in "@$"; do
case "$arg" in
"velocity")
velocity=true
if $bungeecord || $standalone; then
echo "argument velocity can't be used together with bungeecord or standalone"
exit 1
fi
;;
"benugeecord")
bungeecord=true
if $velocity || $standalone; then
echo "argument bungeecord can't be used together with velocity or standalone"
exit 1
fi
;;
"standalone")
standalone=true
if $bungeecord || $velocity; then
echo "argument standalone can't be used together with bungeecord or velocity"
exit 1
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