Merge pull request #24 from W3LFARe/19-using-the-whitelist_users-variable-in-unraid-causes-duplication-on-restart
19 using the whitelist users variable in unraid causes duplication on restart
This commit is contained in:
commit
105160f70e
1 changed files with 45 additions and 39 deletions
10
launch.sh
10
launch.sh
|
|
@ -49,16 +49,19 @@ fi
|
||||||
if [[ -n "$ONLINE_MODE" ]]; then
|
if [[ -n "$ONLINE_MODE" ]]; then
|
||||||
sed -i "s/online-mode=.*/online-mode=$ONLINE_MODE/" /data/server.properties
|
sed -i "s/online-mode=.*/online-mode=$ONLINE_MODE/" /data/server.properties
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Initialize whitelist
|
||||||
echo "[]" > whitelist.json
|
echo "[]" > whitelist.json
|
||||||
IFS=',' read -ra USERS <<< "$WHITELIST_USERS"
|
IFS=',' read -ra USERS <<< "$WHITELIST_USERS"
|
||||||
for raw_username in "${USERS[@]}"; do
|
for raw_username in "${USERS[@]}"; do
|
||||||
username=$(echo "$raw_username" | xargs)
|
username=$(echo "$raw_username" | xargs)
|
||||||
|
|
||||||
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
||||||
echo "Whitelist: Invalid username: '$username'. Skipping..."
|
echo "Whitelist: Invalid username: '$username'. Skipping..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UUID=$(curl -s "https://api.mojang.com/users/profiles/minecraft/$username" | jq -r '.id')
|
UUID=$(curl -s "https://playerdb.co/api/player/minecraft/$username" | jq -r '.data.player.id')
|
||||||
if [[ "$UUID" != "null" ]]; then
|
if [[ "$UUID" != "null" ]]; then
|
||||||
if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then
|
if jq -e ".[] | select(.uuid == \"$UUID\")" whitelist.json > /dev/null; then
|
||||||
echo "Whitelist: $username ($UUID) is already whitelisted."
|
echo "Whitelist: $username ($UUID) is already whitelisted."
|
||||||
|
|
@ -71,16 +74,19 @@ for raw_username in "${USERS[@]}"; do
|
||||||
echo "Whitelist: Failed to fetch UUID for $username."
|
echo "Whitelist: Failed to fetch UUID for $username."
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# Initialize ops
|
||||||
echo "[]" > ops.json
|
echo "[]" > ops.json
|
||||||
IFS=',' read -ra OPS <<< "$OP_USERS"
|
IFS=',' read -ra OPS <<< "$OP_USERS"
|
||||||
for raw_username in "${OPS[@]}"; do
|
for raw_username in "${OPS[@]}"; do
|
||||||
username=$(echo "$raw_username" | xargs)
|
username=$(echo "$raw_username" | xargs)
|
||||||
|
|
||||||
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
if [[ ! "$username" =~ ^[a-zA-Z0-9_]{3,16}$ ]]; then
|
||||||
echo "Ops: Invalid username: '$username'. Skipping..."
|
echo "Ops: Invalid username: '$username'. Skipping..."
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
UUID=$(curl -s "https://api.mojang.com/users/profiles/minecraft/$username" | jq -r '.id')
|
UUID=$(curl -s "https://playerdb.co/api/player/minecraft/$username" | jq -r '.data.player.id')
|
||||||
if [[ "$UUID" != "null" ]]; then
|
if [[ "$UUID" != "null" ]]; then
|
||||||
if jq -e ".[] | select(.uuid == \"$UUID\")" ops.json > /dev/null; then
|
if jq -e ".[] | select(.uuid == \"$UUID\")" ops.json > /dev/null; then
|
||||||
echo "Ops: $username ($UUID) is already an operator."
|
echo "Ops: $username ($UUID) is already an operator."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue