routeros_firmware: Use real tmpfile

This commit is contained in:
Timo Makinen 2025-04-04 16:01:43 +00:00
parent d282b132ab
commit 776b562abe

View file

@ -46,15 +46,16 @@ if [ -z "$checksum" ]; then
fi fi
echo "Downloading new package '${packagename}'" echo "Downloading new package '${packagename}'"
trap 'rm -f -- "${packagename}.tmp"' EXIT tmpfile="$(mktemp -p .)"
curl -sSf -o "${packagename}.tmp" "$packageurl" trap 'rm -f -- "$tmpfile"' EXIT
curl -sSf -o "$tmpfile" "$packageurl"
if [ "$(sha256sum "${packagename}.tmp" | cut -d " " -f 1)" != "$checksum" ]; then if [ "$(sha256sum "$tmpfile" | cut -d " " -f 1)" != "$checksum" ]; then
echo "ERR: Checksum check failed, not saving package" 1>&2 echo "ERR: Checksum check failed, not saving package" 1>&2
exit 1 exit 1
fi fi
mv "${packagename}.tmp" "$packagename" mv "$tmpfile" "$packagename"
echo echo
curl -sSf "https://cdn.mikrotik.com/routeros/$(echo "$packagename" | cut -d "-" -f 2)/CHANGELOG" curl -sSf "https://cdn.mikrotik.com/routeros/$(echo "$packagename" | cut -d "-" -f 2)/CHANGELOG"