103 lines
2.8 KiB
Bash
Executable File
103 lines
2.8 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
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
|