~kris/dots

srice

ref: e9b48d06a8541f3eda5c4db90382ab3c77183afb srice/.local/bin/srht-deploy -rwxr-xr-x 674 bytes
e9b48d06 — Kris Yotam xprofile: systemd-aware pipewire start + blueman-applet; sb-internet: tolerate missing /proc/net/wireless 2 months ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/bin/sh
# srht-deploy -- deploy a directory to sr.ht pages
set -eu

if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
    echo "Usage: srht-deploy <domain> <directory>" >&2
    exit 1
fi

DOMAIN="$1"
DIR="$2"

if [ ! -d "$DIR" ]; then
    echo "Not a directory: $DIR" >&2
    exit 1
fi

TMPFILE=$(mktemp /tmp/srht-deploy-XXXXXX.tar.gz)
trap 'rm -f "$TMPFILE"' EXIT

tar -C "$DIR" -czf "$TMPFILE" .

if command -v hut >/dev/null 2>&1; then
    hut pages publish -d "$DOMAIN" "$TMPFILE"
else
    TOKEN=$(cat ~/.config/srht/token)
    curl -s --oauth2-bearer "$TOKEN" \
      -F "content=@$TMPFILE" \
      "https://pages.sr.ht/publish/$DOMAIN"
fi

echo "[+] Published to $DOMAIN"