utils/src/pasta

39 lines
751 B
Plaintext
Raw Normal View History

2020-11-20 07:36:48 +00:00
#!/usr/bin/env sh
#
# pasta: simple ssh-based paste bin (client)
2020-11-20 07:36:48 +00:00
# author: Hiltjo Posthuma <hiltjo@codemass.org>, Dylan Lom <djl@dylanlom.com>
# see-also: https://codemadness.org/paste-service.html
sshdomain="djl@p.dlom.cc"
destpath="/usr/local/www/p.dlom.cc"
destdomain="http://p.dlom.cc"
2020-11-20 07:36:48 +00:00
argv0="$0"
usage() {
echo "usage: $argv0 [-p | -c] filename"
2020-11-20 07:36:48 +00:00
exit 1
}
while [ "$#" -gt 1 ]; do
case "$1" in
'-p') png='true'; ;;
'-c') concat='true'; ;;
*) usage ;;
esac
shift
done
name="$1"
[ -z "$name" ] && usage
if truthy "$concat"; then
ssh "$sshdomain" "cat >> $destpath/$name"
else
(truthy "$png" && import png:- || cat) | \
ssh "$sshdomain" "cat > $destpath/$name"
fi
echo "$destdomain/$name"
2020-11-20 07:36:48 +00:00