aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
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