diff --git a/src/shadowbox/docker/Dockerfile b/src/shadowbox/docker/Dockerfile index f5c1ec6b..968881cc 100644 --- a/src/shadowbox/docker/Dockerfile +++ b/src/shadowbox/docker/Dockerfile @@ -16,7 +16,7 @@ FROM node:8.15.0-alpine # Versions can be found at https://github.com/Jigsaw-Code/outline-ss-server/releases -ARG SS_VERSION=1.0.7 +ARG SS_VERSION=1.0.8 # Save metadata on the software versions we are using. LABEL shadowbox.node_version=8.15.0 @@ -25,8 +25,9 @@ LABEL shadowbox.outline-ss-server_version="${SS_VERSION}" ARG GITHUB_RELEASE LABEL shadowbox.github.release="${GITHUB_RELEASE}" -# We use curl to detect the server's public IP. -RUN apk add --no-cache curl +# We use curl to detect the server's public IP. We need to use the --date option in `date` to +# safely grab the ip-to-country database +RUN apk add --no-cache --upgrade coreutils curl COPY src/shadowbox/scripts scripts/ COPY src/shadowbox/scripts/update_mmdb.sh /etc/periodic/weekly/update_mmdb diff --git a/src/shadowbox/scripts/update_mmdb.sh b/src/shadowbox/scripts/update_mmdb.sh index 011e0575..acbfb9e7 100755 --- a/src/shadowbox/scripts/update_mmdb.sh +++ b/src/shadowbox/scripts/update_mmdb.sh @@ -5,15 +5,17 @@ # IP Geolocation by DB-IP (https://db-ip.com) +# Note that this runs on BusyBox sh, which lacks bash features. + TMPDIR="$(mktemp -d)" FILENAME="ip-country.mmdb" # We need to make sure that we grab an existing database at install-time -for monthdelta in {0..10}; do - newdate=$(date --date="-$monthdelta month" +%Y-%m) - ADDRESS="https://download.db-ip.com/free/ip-country-${newdate}.mmdb.gz" - curl --fail --silent "${ADDRESS}" -o "$TMPDIR/$FILENAME.gz" > /dev/null && break - if (( monthdelta == 10 )); then +for monthdelta in $(seq 10); do + newdate=$(date --date="-$monthdelta months" +%Y-%m) + ADDRESS="https://download.db-ip.com/free/dbip-country-lite-${newdate}.mmdb.gz" + curl --fail --silent "${ADDRESS}" -o "$TMPDIR/$FILENAME.gz" > /dev/null && break + if [[ $monthdelta -eq 10 ]]; then # A weird exit code on purpose -- we should catch this long before it triggers exit 2 fi