Skip to content

Commit

Permalink
check file integrity after download (#210)
Browse files Browse the repository at this point in the history
  • Loading branch information
hobbyquaker committed May 14, 2019
1 parent 4dde8f1 commit ec93a2c
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion addon_files/redmatic/bin/redmatic-pkg
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,20 @@ function install()

echo "Get $URL"
set -o pipefail
/usr/bin/curl $URL -o $ADDON_DIR/tmp/$1.tar.gz --fail --silent --show-error --location || exit 1
T_START=$(date +"%s")
/usr/bin/curl $URL -o $ADDON_DIR/tmp/$1.tar.gz --fail --show-error --silent --location || exit 1
T_END=$(date +"%s")
echo "Downloaded $(stat -c %s $ADDON_DIR/tmp/$1.tar.gz | awk '{ suffix="KMGT"; for(i=0; $1>1024 && i < length(suffix); i++) $1/=1024; print int($1) substr(suffix, i, 1), $3; }')in $(( T_END-T_START )) seconds"

D_INTEGRITY=sha512-$(cat $ADDON_DIR/tmp/$1.tar.gz | /usr/bin/openssl sha512 -binary | base64 | tr -d \\n)

if [ "$INTEGRITY" == "$D_INTEGRITY" ]; then
echo "File integrity check successful"
else
echo "File integrity check failed"
rm $ADDON_DIR/tmp/$1.tar.gz
exit 1
fi

rm -r $ADDON_DIR/lib/node_modules/$PACKAGE 2> /dev/null

Expand Down

0 comments on commit ec93a2c

Please sign in to comment.