aesthetic terminal experience
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

48 lines
1.2 KiB

3 years ago
#!/bin/sh
# Bare Metal Alchemist, 2022
#############################################
# Tin - ♃ #
#############################################
# Tin is frequently combined with lead to form solder, which is an
# important component of wiring up hardware.
# This ingredient is to be used when you're interacting with physical
# hardware like GPIO pins or USB drives
sha256_check() {
# Args: <sha256_hash> <filename>
#
if check_for sha256sum; then
3 years ago
echo "${1} ${2}" | sha256sum -c
elif check_for sha256; then
3 years ago
if [ "$(uname)" = "FreeBSD" ]; then
sha256 -c "${1}" "${2}"
else
echo "${1} ${2}" | sha256 -c
fi
else
echo "${1} ${2}" | shasum -a 256 -c
fi
}
http_get() {
# Args: <url> <filename> <sha256_hash>
#
# It's acceptable that we don't require SSL here because we manually verify
# content hashes below.
#
if [ -f "${2}" ]; then
echo "File ${2} already exists; not downloading again"
elif check_for curl; then
3 years ago
curl --insecure --retry 5 "${1}" -o "${2}"
else
wget --no-check-certificate "${1}" -O "${2}"
fi
sha256_check "${3}" "${2}"
}
3 years ago
TIN=1