2022-07-10 18:44:30 -04:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
##@Version : 202207101834-git
|
|
|
|
# @Author : Jason Hempstead
|
|
|
|
# @Contact : jason@casjaysdev.com
|
|
|
|
# @License : LICENSE.md
|
|
|
|
# @ReadME : get-deno.sh --help
|
|
|
|
# @Copyright : Copyright: (c) 2022 Jason Hempstead, Casjays Developments
|
|
|
|
# @Created : Sunday, Jul 10, 2022 18:34 EDT
|
|
|
|
# @File : get-deno.sh
|
|
|
|
# @Description : Download binaries for amd64 and arm64
|
|
|
|
# @TODO :
|
|
|
|
# @Other :
|
|
|
|
# @Resource :
|
|
|
|
# @sudo/root : no
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-10-11 16:07:58 -04:00
|
|
|
# Set bash options
|
|
|
|
[ -n "$DEBUG" ] && set -x
|
2022-10-12 17:25:02 -04:00
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-10-12 17:48:30 -04:00
|
|
|
__get_file() {
|
2022-10-12 18:42:53 -04:00
|
|
|
local exitStatus=""
|
2022-10-12 19:12:10 -04:00
|
|
|
if curl -q -LSf "$URL" -o "$FILE"; then
|
2022-10-12 18:42:53 -04:00
|
|
|
exitStatus=0
|
2022-10-12 19:12:10 -04:00
|
|
|
elif curl -q -LSf "$LATEST_URL" -o "$FILE"; then
|
2022-10-12 18:31:11 -04:00
|
|
|
URL="$LATEST_URL"
|
2022-10-12 18:42:53 -04:00
|
|
|
exitStatus=0
|
2022-10-12 17:48:30 -04:00
|
|
|
else
|
2022-10-12 18:42:53 -04:00
|
|
|
exitStatus=1
|
2022-10-12 17:48:30 -04:00
|
|
|
fi
|
2022-10-12 18:42:53 -04:00
|
|
|
return ${exitStatus}
|
2022-10-12 17:48:30 -04:00
|
|
|
}
|
2022-10-11 16:07:58 -04:00
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-10-12 18:59:38 -04:00
|
|
|
DENO_VERSION="${DENO_VERSION:-v1.26.1}"
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-07-10 18:44:30 -04:00
|
|
|
if [ "$(uname -m)" = "amd64" ] || [ "$(uname -m)" = "x86_64" ]; then
|
2022-10-12 18:59:38 -04:00
|
|
|
ARCH="x86_64"
|
2022-10-12 19:12:10 -04:00
|
|
|
BIN_FILE="/usr/bin/deno"
|
2022-10-12 17:48:30 -04:00
|
|
|
FILE="/tmp/deno-$ARCH.zip"
|
2022-10-12 19:12:10 -04:00
|
|
|
TMP_DIR="/tmp/deno-$ARCH/deno"
|
2022-10-12 18:59:38 -04:00
|
|
|
DENO_VERSION="${DENO_VERSION:-latest}"
|
|
|
|
URL="https://github.com/denoland/deno/releases/download/$DENO_VERSION/deno-$ARCH-unknown-linux-gnu.zip"
|
|
|
|
LATEST_URL="https://github.com/denoland/deno/releases/download/latest/deno-$ARCH-unknown-linux-gnu.zip"
|
|
|
|
elif [ "$(uname -m)" = "arm64" ] || [ "$(uname -m)" = "aarch64" ]; then
|
|
|
|
ARCH="arm64"
|
2022-10-12 19:12:10 -04:00
|
|
|
BIN_FILE="/usr/bin/deno"
|
2022-10-12 18:59:38 -04:00
|
|
|
FILE="/tmp/deno-$ARCH.zip"
|
|
|
|
DENO_VERSION="${DENO_VERSION:-latest}"
|
|
|
|
URL="https://github.com/LukeChannings/deno-arm64/releases/download/$DENO_VERSION/deno-linux-$ARCH.zip"
|
|
|
|
LATEST_URL="https://github.com/LukeChannings/deno-arm64/releases/latest/download/deno-linux-$ARCH.zip"
|
|
|
|
else
|
|
|
|
echo "Unsupported architecture"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
# AMD64 binary
|
|
|
|
if [ "$ARCH" = "x86_64" ]; then
|
2022-10-12 19:12:10 -04:00
|
|
|
echo "grabbing ${DENO_VERSION} from denoland for $ARCH"
|
|
|
|
__get_file && if [ -f "$FILE" ]; then
|
|
|
|
mkdir -p "$TMP_DIR" && cd "$TMP_DIR" || exit 10
|
|
|
|
unzip "$FILE"
|
|
|
|
mv -fv "$TMP_DIR" "$BIN_FILE"
|
|
|
|
chmod -Rf 755 "$BIN_FILE"
|
|
|
|
rm -Rf "$FILE" "$TMP_DIR"
|
2022-10-12 17:48:30 -04:00
|
|
|
fi
|
2022-10-12 18:36:54 -04:00
|
|
|
else
|
|
|
|
echo "Failed to download deno from $URL"
|
|
|
|
exit 2
|
|
|
|
fi
|
2022-07-10 18:44:30 -04:00
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
|
|
# ARM64 binary
|
2022-10-12 18:59:38 -04:00
|
|
|
if [ "$ARCH" = "arm64" ]; then
|
2022-10-12 19:12:10 -04:00
|
|
|
echo "grabbing ${DENO_VERSION} from LukeChannings for $ARCH"
|
|
|
|
__get_file && if [ -f "$FILE" ]; then
|
|
|
|
mkdir -p "$TMP_DIR" && cd "$TMP_DIR" || exit 10
|
|
|
|
unzip "$FILE"
|
|
|
|
mv -fv "$TMP_DIR" "$BIN_FILE"
|
|
|
|
chmod -Rf 755 "$BIN_FILE"
|
|
|
|
rm -Rf "$FILE" "$TMP_DIR"
|
2022-10-12 18:36:54 -04:00
|
|
|
fi
|
|
|
|
else
|
|
|
|
echo "Failed to download deno from $URL"
|
|
|
|
exit 2
|
2022-07-10 18:44:30 -04:00
|
|
|
fi
|
2022-10-12 18:59:38 -04:00
|
|
|
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
2022-10-12 17:25:02 -04:00
|
|
|
[ -f "$(which "deno")" ] && deno upgrade && exit 0 || exit 10
|