#!/bin/sh # Serve data from stdin on $HOST over http. # Inspired by https://codemadness.org/paste-service.html if [ -t 0 ] && [ $# -ne 1 ] then printf 'usage: %s [filetype]\n' "${0##*/}" exit 1 fi HOST='thyssentishman.com' DIR="/var/www/htdocs/${HOST}/paste" URL="https://www.${HOST}/paste" rname() { tr -dc '[:alnum:]' < /dev/urandom | fold -w 5 | head -n1 } push() { ssh "$HOST" "cat > \"${DIR}/${1}\"" && printf '%s/%s\n' "$URL" "$1" } push "$(rname).${1:-txt}"