Add quiet flag and produce default output
This commit is contained in:
parent
193045bd40
commit
4f710e80be
38
configure.sh
38
configure.sh
@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# Constants
|
||||
|
||||
# port of the server in standalone mode, aka the open port
|
||||
STANDALONE_PORT=25565
|
||||
# port of the server in proxy mode, aka the internal port
|
||||
@ -18,6 +20,11 @@ VIA_VERSION_REPO="ViaVersion/ViaVersion"
|
||||
# Github repo of ViaBackwards project
|
||||
VIA_BACKWARDS_REPO="ViaVersion/ViaBackwards"
|
||||
|
||||
# Runtime variables
|
||||
|
||||
quiet=false
|
||||
|
||||
|
||||
function main {
|
||||
|
||||
# parse arguments
|
||||
@ -32,33 +39,33 @@ function main {
|
||||
"velocity")
|
||||
velocity=true
|
||||
if $bungeecord || $standalone; then
|
||||
echo "argument velocity can't be used together with bungeecord or standalone"
|
||||
exit 1
|
||||
err "argument velocity can't be used together with bungeecord or standalone"
|
||||
fi
|
||||
;;
|
||||
"bungeecord")
|
||||
bungeecord=true
|
||||
if $velocity || $standalone; then
|
||||
echo "argument bungeecord can't be used together with velocity or standalone"
|
||||
exit 1
|
||||
err "argument bungeecord can't be used together with velocity or standalone"
|
||||
fi
|
||||
;;
|
||||
"standalone")
|
||||
standalone=true
|
||||
if $bungeecord || $velocity; then
|
||||
echo "argument standalone can't be used together with bungeecord or velocity"
|
||||
exit 1
|
||||
err "argument standalone can't be used together with bungeecord or velocity"
|
||||
fi
|
||||
;;
|
||||
"--fetch")
|
||||
fetch=true
|
||||
quiet=true
|
||||
;;
|
||||
"--quiet" | "-q")
|
||||
quiet=true
|
||||
;;
|
||||
"--help")
|
||||
help=true
|
||||
;;
|
||||
*)
|
||||
echo "Unknown argument: $arg"
|
||||
exit 1
|
||||
err "Unknown argument: $arg"
|
||||
;;
|
||||
esac
|
||||
done
|
||||
@ -76,6 +83,7 @@ function main {
|
||||
echo "OPTIONS:"
|
||||
echo " --fetch - print the current mode before reconfiguring the server. Nothing else will be printed."
|
||||
echo " --help - show this message"
|
||||
echo " -q --quiet - Dont print any output, except for output which is caused by --fetch"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
@ -187,7 +195,19 @@ function download_jar_from_github {
|
||||
local repo=$1
|
||||
local dst=$2
|
||||
local url=$(curl -s "https://api.github.com/repos/$repo/releases/latest" | jq -r '.assets[] | select(.name | endswith(".jar")) | .browser_download_url')
|
||||
wget -qP "$dst" "$url"
|
||||
if $quiet; then
|
||||
wget -qP "$dst" "$url"
|
||||
else
|
||||
wget -P "$dst" "$url"
|
||||
fi
|
||||
}
|
||||
|
||||
# Shows ans error message and exits the program with code 1
|
||||
#
|
||||
# Usage: err <msg>
|
||||
function err {
|
||||
echo "$1"
|
||||
exit 1
|
||||
}
|
||||
|
||||
main "$@"
|
||||
|
||||
Loading…
Reference in New Issue
Block a user