#!/usr/bin/env bash # # Refresh the vendored copy of Digital Extremes' drop tables. # # /Warframe reads Blog/Resources/droptables.html rather than warframe.com, # which blocks requests from the server. This runs before a publish so each # deploy ships current data. Commit the result. # # A failed refresh is a warning, not an error: the committed copy is still good # data, and an outage at DE should not block a deploy that has nothing to do # with Warframe. Missing the file entirely is an error, because then there is # nothing to publish. set -uo pipefail url="${WARFRAME_DROPTABLES_URL:-https://www.warframe.com/droptables}" repo="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" target="$repo/Blog/Resources/droptables.html" tmp="$(mktemp)" trap 'rm -f "$tmp"' EXIT de_last_update() { grep -A1 'Last Update:' "$1" 2>/dev/null | tail -1 | tr -d '\r' } keep_existing() { echo "WARNING: could not refresh the drop tables: $1" >&2 if [ ! -f "$target" ]; then echo "ERROR: and there is no committed copy at $target to fall back on." >&2 exit 1 fi echo "WARNING: publishing the committed copy (DE last update $(de_last_update "$target"))." >&2 exit 0 } echo "Fetching $url" curl -sSL --fail --max-time 180 -o "$tmp" "$url" || keep_existing "download failed" # The publish that follows ships whatever lands here, so an error page or a # truncated download must not replace a copy that is known good. The real page # is around 4 MB across twenty sections; anything far short of that is not it. bytes=$(wc -c < "$tmp" | tr -d ' ') sections=$(grep -c '