fix: allow verified offline monitoring releases
This commit is contained in:
@@ -7,6 +7,7 @@ REDIS_EXPORTER_VERSION="1.89.0"
|
||||
REDIS_EXPORTER_SHA256_ARM64="1a70d42cd1d96a9388f8b528f55ad5bdc2c3cbd911c1dff3875fcb9ac01fa28a"
|
||||
NGINX_EXPORTER_VERSION="1.5.3"
|
||||
NGINX_EXPORTER_SHA256_ARM64="a0b1a5f5bba09483bd2e04c759c1a75fffe46ca72c0314ee2bb925d1742ff23b"
|
||||
MONITORING_RELEASE_CACHE_DIR="${MONITORING_RELEASE_CACHE_DIR:-}"
|
||||
|
||||
if [[ "$(id -u)" -ne 0 ]]; then echo "Run as root." >&2; exit 1; fi
|
||||
for command_name in systemctl nginx curl install ss; do command -v "$command_name" >/dev/null || { echo "Missing command: $command_name" >&2; exit 1; }; done
|
||||
@@ -15,10 +16,15 @@ log() { printf '\n[%s] %s\n' "$(date '+%F %T')" "$*"; }
|
||||
|
||||
install_release_binary() {
|
||||
local url="$1" expected_sha256="$2" archive_member="$3" destination="$4"
|
||||
local work_dir archive
|
||||
local work_dir archive asset_name
|
||||
work_dir="$(mktemp -d /tmp/cmpp-monitoring.XXXXXX)"
|
||||
archive="$work_dir/release.tar.gz"
|
||||
curl -fL --retry 5 --retry-delay 2 --connect-timeout 15 -o "$archive" "$url"
|
||||
asset_name="${url##*/}"
|
||||
if [[ -n "$MONITORING_RELEASE_CACHE_DIR" && -f "$MONITORING_RELEASE_CACHE_DIR/$asset_name" ]]; then
|
||||
cp "$MONITORING_RELEASE_CACHE_DIR/$asset_name" "$archive"
|
||||
else
|
||||
curl -fL --retry 5 --retry-delay 2 --connect-timeout 15 -o "$archive" "$url"
|
||||
fi
|
||||
printf '%s %s\n' "$expected_sha256" "$archive" | sha256sum -c -
|
||||
tar -xzf "$archive" -C "$work_dir"
|
||||
install -o root -g root -m 0755 "$work_dir/$archive_member" "$destination"
|
||||
|
||||
Reference in New Issue
Block a user