tbitreich-paste - scripts - random scripts
HTML git clone https://git.parazyd.org/scripts
DIR Log
DIR Files
DIR Refs
---
tbitreich-paste (596B)
---
1 #!/bin/sh
2
3 DST="parazyd@bitreich.org"
4 DSTDIR="/bitreich/gopher/paste"
5
6 if [ -z "$DST" ];
7 then
8 printf "You forgot to set DST in %s. Please do so.\n" \
9 "$(basename "$0")" >&2
10 exit 1
11 fi
12
13 if [ $# -gt 0 ];
14 then
15 file="$@"
16 else
17 file=
18 fi
19
20 cd $HOME/tmp
21 tmpfile="$(mktemp p-XXXXXXXXXXXXX.txt)"
22 if [ -z "$file" ];
23 then
24 cat > $tmpfile
25 else
26 cat "$file" > $tmpfile
27 fi
28
29 [ $(stat -c %s $tmpfile) -eq 0 ] && exit 1
30
31 tar cf - $tmpfile | ssh ${DST} "cd $DSTDIR; tar xf -; chmod g+rw $tmpfile"
32 name="$(basename $tmpfile)"
33 echo "gopher://bitreich.org/0/p/$name" | xclip
34 echo "gopher://bitreich.org/0/p/$name"