diff options
| author | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
|---|---|---|
| committer | TheSiahxyz <164138827+TheSiahxyz@users.noreply.github.com> | 2025-12-24 13:54:03 +0900 |
| commit | 28e8bdf7f8286bd431b7f3b709e79f3827b31469 (patch) | |
| tree | 85b44eff6da4d8443198fb6e04dfb6ee55244588 /debian/.local/bin/hugow | |
| parent | 8470ff001befcfd0f626dea69a9e76d43aee0511 (diff) | |
updates
Diffstat (limited to 'debian/.local/bin/hugow')
| -rwxr-xr-x | debian/.local/bin/hugow | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/debian/.local/bin/hugow b/debian/.local/bin/hugow new file mode 100755 index 0000000..0460174 --- /dev/null +++ b/debian/.local/bin/hugow @@ -0,0 +1,70 @@ +#!/bin/sh +set -eu + +repodir="$HOME/Private/repos/THESIAH" +out="$repodir/public/recordings/index.html" +server="${THESIAH_SERVER:-root@thesiah.xyz}" +dest="/var/www/thesiah/recordings/" +defaults="sy after foramonth" +src="$repodir/public/recordings/" + +cd "$repodir" +hugo --cleanDestinationDir + +if [ ! -f "$out" ]; then + echo "error: not found: $out" >&2 + exit 1 +fi + +tmp="$(mktemp "$out.XXXXXXXX.tmp")" + +awk -v defaults="$defaults" ' +BEGIN { + n = split(defaults, a, /[[:space:]]+/) + insert = "" + for (i = 1; i <= n; i++) { + if (a[i] == "") continue + name = a[i] ".mp4" + insert = insert \ +" <li>\n" \ +" <a href=\"/recordings/" name "\" data-name=\"" name "\" class=\"vid\">" name "</a>\n" \ +" </li>\n" + } + injected = 0 +} +{ + print + if (!injected && $0 ~ /<ul[^>]*id=["'\''"]list["'\''"][^>]*>/) { + printf("%s", insert) + injected = 1 + } +} +END { if (!injected) exit 2 } +' "$out" >"$tmp" + +mv "$tmp" "$out" +echo "Injected defaults into: $out" + +ssh "$server" "mkdir -p '$dest'" + +if [ -n "${THESIAH_SSH_OPTS:-}" ]; then + rsync -azv --update --itemize-changes --stats \ + -e "ssh $THESIAH_SSH_OPTS" \ + "$src" "$server:$dest" +else + rsync -azv --update --itemize-changes --stats \ + "$src" "$server:$dest" +fi + +if [ -n "${1-}" ]; then + new="$repodir/content/recordings/$1" + if [ -f "$new" ]; then + rsync -az --update "$new" "$server:$dest" + elif [ -d "$new" ]; then + rsync -az --update "$new/" "$server:$dest$(basename "$new")/" + fi +fi + +ssh "$THESIAH_SERVER" "chmod 644 $dest/index.html" + +cd - >/dev/null |
