Skip to content

Commit

Permalink
nicely format install sh
Browse files Browse the repository at this point in the history
  • Loading branch information
elchead committed Nov 2, 2023
1 parent 61103dd commit a03abaa
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 43 deletions.
38 changes: 19 additions & 19 deletions terraform/aws-constellation/install-yq.sh
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
#!/usr/bin/env bash
VERSION="v4.35.2"
if [ -f ./yq ] && echo $(./yq --version) | grep -q "$VERSION"; then
echo "yq is already installed and up to date."
if [ -f ./yq ] && ./yq --version | grep -q "${VERSION}"; then
echo "yq is already available and up to date."
exit 0
fi
if [ -f ./yq ]; then
echo "yq is already installed but not at the required version. Replacing with $VERSION."
echo "yq is already available but not at the required version. Replacing with ${VERSION}."
rm -f yq
fi

echo "Installing yq $VERSION"
echo "Fetching yq ${VERSION}"
OS=$(uname -s)
ARCH=$(uname -m)
URL=""

if [ "$OS" == "Darwin" ]; then
if [ "$ARCH" == "arm64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/$VERSION/yq_darwin_arm64"
elif [ "$ARCH" == "x86_64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/$VERSION/yq_darwin_amd64"
if [ "${OS}" == "Darwin" ]; then
if [ "${ARCH}" == "arm64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_darwin_arm64"
elif [ "${ARCH}" == "x86_64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_darwin_amd64"
fi
elif [ "$OS" == "Linux" ]; then
if [ "$ARCH" == "x86_64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/$VERSION/yq_linux_amd64"
elif [ "$ARCH" == "arm64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/$VERSION/yq_linux_arm64"
elif [ "${OS}" == "Linux" ]; then
if [ "${ARCH}" == "x86_64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_amd64"
elif [ "${ARCH}" == "arm64" ]; then
URL="https://github.com/mikefarah/yq/releases/download/${VERSION}/yq_linux_arm64"
fi
fi

if [ -z "$URL" ]; then
echo "OS \"$OS\" and/or architecture \"$ARCH\" is not supported."
if [ -z "${URL}" ]; then
echo "OS \"${OS}\" and/or architecture \"${ARCH}\" is not supported."
exit 1
else
echo "Downloading yq from $URL"
curl -o yq -L $URL
echo "Downloading yq from ${URL}"
curl -o yq -L "${URL}"
chmod +x ./yq
./yq --version
if ! echo $(./yq --version) | grep -q "$VERSION"; then # check that yq was installed correctly
if ! ./yq --version | grep -q "${VERSION}"; then # check that yq was installed correctly
echo "Version is incorrect"
exit 1
fi
Expand Down
52 changes: 28 additions & 24 deletions terraform/constellation-cluster/install-constellation.sh
Original file line number Diff line number Diff line change
@@ -1,29 +1,33 @@
#!/usr/bin/env bash
if ! [ -f ./constellation ]; then
OS=$(uname -s)
ARCH=$(uname -m)
VERSION="latest"
URL=""
if [ -f ./constellation ]; then
echo "constellation CLI is already available."
exit 0
fi

if [ $OS == "Darwin" ]; then
if [ $ARCH == "arm64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-darwin-arm64"
elif [ $ARCH == "x86_64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-darwin-amd64"
fi
elif [ $OS == "Linux" ]; then
if [ $ARCH == "x86_64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-linux-amd64"
elif [ $ARCH == "arm64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-linux-arm64"
fi
fi
echo "Fetching constellation ${VERSION}"
OS=$(uname -s)
ARCH=$(uname -m)
VERSION="latest"
URL=""

if [ -z "$URL" ]; then
echo "OS \"$OS\" and/or architecture \"$ARCH\" is not supported."
exit 1
else
curl -o constellation -L $URL
chmod +x constellation
if [ "${OS}" == "Darwin" ]; then
if [ "${ARCH}" == "arm64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-darwin-arm64"
elif [ "${ARCH}" == "x86_64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-darwin-amd64"
fi
elif [ "${OS}" == "Linux" ]; then
if [ "${ARCH}" == "x86_64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-linux-amd64"
elif [ "${ARCH}" == "arm64" ]; then
URL="https://github.com/edgelesssys/constellation/releases/${VERSION}/download/constellation-linux-arm64"
fi
fi

if [ -z "${URL}" ]; then
echo "OS \"${OS}\" and/or architecture \"${ARCH}\" is not supported."
exit 1
else
curl -o constellation -L "${URL}"
chmod +x constellation
fi

0 comments on commit a03abaa

Please sign in to comment.