Add pasta

Gitignore a.out, dist/usr/
This commit is contained in:
Dylan Lom 2020-11-20 18:36:48 +11:00
parent f9906870aa
commit c819f5107f
3 changed files with 34 additions and 1 deletions

2
.gitignore vendored
View File

@ -1 +1,3 @@
*.deb
a.out
dist/usr

View File

@ -1,10 +1,13 @@
all: djl-utils.deb
dist: sign suptime timestamp
dist: sign pasta suptime timestamp
sign: src/sign
cp src/sign dist/usr/bin
pasta: src/pasta
cp src/pasta dist/usr/bin
suptime: src/suptime.c
cc -o dist/usr/bin/suptime src/suptime.c

28
src/pasta Executable file
View File

@ -0,0 +1,28 @@
#!/usr/bin/env sh
#
# pasta: simple ssh-based paste bin
# author: Hiltjo Posthuma <hiltjo@codemass.org>, Dylan Lom <djl@dylanlom.com>
# see-also: https://codemadness.org/paste-service.html
argv0="$0"
usage() {
echo "usage: $argv0 [-p] filename"
exit 1
}
pasta() {
ssh djl@p.dlom.cc "cat > /usr/local/www/p.dlom.cc/$1"
echo "http://p.dlom.cc/$1"
}
[ "$#" -lt 1 ] && usage
png="$([ "$1" = '-p' ] && echo 'true')"
[ ! -z "$png" ] && shift
title="$1"
[ -z "$title" ] && usage
([ ! -z "$png" ] && import png:- || cat) | pasta "$title"