From 7f39d1f22ebc5e930cd9a7a4a3f8e48639676b90 Mon Sep 17 00:00:00 2001 From: Geoff Bourne Date: Sat, 15 Jul 2017 20:02:40 -0500 Subject: [PATCH] [mc] Properly check empty json files to fix For #162 --- minecraft-server/start-minecraft.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/minecraft-server/start-minecraft.sh b/minecraft-server/start-minecraft.sh index 3e9c2ab5..7474993e 100755 --- a/minecraft-server/start-minecraft.sh +++ b/minecraft-server/start-minecraft.sh @@ -1,5 +1,7 @@ #!/bin/bash +shopt -s nullglob + #umask 002 export HOME=/data @@ -561,12 +563,12 @@ if [ -n "$ICON" -a ! -e server-icon.png ]; then fi # Make sure files exist and are valid JSON (for pre-1.12 to 1.12 upgrades) -if [[ ! -e banned-players.json || ! $(jq banned-players.json &> /dev/null) ]]; then - echo '[]' > banned-players.json -fi -if [[ ! -e banned-ips.json || ! $(jq banned-ips.json &> /dev/null) ]]; then - echo '[]' > banned-ips.json -fi +for j in *.json; do + if [[ $(python -c "print open('$j').read().strip()==''") = True ]]; then + echo "Fixing JSON $j" + echo '[]' > $j + fi +done # If any modules have been provided, copy them over mkdir -p /data/mods