Add fetch and help options to configure.sh
This commit is contained in:
parent
c385743ccf
commit
401212cade
81
configure.sh
81
configure.sh
@ -1,6 +1,75 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
if [ "$1" == "velocity" ]; then
|
||||
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
|
||||
@ -9,7 +78,7 @@ if [ "$1" == "velocity" ]; then
|
||||
yq -iy ".proxies.velocity.enabled = true" config/paper-global.yml
|
||||
#disable bungeecord
|
||||
yq -iy ".settings.bungeecord = false" spigot.yml
|
||||
elif [ "$1" == "bungeecord" ]; then
|
||||
elif $bungeecord; then
|
||||
#disable online-mode
|
||||
sed -ie "/online-mode/c\online-mode=false" server.properties
|
||||
#change port to 25566
|
||||
@ -18,7 +87,7 @@ elif [ "$1" == "bungeecord" ]; then
|
||||
yq -iy ".proxies.velocity.enabled = false" config/paper-global.yml
|
||||
#enable bungeecord
|
||||
yq -iy ".settings.bungeecord = true" spigot.yml
|
||||
elif [ "$1" == "standalone" ]; then
|
||||
elif $standalone; then
|
||||
#enable online-mode
|
||||
sed -ie "/online-mode/c\online-mode=true" server.properties
|
||||
#change port to 25565
|
||||
@ -27,7 +96,7 @@ elif [ "$1" == "standalone" ]; then
|
||||
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
|
||||
}
|
||||
|
||||
main
|
||||
|
||||
Loading…
Reference in New Issue
Block a user