diff --git a/terraform/aws-constellation/install-yq.sh b/terraform/aws-constellation/install-yq.sh index 8db13e848d..d37da4625d 100755 --- a/terraform/aws-constellation/install-yq.sh +++ b/terraform/aws-constellation/install-yq.sh @@ -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 diff --git a/terraform/constellation-cluster/install-constellation.sh b/terraform/constellation-cluster/install-constellation.sh index b569d16d6d..fbf5cec961 100755 --- a/terraform/constellation-cluster/install-constellation.sh +++ b/terraform/constellation-cluster/install-constellation.sh @@ -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