2019-02-24 10:07:31 +01:00
|
|
|
#!/bin/bash
|
|
|
|
do_restore() {
|
|
|
|
abfyml=.abf.yml
|
|
|
|
|
|
|
|
local file sha
|
|
|
|
if [ -e "${abfyml}" ]; then
|
|
|
|
echo "parsing file '${abfyml}'"
|
|
|
|
sed -ne '/^[Ss]ources\:.*$/,$p' ${abfyml} | \
|
|
|
|
sed -rn '$G;s/^[\"'\''[:space:]]*([^[:space:]:\"'\'']+)[\"'\''[:space:]]*.*[\"'\''[:space:]]*([0-9a-fA-F]{40})[\"'\''[:space:]]*$/\1 \2/p' | \
|
|
|
|
|
|
|
|
while read -r file sha; do
|
|
|
|
echo -n "found entry: file=${file} ... "
|
|
|
|
if [ -e "${file}" ]; then
|
|
|
|
if echo "${sha} ${file}" | sha1sum -c --status; then
|
|
|
|
echo "sha1sum correct"
|
|
|
|
else
|
|
|
|
echo "sha1sum INCORRECT! skipping..."
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo -n "try to download... "
|
2019-02-24 19:07:02 +03:00
|
|
|
if curl -L "http://file-store.rosalinux.ru/download/${sha}" -o "${file}"; then
|
2019-02-24 10:07:31 +01:00
|
|
|
echo "ok"
|
|
|
|
echo -n "check sum... "
|
|
|
|
if echo "${sha} ${file}" | sha1sum -c --status; then
|
|
|
|
echo "ok"
|
|
|
|
else
|
|
|
|
echo "sha1sum INCORRECT! skipping..."
|
|
|
|
echo "remove file ${file}"
|
|
|
|
rm -f "${file}"
|
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "filed! skipping..."
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
do_restore
|