feat: install script checksum before installing

Signed-off-by: haoadoresorange <github@comtam.dev>
This commit is contained in:
haoadoresorange 2021-11-17 03:59:18 +00:00
parent 4e9128a23f
commit c0cc0ea623

View File

@ -149,6 +149,14 @@ elevate_priv() {
install() {
ext="$1"
archive=$(get_tmpfile "$ext")
# download to the temp file
download "${archive}" "${URL}"
starship_checksum="$HOME"/.starship-checksum
checksum="$(sha256sum "$archive" | awk '{ print $1 }')"
if [[ checksum != "$(cat "$starship_checksum")" ]]; then
if test_writeable "${BIN_DIR}"; then
sudo=""
msg="Installing Starship, please wait…"
@ -160,13 +168,10 @@ install() {
fi
info "$msg"
archive=$(get_tmpfile "$ext")
# download to the temp file
download "${archive}" "${URL}"
# unpack the temp file to the bin dir, using sudo if required
unpack "${archive}" "${BIN_DIR}" "${sudo}"
fi
echo "$checksum" > "$starship_checksum"
}
# Currently supporting: