-
Notifications
You must be signed in to change notification settings - Fork 1
/
bsbin
executable file
·39 lines (33 loc) · 972 Bytes
/
bsbin
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/sh -e
#
# http://github.com/mitchweaver/bin
#
# pastebin / file upload reppin the bonsai site
#
vps=vps
dir=bonsai-website/www
file="$1"
echo "$1" | grep '\.' >/dev/null && ext=".${1#*.}"
name=$(rgen)
[ -f "$file" ] || exit 1
case "${ext#.}" in
png|jpg|gif|mp4|webm)
cat "$file" >> /tmp/$$.bsix
scp -q /tmp/$$.bsix $vps:$dir/uploads/$name"$ext"
url=http://bonsai-linux.org/uploads
;;
*) # text
echo '<html><head></head><body>' >> /tmp/$$.bsix
echo '<pre style="word-wrap: break-word; white-space: pre-wrap;">' >> /tmp/$$.bsix
cat "$file" >> /tmp/$$.bsix
echo '</pre></body></html>' >> /tmp/$$.bsix
ssh $vps "mkdir -p $dir/pastes/$name$ext"
scp -q /tmp/$$.bsix $vps:$dir/pastes/$name$ext/index.html
url=http://bonsai-linux.org/pastes
esac
set -- "$url/$name$ext"
echo "$1"
for clip in ip ib is ; do
echo "$1" | xsel -$clip
done
rm /tmp/$$.bsix 2>/dev/null ||: