diff options
| author | St33v <github@f3rr3t.com> | 2026-01-30 18:16:03 +1100 |
|---|---|---|
| committer | St33v <github@f3rr3t.com> | 2026-01-30 18:16:03 +1100 |
| commit | 70f2fc45af8a0ea98e0e6f7b4254928dc7bfe317 (patch) | |
| tree | 1e28e8e75053e9bdcde02dce1ae63da39147400f /forge/script | |
| parent | 8f4de5585ddb57331056ead793548cf22a9f685b (diff) | |
systemd paths (build works, publish might)
Diffstat (limited to 'forge/script')
| -rwxr-xr-x | forge/script/build-sotd.sh (renamed from forge/script/sotd-build.sh) | 14 | ||||
| -rw-r--r-- | forge/script/incantations | 16 | ||||
| -rwxr-xr-x | forge/script/publish-sotd.sh | 42 | ||||
| -rw-r--r-- | forge/script/sotd-build.service | 2 | ||||
| -rw-r--r-- | forge/script/sotd-publish.path | 9 | ||||
| -rw-r--r-- | forge/script/sotd-publish.service | 8 |
6 files changed, 84 insertions, 7 deletions
diff --git a/forge/script/sotd-build.sh b/forge/script/build-sotd.sh index 78d6a55..8412f84 100755 --- a/forge/script/sotd-build.sh +++ b/forge/script/build-sotd.sh @@ -24,13 +24,15 @@ template_file="$TPL/release.template" # --- derive variables ----------------------------------------------------- slugify() { - echo "$1" \ + local s="$1" + local ascii + + # Try to transliterate to ASCII; if it fails, keep original + ascii="$(printf '%s' "$s" | iconv -f UTF-8 -t ASCII//TRANSLIT 2>/dev/null || printf '%s' "$s")" + + printf '%s' "$ascii" \ | tr '[:upper:]' '[:lower:]' \ - | sed -E ' - s/[^a-z0-9]+/-/g; - s/^-+//; - s/-+$// - ' + | sed -E 's/[^a-z0-9]+//g' } #--------------------------------------------------------------------------- diff --git a/forge/script/incantations b/forge/script/incantations new file mode 100644 index 0000000..677b3e9 --- /dev/null +++ b/forge/script/incantations @@ -0,0 +1,16 @@ +rsync -av --delete .faircamp_build/ st33v.com:/srv/www/st33v.com/sotd + + + + +systemctl --user daemon-reload +systemctl --user enable --now sotd-build.path sotd-publish.path + + +systemctl --user status sotd-build.path sotd-publish.path + + +journalctl --user -u sotd-build.service -f +# and/or +journalctl --user -u sotd-publish.service -f +:wq diff --git a/forge/script/publish-sotd.sh b/forge/script/publish-sotd.sh new file mode 100755 index 0000000..09248b4 --- /dev/null +++ b/forge/script/publish-sotd.sh @@ -0,0 +1,42 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT="$HOME/dox/st33v.com" +OUT="$ROOT/forge/out" +SOTD="$ROOT/sotd" + +log() { printf '[sotd-publish] %s\n' "$*" >&2; } +die() { log "$*"; exit 1; } + +publish_marker="$OUT/PUBLISH" +[[ -f "$publish_marker" ]] || die "No publish marker: $publish_marker" + +# mkdir -p "$SOTD" + +# Find candidate release directories in OUT (ignore marker files) +release_dirs=() +for d in "$OUT"/*; do + [[ -d "$d" ]] || continue + release_dirs+=( "$d" ) +done + +[[ ${#release_dirs[@]} -eq 1 ]] || die "Expected exactly 1 release dir in $OUT, found ${#release_dirs[@]}" + +rel="${release_dirs[0]}" + +[[ -f "$rel/release.eno" ]] || die "Missing release.eno in $(basename "$rel")" + +shopt -s nullglob +wav_files=( "$rel"/*.wav ) +shopt -u nullglob +(( ${#wav_files[@]} > 0 )) || die "Missing .wav in $(basename "$rel")" + +dest="$SOTD/$(basename "$rel")" +[[ ! -e "$dest" ]] || die "Destination already exists: $dest" + +mv "$rel" "$dest" +log "Published: $dest" + +# Cleanup markers after successful publish +rm -f "$OUT/PUBLISH" "$OUT/BUILT" + diff --git a/forge/script/sotd-build.service b/forge/script/sotd-build.service index 44019ca..9591396 100644 --- a/forge/script/sotd-build.service +++ b/forge/script/sotd-build.service @@ -3,6 +3,6 @@ Description=SOTD forge build (forge/in -> forge/out) [Service] Type=oneshot -ExecStart=/usr/local/bin/sotd-build +ExecStart=/usr/local/bin/build-sotd.sh WorkingDirectory=%h/dox/st33v.com diff --git a/forge/script/sotd-publish.path b/forge/script/sotd-publish.path new file mode 100644 index 0000000..1b295d0 --- /dev/null +++ b/forge/script/sotd-publish.path @@ -0,0 +1,9 @@ +[Unit] +Description=Publish SOTD when forge/out/PUBLISH appears + +[Path] +PathExists=%h/dox/st33v.com/forge/out/PUBLISH + +[Install] +WantedBy=default.target + diff --git a/forge/script/sotd-publish.service b/forge/script/sotd-publish.service new file mode 100644 index 0000000..f96d761 --- /dev/null +++ b/forge/script/sotd-publish.service @@ -0,0 +1,8 @@ +[Unit] +Description=SOTD publish release folder/s (forge/out/ -> sotd/) + +[Service] +Type=oneshot +ExecStart=%h/bin/sotd-forge-publish.sh +WorkingDirectory=%h/dox/st33v.com + |
