From 4015bd2214c111f807e6f7002322a999a2df2ad4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tiago=20Concei=C3=A7=C3=A3o?= Date: Sun, 30 Oct 2022 16:10:59 +0000 Subject: Update install-uvtools.sh --- Scripts/install-uvtools.sh | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/Scripts/install-uvtools.sh b/Scripts/install-uvtools.sh index ffef783..dfe23c5 100644 --- a/Scripts/install-uvtools.sh +++ b/Scripts/install-uvtools.sh @@ -16,6 +16,17 @@ macOS_least_version=10.15 version() { echo "$@" | awk -F. '{ printf("%d%03d%03d%03d\n", $1,$2,$3,$4); }'; } testcmd() { command -v "$1" &> /dev/null; } +get_filesize() { + ( + du --apparent-size --block-size=1 "$1" 2>/dev/null || + gdu --apparent-size --block-size=1 "$1" 2>/dev/null || + find "$1" -printf "%s" 2>/dev/null || + gfind "$1" -printf "%s" 2>/dev/null || + stat --printf="%s" "$1" 2>/dev/null || + stat -f%z "$1" 2>/dev/null || + wc -c <"$1" 2>/dev/null + ) | awk '{print $1}' +} downloaduvtools(){ if [ -z "$1" ]; then echo "Download url was not specified" @@ -28,6 +39,16 @@ downloaduvtools(){ echo "Downloading: $download_url" curl -L --retry 4 $download_url -o "$tmpfile" + if [ -n "$2" ]; then + echo "- Validating file" + size="$(get_filesize "$tmpfile")" + if [ "$2" -ne "$size" ]; then + echo "Error: File verification failed, expecting $2 bytes but downloaded $size bytes. Please re-run the script." + rm -f "$tmpfile" + exit -1 + fi + fi + echo "- Kill instances" killall UVtools 2> /dev/null ps -ef | grep '.*dotnet.*UVtools.dll' | grep -v grep | awk '{print $2}' | xargs kill 2> /dev/null @@ -90,7 +111,7 @@ if [ "${OSTYPE:0:6}" == "darwin" ]; then echo "- Removing old versions" rm -rf "$appPath" - echo "- Inflating $tmpfile to $appPath" + echo "- Inflating $filename to $appPath" unzip -q -o "$tmpfile" -d "/Applications" rm -f "$tmpfile" -- cgit v1.2.3