Files
geointel/deploy/refresh-unraid-icon.sh
T
Jens d5ea270329
GeoIntel release gates / Compile, test, contracts and builds (push) Canceled after 0s
GeoIntel release gates / Python and npm vulnerability policy (push) Canceled after 0s
GeoIntel release gates / GIS image, SBOM and container scan (push) Canceled after 0s
Update GeoIntel project files
2026-07-25 23:43:08 +02:00

49 lines
1.4 KiB
Bash
Executable File

#!/bin/sh
set -eu
container_name="${1:-DockDeck}"
icon_url="${2:-}"
template_path="/boot/config/plugins/dockerMan/templates-user/my-${container_name}.xml"
persistent_dir="/var/lib/docker/unraid/images"
runtime_dir="/usr/local/emhttp/state/plugins/dynamix.docker.manager/images"
fail() {
printf 'DockDeck icon refresh failed: %s\n' "$1" >&2
exit 1
}
[ "$(id -u)" -eq 0 ] || fail "run this helper as root on the Unraid host"
case "$container_name" in
"" | *[!A-Za-z0-9_.-]*) fail "invalid container name" ;;
esac
if [ -z "$icon_url" ] && [ -f "$template_path" ]; then
icon_url="$(sed -n 's#.*<Icon>\(.*\)</Icon>.*#\1#p' "$template_path" | head -n 1)"
fi
case "$icon_url" in
http://* | https://*) ;;
*) fail "provide an HTTP(S) icon URL or a user template containing <Icon>" ;;
esac
temporary_icon="$(mktemp /tmp/dockdeck-icon.XXXXXX)"
trap 'rm -f "$temporary_icon"' EXIT HUP INT TERM
curl --fail --silent --show-error --location \
--connect-timeout 5 --max-time 20 \
"$icon_url" --output "$temporary_icon"
[ "$(file -b --mime-type "$temporary_icon")" = "image/png" ] || \
fail "the downloaded asset is not a real PNG"
mkdir -p "$persistent_dir" "$runtime_dir"
install -m 0644 -o root -g root \
"$temporary_icon" "$persistent_dir/${container_name}-icon.png"
install -m 0644 -o root -g root \
"$temporary_icon" "$runtime_dir/${container_name}-icon.png"
printf 'Refreshed both Unraid icon caches for %s from %s\n' \
"$container_name" "$icon_url"