ServerKit is a lightweight, modern server control panel for managing web applications, databases, and services on your VPS or dedicated server. Built with Python/Flask backend and React frontend.
Python astracloudflarecontrol-panelcyberpaneldnsfablehosting-control-panelhosting-panelkimi-k3server-managementserverkitubuntu-web-panelwebserver
fix(favicon): persist the per-install tint + apply it on update too
Juan Denis56c1ab6a27da
diff --git a/install.sh b/install.shindex 41f5b788..8a8a1607 100644--- a/install.sh+++ b/install.sh@@ -1120,19 +1120,29 @@ EOFrandomize_favicon() {local fav="$INSTALL_DIR/frontend/dist/favicon.svg"[ -f "$fav" ] || return 0- local hues=(210 225 235 250 265 285 320 345 12 25 160 175 190)- local base="${hues[$RANDOM % ${#hues[@]}]}"- local jitter=$(( RANDOM % 21 - 10 )) # -10..+10 degrees- local h=$(( (base + jitter + 360) % 360 ))- local s=$(( 48 + RANDOM % 28 )) # 48-75% saturation- local l=$(( 32 + RANDOM % 15 )) # 32-46% lightness (dark enough for the glyph)- if sed -i -E "s|(<rect width=\"32\" height=\"32\" rx=\"7\" fill=\")[^\"]+(\")|\1hsl(${h}, ${s}%, ${l}%)\2|" "$fav" 2>/dev/null; then- good "Favicon tint set to hsl(${h}, ${s}%, ${l}%)"- fi- # Also serve the tinted mark at /favicon.ico so a blind favicon-hash fetch- # there varies per install too, instead of a fixed cross-install icon. It's- # SVG bytes under an .ico name — browsers use the linked SVG anyway; this is- # only about what a scanner hashes at that URL.+ # Assign the color ONCE and persist it in $CONFIG_DIR (survives updates), so+ # `serverkit update` re-applies the SAME color instead of repainting the box+ # on every update — a car keeps its paint. Existing installs get a color on+ # their first update. See scripts/update.sh for the matching re-apply.+ local color_file="$CONFIG_DIR/favicon-color"+ local hsl=""+ [ -s "$color_file" ] && hsl="$(cat "$color_file" 2>/dev/null)"+ if [ -z "$hsl" ]; then+ local hues=(210 225 235 250 265 285 320 345 12 25 160 175 190)+ local base="${hues[$RANDOM % ${#hues[@]}]}"+ local jitter=$(( RANDOM % 21 - 10 )) # -10..+10 degrees+ local h=$(( (base + jitter + 360) % 360 ))+ local s=$(( 48 + RANDOM % 28 )) # 48-75% saturation+ local l=$(( 32 + RANDOM % 15 )) # 32-46% lightness (dark enough for the glyph)+ hsl="hsl(${h}, ${s}%, ${l}%)"+ mkdir -p "$CONFIG_DIR" 2>/dev/null || true+ printf '%s\n' "$hsl" > "$color_file" 2>/dev/null || true+ good "Favicon tint assigned: ${hsl}"+ fi+ sed -i -E "s|(<rect width=\"32\" height=\"32\" rx=\"7\" fill=\")[^\"]+(\")|\1${hsl}\2|" "$fav" 2>/dev/null || true+ # Serve the same tinted mark at /favicon.ico so a blind favicon-hash fetch+ # there varies per install too (SVG bytes under an .ico name — browsers use+ # the linked SVG; this only affects what a scanner hashes at that URL).cp "$fav" "$INSTALL_DIR/frontend/dist/favicon.ico" 2>/dev/null || true}diff --git a/scripts/update.sh b/scripts/update.shindex c3e7caca..c68aa227 100644--- a/scripts/update.sh+++ b/scripts/update.sh@@ -866,6 +866,35 @@ build_frontend_bundle() {NODE_OPTIONS="--max-old-space-size=1024" npm run build 2>&1 | tail -5 )}+# Re-apply this install's PERSISTENT favicon tint to the staged dist. The color+# is assigned once (on first install/update) and stored in /etc/serverkit so the+# mark keeps the same per-install color across updates instead of repainting —+# and an install that predates the feature picks one up on its first update.+# Mirror of install.sh randomize_favicon (kept standalone; the two installers+# already keep separate build fns). Also serves it at /favicon.ico so a blind+# favicon-hash fetch varies too.+apply_favicon_tint() {+ local root="$1"+ local fav="$root/frontend/dist/favicon.svg"+ [ -f "$fav" ] || return 0+ local color_file="/etc/serverkit/favicon-color"+ local hsl=""+ [ -s "$color_file" ] && hsl="$(cat "$color_file" 2>/dev/null)"+ if [ -z "$hsl" ]; then+ local hues=(210 225 235 250 265 285 320 345 12 25 160 175 190)+ local base="${hues[$RANDOM % ${#hues[@]}]}"+ local jitter=$(( RANDOM % 21 - 10 ))+ local h=$(( (base + jitter + 360) % 360 ))+ local s=$(( 48 + RANDOM % 28 ))+ local l=$(( 32 + RANDOM % 15 ))+ hsl="hsl(${h}, ${s}%, ${l}%)"+ mkdir -p /etc/serverkit 2>/dev/null || true+ printf '%s\n' "$hsl" > "$color_file" 2>/dev/null || true+ fi+ sed -i -E "s|(<rect width=\"32\" height=\"32\" rx=\"7\" fill=\")[^\"]+(\")|\1${hsl}\2|" "$fav" 2>/dev/null || true+ cp "$fav" "$root/frontend/dist/favicon.ico" 2>/dev/null || true+}+# A plugin carried forward from the old install can be incompatible with the# new tree (imports that no longer resolve) and sink the whole bundle build.# Rather than blocking the update, move the carried frontends aside so the@@ -1681,6 +1710,10 @@ if [ ! -d "$NEXT_DIR/frontend/dist" ]; thenfifi+# Re-apply the persistent per-install favicon tint to the staged dist (whether+# just rebuilt above or shipped prebuilt), so the color carries across updates.+[ "$DRY_RUN" = "0" ] && apply_favicon_tint "$NEXT_DIR"+# Refresh nginx/systemd configs in the active tree before switch.refresh_config "$NEXT_DIR"