#!/bin/sh set -eu repodir="$HOME/Private/repos/THESIAH" out="$repodir/public/diary/index.html" server="${THESIAH_SERVER:-root@thesiah.xyz}" dest="/var/www/thesiah/diary/" defaults="sy after foramonth" src="$repodir/public/diary/" bgm="$repodir/static/bgm/" bgmd="/var/www/thesiah/bgm/" cd "$repodir" hugo --cleanDestinationDir if [ ! -f "$out" ]; then echo "error: not found: $out" >&2 exit 1 fi ssh "$server" "mkdir -p '$dest'" rsync -azv --update --itemize-changes --stats "$bgm" "$server:$bgmd" 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/diary/$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