add pasting script
This commit is contained in:
parent
f5558d49d9
commit
3a868c0a94
2
Makefile
2
Makefile
|
@ -5,3 +5,5 @@ install:
|
|||
chmod +x $(PREFIX)$(DESTDIR)/gitman
|
||||
cp -f paste/paste.py $(PREFIX)$(DESTDIR)/paste
|
||||
chmod +x $(PREFIX)$(DESTDIR)/paste
|
||||
cp -f pb/pb.sh $(PREFIX)$(DESTDIR)/pb
|
||||
chmod +x $(PREFIX)$(DESTDIR)/pb
|
||||
|
|
|
@ -10,3 +10,6 @@ chmod +x $(PREFIX)$(DESTDIR)/gitman
|
|||
|
||||
cp -f paste/paste.py $(PREFIX)$(DESTDIR)/phman
|
||||
chmod +x $(PREFIX)$(DESTDIR)/paste
|
||||
|
||||
cp -f pb/pb.sh $(PREFIX)$(DESTDIR)/pb
|
||||
chmod +x $(PREFIX)$(DESTDIR)/pb
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/sh
|
||||
|
||||
# hello there
|
||||
|
||||
# this is a program for the gopher pastebin service, hosted
|
||||
# at beepboop.systems. simply run this command with your
|
||||
# filename as your argument and you'll get a link.
|
||||
|
||||
# should you wish to use a different instance you can specify
|
||||
# one in the second argument.
|
||||
|
||||
# error codes:
|
||||
# exit 1: specify filename
|
||||
# exit 2: there's no gopherpaste service here
|
||||
# exit 3: there was an error posting some of the data
|
||||
# exit 4: error writing final to document
|
||||
|
||||
# this software is (c) randomuser 2021
|
||||
# licenced under the GNU AGPL 3
|
||||
|
||||
INSTANCE="beepboop.systems"
|
||||
|
||||
[ -f $1 ] || exit 1
|
||||
[ -z $2 ] || INTSTANCE=${2}
|
||||
|
||||
# check if the instance exists
|
||||
data=$(curl --silent gopher://${INSTANCE}/0/cgi-bin/dig/active)
|
||||
[ ${data} = "ACTIVE" ] || exit 2
|
||||
|
||||
# get the id for the paste
|
||||
id=$(curl --silent gopher://${INSTANCE}/0/cgi-bin/dig/getid)
|
||||
|
||||
# paste it
|
||||
IFS="
|
||||
"
|
||||
for i in $(base64 ${1} | tr -d ' ' | tr -d '\n' | fold -w 20); do
|
||||
data=$(curl --silent gopher://${INSTANCE}/0/cgi-bin/dig/post?"${id} ${i}")
|
||||
[ ${data} = "APPENDED" ] || exit 3
|
||||
done
|
||||
|
||||
data=$(curl --silent gopher://${INSTANCE}/0/cgi-bin/dig/finish?"${id}")
|
||||
[ ${data} = "FINISHED" ] || exit 4
|
||||
|
||||
|
||||
printf "gopher://%s/0/cgi-bin/dig/get?%s\n" ${INSTANCE} ${id}
|
||||
exit 0
|
Loading…
Reference in New Issue