Skip to content

Instantly share code, notes, and snippets.

@jmcph4
Created December 29, 2022 02:01
Show Gist options
  • Save jmcph4/1d40e497d67c9a62963482c1946de38b to your computer and use it in GitHub Desktop.
Save jmcph4/1d40e497d67c9a62963482c1946de38b to your computer and use it in GitHub Desktop.
Forward notes to a public webserver
#!/bin/bash
SSH_KEY=~/.ssh/id_ed25519
REMOTE_HOST=example.com
REMOTE_PATH=data
MAX_DIGEST_LEN=7
# usage
if [ "$#" -ne 1 ]; then
echo "[publish] usage: publish file"
exit
fi
FILEPATH=$1
TAG=$(sha512sum "$FILEPATH" | head -c "$MAX_DIGEST_LEN")
scp -i "$SSH_KEY" "$FILEPATH" "$REMOTE_HOST":"$REMOTE_PATH"/"$TAG"".html"
PUBLIC_URL="https://notes.""$REMOTE_HOST"/"$TAG"".html"
echo "$PUBLIC_URL"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment