diff options
author | EuAndreh <eu@euandre.org> | 2022-06-02 15:02:29 -0300 |
---|---|---|
committer | EuAndreh <eu@euandre.org> | 2022-06-02 15:02:29 -0300 |
commit | 973e50971901c0492c48c13c68aa2266706ab2a7 (patch) | |
tree | b4a427d37ff40d5d2b90a41610a9e71cf48d784b | |
parent | etc/guix/home.scm: Explicitly load srfi-1 instead of inheriting it from curth0 (diff) | |
download | dotfiles-973e50971901c0492c48c13c68aa2266706ab2a7.tar.gz dotfiles-973e50971901c0492c48c13c68aa2266706ab2a7.tar.xz |
bin/tmp: Move from website repository, now pointing to kuvira
-rwxr-xr-x | bin/tmp | 76 |
1 files changed, 76 insertions, 0 deletions
@@ -0,0 +1,76 @@ +#!/bin/sh +set -eu + +usage() { + cat <<-'EOF' + Usage: + tmp FILE... + tmp -d + tmp -h + EOF +} + +help() { + cat <<-'EOF' + + Options: + -d delete the remote "tmp/" folder + -h, --help show this message + EOF +} + +for flag in "$@"; do + case "$flag" in + --) + break + ;; + --help) + usage + help + exit + ;; + *) + ;; + esac +done + +REMOTE='euandreh.xyz' +DIR='/opt/www/euandreh.xyz/static/tmp' +while getopts 'dh' flag; do + case "$flag" in + d) + printf 'Deleting %s:%s...\n' "$REMOTE" "$DIR/" >&2 + ssh "$REMOTE" rm -rf "$DIR" + exit + ;; + h) + usage + help + exit + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) +FILE="${1:-}" + +if [ -z "$FILE" ]; then + printf 'Missing FILE.\n\n' >&2 + usage >&2 + exit 2 +fi + +for f in "$@"; do + FILENAME="$(basename "$f")" + # shellcheck disable=2029 + ssh "$REMOTE" "mkdir -p '$DIR' && cat > '$DIR/$FILENAME'" < "$f" + + LINK="$(printf 'https://%s/tmp/%s' "$REMOTE" "$FILENAME")" + open "$LINK" + if [ $# = 1 ]; then + printf '%s' "$LINK" | copy + printf 'Copied %s to the clipboard!\n' "$LINK" >&2 + fi +done |