Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Input when uninstalling the old version #50

Closed
otherpirate opened this issue Jul 1, 2020 · 4 comments
Closed

Input when uninstalling the old version #50

otherpirate opened this issue Jul 1, 2020 · 4 comments

Comments

@otherpirate
Copy link

We are having trouble when installing AWS CLI v2

There is a shell input to replace aws/README.md, I'm not sure about what it is but started to happen 4 days ago

Full log:

AWS_VER_REGEXP_2='aws-cli\/2.\d*.\d*'
AWS_VER_REGEXP_1='aws-cli\/1.\d*.\d*'
# initialize installed version to zero, to signify not installed (Or we want to ignore the installed version and re-install).
AWS_CLI_INSTALLED_VERSION="0"
AWS_CLI_VERSION_SELECTED="2"

if [[ $EUID == 0 ]]; then export SUDO=""; else export SUDO="sudo"; fi

if "false" == "false"; then
    if ! command -v aws --version >/dev/null 2>&1  ; then
        echo AWS is not installed
    else
        echo AWS is currently installed.
        if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
            echo AWS CLI v2 is installed
            AWS_CLI_INSTALLED_VERSION="2"
        fi
        if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_1; then
            echo AWS CLI v1 is installed
            AWS_CLI_INSTALLED_VERSION="1"
        fi
    fi
else
    echo "Skipping version check. Installing CLI"
fi

AWS_V2_UPDATE_PARAM=""
if aws --version 2>&1 | grep -q $AWS_VER_REGEXP_2; then
    AWS_V2_UPDATE_PARAM="--update"
fi

#If the desired version of the CLI is not installed, install it.
if [[ $AWS_CLI_VERSION_SELECTED != $AWS_CLI_INSTALLED_VERSION ]]; then

    #uninstall AWS CLI if it is installed.
    if which aws; then
        echo Uninstalling old CLI
        $SUDO rm -rf $(which aws)
    fi
    case $AWS_CLI_VERSION_SELECTED in
        "1")
            if ! command -v python >/dev/null 2>&1 && ! command -v python3 >/dev/null 2>&1 ; then
                echo "Your environment does not seem to have Python installed, a requirement of the AWS CLI."
                echo "Please either utilize the AWS CLI v2, or select an envionment with Python installed."
                echo "Recommended image: cimg:/python:3.8"
                exit 1
            fi
            # install CLI v1
            export PIP=$(which pip pip3 | head -1)
            if [[ -n $PIP ]]; then
                if which sudo > /dev/null; then
                    sudo $PIP install awscli --upgrade
                else
                    # This installs the AWS CLI to ~/.local/bin. Make sure that ~/.local/bin is in your $PATH.
                    $PIP install awscli --upgrade --user
                fi
            elif [[ $(which unzip curl | wc -l) -eq 2 ]]; then
                cd
                curl "https://s3.amazonaws.com/aws-cli/awscli-bundle.zip" -o "awscli-bundle.zip"
                unzip awscli-bundle.zip
                if which sudo > /dev/null; then
                    sudo ~/awscli-bundle/install -i /usr/local/aws -b /usr/local/bin/aws
                else
                    # This installs the AWS CLI to the default location (~/.local/lib/aws) and create a symbolic link (symlink) at ~/bin/aws. Make sure that ~/bin is in your $PATH.
                    awscli-bundle/install -b ~/bin/aws
                fi
                rm -rf awscli-bundle*
                cd -
            else
                echo "Unable to install AWS CLI. Please install pip."
                exit 1
            fi
            # Installation check
            if aws --version &> grep -q "aws-cli/1"; then
                echo "AWS CLI V1 has been installed successfully"
                exit 0
            else
                echo "There was an issue installing the AWS CLI V1. Exiting."
                exit 1
            fi
        ;;
        "2")
            # install CLI v2

            cd /tmp || exit

            # PLATFORM CHECK: mac vs. alpine vs. other linux
            if uname -a | grep Darwin; then
                SYS_ENV_PLATFORM=darwin
            elif uname -a | grep Linux; then
                SYS_ENV_PLATFORM=linux
            else
                echo "This platform appears to be unsupported."
                uname -a
                exit 1
            fi

            case $SYS_ENV_PLATFORM in
                linux)
                    curl -sSL "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
                    unzip awscliv2.zip
                    $SUDO ./aws/install $AWS_V2_UPDATE_PARAM
                    rm awscliv2.zip
                    ;;
                darwin)
                    curl -sSL "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
                    $SUDO installer -pkg AWSCLIV2.pkg -target /
                    rm AWSCLIV2.pkg
                    ;;
                *)
                    echo "This orb does not currently support your platform. If you believe it should, please consider opening an issue on the GitHub repository:"
                    echo "https://github.com/CircleCI-Public/aws-cli-orb/issues/new"
                    exit 1
                ;;
            esac
            # Installation check
            if aws --version &> grep -q "aws-cli/2"; then
                echo "AWS CLI V2 has been installed successfully"
                exit 0
            else
                echo "There was an issue installing the AWS CLI V2. Exiting."
                exit 1
            fi
        ;;
    esac

else
    echo "The v${AWS_CLI_VERSION_SELECTED} AWS CLI is already installed."
    exit 0
fi
Skipping version check. Installing CLI
/usr/local/bin/aws
Uninstalling old CLI
Linux 06b4708cfdb0 4.15.0-1067-aws #71-Ubuntu SMP Thu Apr 30 13:51:43 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux
Archive:  awscliv2.zip
replace aws/README.md? [y]es, [n]o, [A]ll, [N]one, [r]ename:  NULL
(EOF or read error, treating as "[N]one" ...)

Exited with code exit status 1
CircleCI received exit code 1```
@deeptianand
Copy link

We are also running into the same issue! Would love to get this fixed.

@kylev
Copy link

kylev commented Jul 2, 2020

Same here. We're using circleci/aws-cli@1 with the cimg/python:3.8 executor.

@lokst
Copy link
Contributor

lokst commented Jul 3, 2020

Could you try using the new orb version 1.2.1 to see if it resolves the issue?

@gmemstr
Copy link
Contributor

gmemstr commented Jul 8, 2020

I believe we can close this issue now, but feel free to reopen if you find this isn't actually resolved for you - given the reactions on @lokst's comment, I'm assuming it's all good :)

@gmemstr gmemstr closed this as completed Jul 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants