Made username, token checking more robust against configuration errors

This commit is contained in:
Sandro Jäckel 2019-07-06 16:45:38 +02:00
parent 9c92ac9342
commit fd7b8cd839
No known key found for this signature in database
GPG Key ID: 236B6291555E8401

View File

@ -9,10 +9,20 @@ if [[ -f /run/secrets/username ]]; then
TOKEN=$(cat /run/secrets/token) TOKEN=$(cat /run/secrets/token)
fi fi
if [[ -z $TOKEN ]]; then if [[ -z ${USERNAME:-} ]]; then
set -- "$(jq -j ".username, \" \", .token" "$CONFIG/server-settings.json")" USERNAME="$(jq -j ".username" "$CONFIG/server-settings.json")"
USERNAME=$1 fi
TOKEN=$2
if [[ -z ${TOKEN:-} ]]; then
TOKEN="$(jq -j ".token" "$CONFIG/server-settings.json")"
fi
if [[ -z ${USERNAME:-} ]]; then
echo "You need to provide your Factorio username to update mods."
fi
if [[ -z ${TOKEN:-} ]]; then
echo "You need to provide your Factorio token to update mods."
fi fi
./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN" ./update-mods.sh "$VERSION" "$MODS" "$USERNAME" "$TOKEN"