added sha1 sums
This commit is contained in:
parent
11bd1c8269
commit
2decbf015c
@ -22,6 +22,8 @@ if ! [ -x "$(command -v strings)" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
declare -A SHASUMS
|
||||||
|
|
||||||
echo "===== ===== ===== GENERATE .ZSYNC ===== ===== ====="
|
echo "===== ===== ===== GENERATE .ZSYNC ===== ===== ====="
|
||||||
FILELIST=$(find . -type f ! -path "*/.sync*" ! -path "*.zsync")
|
FILELIST=$(find . -type f ! -path "*/.sync*" ! -path "*.zsync")
|
||||||
while IFS= read -r line; do
|
while IFS= read -r line; do
|
||||||
@ -60,10 +62,12 @@ while IFS= read -r line; do
|
|||||||
echo "Nothing changed for $line"
|
echo "Nothing changed for $line"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
SHA=$(strings "${zsyncfile}" | grep -m 1 SHA-1 | cut -d" " -f2)
|
||||||
|
SHASUMS[$(echo "${line}" | sed 's|^./||')]="${SHA}"
|
||||||
|
|
||||||
done <<< "$FILELIST"
|
done <<< "$FILELIST"
|
||||||
echo -e "===== ===== ===== ===== ===== =====\n"
|
echo -e "===== ===== ===== ===== ===== =====\n"
|
||||||
|
|
||||||
|
|
||||||
echo "===== ===== ===== DELETE SINGLE ZFILE WITHOUT FILE ===== ===== ====="
|
echo "===== ===== ===== DELETE SINGLE ZFILE WITHOUT FILE ===== ===== ====="
|
||||||
ZSYNCLIST=$(find . -name "*.zsync")
|
ZSYNCLIST=$(find . -name "*.zsync")
|
||||||
while IFS= read -r zfile; do
|
while IFS= read -r zfile; do
|
||||||
@ -90,14 +94,14 @@ while IFS= read -r folder; do
|
|||||||
filebyte=$(wc -c < "${folderfile}")
|
filebyte=$(wc -c < "${folderfile}")
|
||||||
foldersize=$(expr $foldersize + $filebyte)
|
foldersize=$(expr $foldersize + $filebyte)
|
||||||
name=$(echo "${folderfile}" | cut -d"/" -f2-)
|
name=$(echo "${folderfile}" | cut -d"/" -f2-)
|
||||||
x="\"${name}\":${filebyte},${x}"
|
x="\"${name}\":{\"size\": ${filebyte}, \"sha1\": \"${SHASUMS[$folderfile]}\"},${x}"
|
||||||
done <<< "$FILEFOLDER"
|
done <<< "$FILEFOLDER"
|
||||||
x=$(echo ${x} | rev | cut -c2- | rev)
|
x=$(echo ${x} | rev | cut -c2- | rev)
|
||||||
JSONDATA+=( "\"${folder}\": {\"size\":${foldersize},\"content\":{${x}}}" )
|
JSONDATA+=( "\"${folder}\": {\"size\":${foldersize},\"content\":{${x}}}" )
|
||||||
else
|
else
|
||||||
echo "is file"
|
echo "is file"
|
||||||
filebyte=$(wc -c < "${folder}")
|
filebyte=$(wc -c < "${folder}")
|
||||||
JSONDATA+=( "\"${folder}\": {\"size\":${filebyte}}" )
|
JSONDATA+=( "\"${folder}\": {\"size\":${filebyte}, \"sha1\": \"${SHASUMS[$folder]}\"}" )
|
||||||
fi
|
fi
|
||||||
done <<< "$FILELIST"
|
done <<< "$FILELIST"
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user