feat: Dynamic page content (#585)

This commit is contained in:
Kroese
2024-01-21 18:35:55 +01:00
committed by GitHub
parent 2c7cea042f
commit 1e13258bc9
10 changed files with 311 additions and 75 deletions

View File

@@ -174,8 +174,8 @@ fi
rm -rf "$TMP" && mkdir -p "$TMP"
MSG="Downloading $BASE.pat..."
info "Install: $MSG" && html "$MSG"
info "Install: Downloading $BASE.pat..."
html "Install: Downloading DSM from Synology..."
PAT="/$BASE.pat"
rm -f "$PAT"

View File

@@ -254,8 +254,8 @@ if [[ "$DHCP" == [Yy1]* ]]; then
# Configuration for DHCP IP
configureDHCP
MSG="Please wait while discovering IP..."
html "$MSG" "2000"
MSG="Booting DSM instance..."
html "$MSG"
else

View File

@@ -7,6 +7,7 @@ info () { printf "%b%s%b" "\E[1;34m \E[1;36m" "$1" "\E[0m\n" >&2; }
error () { printf "%b%s%b" "\E[1;31m " "ERROR: $1" "\E[0m\n" >&2; }
file="/run/shm/dsm.url"
info="/run/shm/msg.html"
page="/run/shm/index.html"
address="/run/shm/qemu.ip"
shutdown="/run/shm/qemu.end"
@@ -80,6 +81,7 @@ if [[ "$location" != "20.20"* ]]; then
HTML="${HTML/\[5\]/}"
echo "$HTML" > "$page"
echo "$body" > "$info"
else

View File

@@ -29,6 +29,7 @@ echo
# Helper variables
STORAGE="/storage"
INFO="/dev/shm/msg.html"
PAGE="/run/shm/index.html"
TEMPLATE="/var/www/index.html"
FOOTER1="$APP for Docker v$(</run/version)"
@@ -118,6 +119,7 @@ html()
{
local title
local body
local script
local footer
title=$(escape "$APP")
@@ -129,10 +131,7 @@ html()
body="<p class=\"loading\">${body/.../}</p>"
fi
local timeout="4999"
[ -n "${2:-}" ] && timeout="$2"
local script="<script>setTimeout(() => { document.location.reload(); }, $timeout);</script>"
[[ "$timeout" == "0" ]] && script=""
[ -n "${2:-}" ] && script="$2" || script=""
local HTML
HTML=$(<"$TEMPLATE")
@@ -143,6 +142,7 @@ html()
HTML="${HTML/\[5\]/$FOOTER2}"
echo "$HTML" > "$PAGE"
echo "$body" > "$INFO"
return 0
}