1
0
Fork 0

Bash client added

master
Simon Moser vor 3 Jahren
Ursprung 329db1b423
Commit 7fbb57fdde
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 83765B895FF2CFC6

@ -0,0 +1,22 @@
#!/bin/bash
# Simple bash client for linux
if [ "$#" != 3 ] || { [ "$1" != "download" ] && [ "$1" != "upload" ];}
then echo "Usage: $0 [download|upload] FILENAME SERVERNAME"; exit 1; fi
f=$2; s=$3
if [ "$1" = "download" ]
then
c=$(dig +short txt "$f".count."$s"|tr -d \")
for i in $(seq 0 "$c"); do echo -n "$(dig +short txt "$f"."$i"."$s"|tr -d \")"; done | base64 -d > "$f"
else
i=0; d=$(base64 -w 0 < "$f"); id=$(sha256sum "$f" | cut -d" " -f1 | base64 -w 0 | cut -c1-6)
while true; do
u=".$i-${id}u.$s"; ((i++)); x=$((63-${#u}))
if [ $x -lt ${#d} ]
then p=${d:0:$x}; d=${d:$x}; dig +short txt "$p$u"
else dig +short txt "$d$u"; exit 0
fi
done
fi
Laden…
Abbrechen
Speichern