Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions scripts/install_sh/install.sh.txt
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
(@ load("@ytt:data", "data") @)
(@ load("helpers.star", "addProtocol") @)

#!/bin/bash
#!/bin/sh
## **This is an autogenerated file, do not change it manually**

if test -z "$BASH_VERSION"; then
echo "Please run this script using bash, not sh or any other shell." >&2
exit 1
fi

install() {
set -euo pipefail

Expand All @@ -20,9 +15,17 @@ install() {
dl_bin="curl -s -L"
fi

shasum -v 1>/dev/null 2>&1 || (echo "Missing shasum binary" && exit 1)
if command -v sha256sum >/dev/null; then
SHASUM_CMD="sha256sum"
elif command -v sha1sum >/dev/null; then
SHASUM_CMD="sha1sum"
else
echo "Missing sha256sum or sha1sum binary" >&2
exit 1
fi


if [[ `uname` == Darwin ]]; then
if [ "$(uname)" = "Darwin" ]; then
binary_type=darwin-amd64
(@ for val in data.values.products: @)(@ for asset in val.assets: @)(@ if asset.os == "darwin" and asset.arch=="amd64": @)
(@=val.product @)_checksum=(@=asset.shasum @)(@ end @)(@ end @)(@ end @)
Expand All @@ -37,7 +40,7 @@ install() {
(@ for val in data.values.products: @)
echo "Installing (@= val.product @)..."
$dl_bin (@= addProtocol(val.github.url) @)/releases/download/(@= val.version @)/(@= val.product @)-${binary_type} > /tmp/(@= val.product @)
echo "${(@= val.product @)_checksum} /tmp/(@= val.product @)" | shasum -c -
echo "${(@= val.product @)_checksum} /tmp/(@= val.product @)" | $SHASUM_CMD -c -
mv /tmp/(@= val.product @) ${dst_dir}/(@= val.product @)
chmod +x ${dst_dir}/(@= val.product @)
echo "Installed ${dst_dir}/(@= val.product @) (@= val.version @)"
Expand Down