diff --git a/install-guard.sh b/install-guard.sh index 50751ae4..9c53f888 100644 --- a/install-guard.sh +++ b/install-guard.sh @@ -27,11 +27,16 @@ main() { mkdir -p ~/.guard/"$MAJOR_VER" ~/.guard/bin || err "unable to make directories ~/.guard/$MAJOR_VER, ~/.guard/bin" get_os_type - download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/"$VERSION"/cfn-guard-v"$MAJOR_VER"-"$ARCH_TYPE"-"$OS_TYPE"-latest.tar.gz >/tmp/guard.tar.gz || - err "unable to download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/$VERSION/cfn-guard-v$MAJOR_VER-$ARCH_TYPE-$OS_TYPE-latest.tar.gz" + if [ "$MAJOR_VER" -le 2 ] || [ "$VERSION" = "3.0.0" ]; then + FILENAME="cfn-guard-v$MAJOR_VER-$OS_TYPE-latest" + else + FILENAME="cfn-guard-v$MAJOR_VER-$ARCH_TYPE-$OS_TYPE-latest" + fi + download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/"$VERSION/$FILENAME".tar.gz >/tmp/guard.tar.gz || + err "unable to download https://github.com/aws-cloudformation/cloudformation-guard/releases/download/$VERSION/$FILENAME.tar.gz" tar -C ~/.guard/"$MAJOR_VER" -xzf /tmp/guard.tar.gz || err "unable to untar /tmp/guard.tar.gz" - ln -sf ~/.guard/"$MAJOR_VER"/cfn-guard-v"$MAJOR_VER"-"$ARCH_TYPE"-"$OS_TYPE"-latest/cfn-guard ~/.guard/bin || + ln -sf ~/.guard/"$MAJOR_VER/$FILENAME"/cfn-guard ~/.guard/bin || err "unable to symlink to ~/.guard/bin directory" ~/.guard/bin/cfn-guard help || err "cfn-guard was not installed properly"