#!/bin/bash
set -e
-for f in $(find . -type f -not -name "*hashes*" | grep -v "put\|/\.\|^\.$\|/$")
+files=$(find . -type f -not -iwholename "*.git*" -not -name "README.md" -not -name "put.bash" -not -name "hashes.txt")
+user=ftp@martlubbers.net:$(pass ftp.martlubbers.net/ftp@martlubbers.net)
+
+for f in $files
do
- dir=$(dirname $f)
- if [ "$(md5sum $f | awk '{print $1}')" = "$(grep $(basename $f) $dir/hashes.txt | awk '{print $1}')" ]
+ origmd5=$(grep "$f" ./hashes.txt | awk '{print $1}')
+ currmd5=$(md5sum "$f" | awk '{print $1}')
+ if [ "$origmd5" = "$currmd5" ]
then
- echo "$f didn't change..."
+ echo "$f is not changed"
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
+ echo "$f is changed"
+ curl -u "$user" -T $f ftp://martlubbers.net/public_html/$f
fi
done
-echo "recalculating hashes"
-md5sum ./* > hashes.txt
-cd files
-md5sum ./* > hashes.txt
-cd ..
+md5sum ./*{,/*} > ./hashes.txt || true