Created
December 29, 2022 02:01
-
-
Save jmcph4/1d40e497d67c9a62963482c1946de38b to your computer and use it in GitHub Desktop.
Forward notes to a public webserver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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