aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorVG <vg@devys.org>2015-01-28 18:45:29 +0100
committerVG <vg@devys.org>2015-01-28 18:45:29 +0100
commit12240fb74c0c6f2768e1070f849cd265ea3dd181 (patch)
tree6f5cb93e0e020bd918e015aba164e90db1fd0739 /scripts
downloadshareit-12240fb74c0c6f2768e1070f849cd265ea3dd181.tar.gz
shareit-12240fb74c0c6f2768e1070f849cd265ea3dd181.tar.bz2
shareit-12240fb74c0c6f2768e1070f849cd265ea3dd181.zip
First commit
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/shareit28
-rwxr-xr-xscripts/shareit-scrot14
2 files changed, 42 insertions, 0 deletions
diff --git a/scripts/shareit b/scripts/shareit
new file mode 100755
index 0000000..0c30310
--- /dev/null
+++ b/scripts/shareit
@@ -0,0 +1,28 @@
+#!/bin/bash
+
+file="$1"
+tempfile=""
+
+rmtempfile_cb() { rm "$tempfile"; }
+
+if [ "$file" == "" ]; then
+ tempfile="$(mktemp)"
+ trap rmtempfile_cb EXIT
+ cat > $tempfile
+ file=$tempfile
+fi
+
+if [ ! -e ~/.certs/org.devys.shareit.crt ]; then
+ mkdir -p ~/.certs/
+ gnutls-cli -p 443 shareit.devys.org --print-cert </dev/null | \
+ sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' > \
+ ~/.certs/org.devys.shareit.crt || exit 1
+fi
+
+file="${file/\\/\\\\}"
+file="${file/\"/\\\"}"
+
+curl --cacert ~/.certs/org.devys.shareit.crt \
+ --netrc --form upload=@"\"$file\"" \
+ https://shareit.devys.org/upload/ | \
+ sed -n 's/^.*<a href="\([^"]\+\)".*$/\1/p' | head -n 1
diff --git a/scripts/shareit-scrot b/scripts/shareit-scrot
new file mode 100755
index 0000000..9588de6
--- /dev/null
+++ b/scripts/shareit-scrot
@@ -0,0 +1,14 @@
+#!/bin/bash
+set -e
+
+file=
+
+cleanup_cb() { [ -n "$file" ] && rm $file; }
+
+trap cleanup_cb EXIT
+
+file=$(mktemp --suffix=.png)
+
+scrot -s $file
+
+shareit $file