smart upload with hash check
authorMart Lubbers <mart@martlubbers.net>
Tue, 8 Jul 2014 08:33:48 +0000 (10:33 +0200)
committerMart Lubbers <mart@martlubbers.net>
Tue, 8 Jul 2014 08:33:48 +0000 (10:33 +0200)
files/hashes.txt [new file with mode: 0644]
hashes.txt [new file with mode: 0644]
index.html
put.bash

diff --git a/files/hashes.txt b/files/hashes.txt
new file mode 100644 (file)
index 0000000..9f4ee44
--- /dev/null
@@ -0,0 +1,2 @@
+dd13e096acf6b9b95cace6943fe56577  dvorak-0.74.map
+85f82d281bc3d4e48e375193fdaada66  dvorak_dos.tar
diff --git a/hashes.txt b/hashes.txt
new file mode 100644 (file)
index 0000000..8672aa0
--- /dev/null
@@ -0,0 +1,15 @@
+d6e0677c490230e96f24cdbd1c300a77  ./dvorak.html
+9fc9c704c41b3347e05b00c603955fe7  ./hashes.txt
+5b69e6c9c8ed13cca3206cc6ad2652dd  ./index.html
+72ac29b74f3e09c551aa10a2a8d2581d  ./lejos-ubuntu.html
+0ba6cb2c3a9d7d8ba27406d215aa501e  ./mart@martlubbers.net.asc
+146f1bb6bed2adfd4d13f9644390db71  ./nsa-dropbox.html
+75068866762dc200d6e185bfe9b3a2bf  ./o.html
+ce31052406b3874b287e98c8a9477516  ./p.jpg
+95b2932b7da95664dcef20097b1b58df  ./put.bash
+43eb61826bc538817b4c78c7f8d57019  ./README.md
+4be5b32df3dedb74eeb758b233864fe6  ./robots.txt
+5caad6ee7880531cf07efc21591c0ec0  ./style.css
+d69f225d06c3d7a417fb5e8159efc2d1  ./test.php
+2ed34aa229468632cce58151c33d1ebc  ./wlan-debian.html
+d07dca8f45b3f046558216cf3ac96c28  ./youtube-term.html
index 105d3e1..095c75e 100644 (file)
@@ -22,6 +22,7 @@
                                        GPG ID: <a href="http://martlubbers.net/mart@martlubbers.net.asc">AD3FEBE7</a><br />
                                        Fingerprint: 74FF FBF1 4758 273B 2F56  A30C A937 B7A1 AD3F EBE7<br />
                                        <a href="http://www.linkedin.com/pub/mart-lubbers/1b/76a/763">LinkedIn</a><br />
+                                       <a href="https://github.com/dopefishh">Github</a><br />
                                </td>
                        </tr>
                </table>
index 46ca44b..cd0b8fd 100644 (file)
--- a/put.bash
+++ b/put.bash
@@ -1,6 +1,18 @@
 #!/bin/bash
 set -e
-for f in $(find . -type f | grep -v "put\|/\.\|^\.$\|/$")
+for f in $(find . -type f -not -name "*hashes*" | grep -v "put\|/\.\|^\.$\|/$")
 do
-       curl -u $(gpg --use-agent -d ~/passwd.gpg | grep ftp-user | awk '{print $2":"$3}') -T $f ftp://martlubbers.net/public_html/$f
+       dir=$(dirname $f)
+       if [ "$(md5sum $f | awk '{print $1}')" = "$(grep $(basename $f) $dir/hashes.txt | awk '{print $1}')" ]
+       then
+               echo "$f didn't change..."
+       else
+               echo "$f did change..."
+               curl -u $(gpg --use-agent -d ~/passwd.gpg | grep ftp-user | awk '{print $2":"$3}') -T $f ftp://martlubbers.net/public_html/$f
+       fi
 done
+echo "recalculating hashes"
+md5sum ./* > hashes.txt
+cd files
+md5sum ./* > hashes.txt
+cd ..