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

Improve install script #264

Merged
merged 17 commits into from
Jan 15, 2019
Merged

Conversation

aparkerlue
Copy link
Contributor

Problem Statement

Install script is (1) difficult to read, (2) does not print critical information about what it is doing, (3) silently modifies ~/.bash_profile, and (4) writes files to multiple locations in the filesystem, a change that is difficult to revert unless there is a corresponding uninstallation mechanism.

Solution

  1. Update the install script to make it easier to read using here documents
  2. Print information about what it is doing
  3. Print advice about how to modify ~/.bash_profile and how to proceed post-installation
  4. Write all files to ~/.okta so that uninstalling only involves removing that directory

@aparkerlue
Copy link
Contributor Author

This is how ~/.okta might look after installing using these changes and then authenticating:

$ tree -a ~/.okta/
~/.okta/
├── .current-session
├── bash_functions
├── bin
│   ├── okta-credential_process
│   ├── okta-listroles
│   └── withokta
├── config.properties
├── cookies.properties
├── fish_functions
│   ├── okta-aws.fish
│   └── okta-sls.fish
├── logging.properties
├── okta-aws-cli-1.0.7.jar
├── okta-aws-cli.jar -> okta-aws-cli-1.0.7.jar
└── profiles

2 directories, 13 files

Copy link
Contributor

@AlainODea AlainODea left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like these changes. There's one minor bug that needs to be fixed and I'll approve and merge this.

bin/install.sh Outdated Show resolved Hide resolved
@aparkerlue
Copy link
Contributor Author

I'm about to commit a couple additional edits. I'll follow up.

@aparkerlue
Copy link
Contributor Author

Usage examples:

Invocation without arguments

$ ./install.sh 
usage: install.sh [-h | -i]
       install Okta AWS CLI Assume Role tool

Help

$ ./install.sh -h
Installation script for Okta AWS CLI Assume Role
================================================

To execute:

    install.sh -i

This command

1. Installs files into a filesystem location that can be configured
   with the PREFIX environment variable (default: ~/.okta) and
2. Prints instructions for setting up shell functions and scripts.

This script checks for (and installs if necessary) the file
~/.okta/config.properties regardless of the value of PREFIX.

For details, see https://github.com/oktadeveloper/okta-aws-cli-assume-role.

Installation into default location

$ ./install.sh -i
Installing into ~/.okta
Latest release JAR file: https://github.com/oktadeveloper/okta-aws-cli-assume-role/releases/download/v1.0.7/okta-aws-cli-1.0.7.jar
Fetching JAR file → ~/.okta/okta-aws-cli-1.0.7.jar
Symlinking ~/.okta/okta-aws-cli.jar → okta-aws-cli-1.0.7.jar
Found ~/.okta/config.properties

Add the following to ~/.bash_profile or ~/.profile:

#OktaAWSCLI
if [[ -f "$HOME/.okta/bash_functions" ]]; then
    . "$HOME/.okta/bash_functions"
fi
if [[ -d "$HOME/.okta/bin" && ":$PATH:" != *":$HOME/.okta/bin:"* ]]; then
    PATH="$HOME/.okta/bin:$PATH"
fi

Installation into custom location

$ PREFIX=tmp ./install.sh -i
Installing into ~/tmp
Latest release JAR file: https://github.com/oktadeveloper/okta-aws-cli-assume-role/releases/download/v1.0.7/okta-aws-cli-1.0.7.jar
Fetching JAR file → ~/tmp/okta-aws-cli-1.0.7.jar
Symlinking ~/tmp/okta-aws-cli.jar → okta-aws-cli-1.0.7.jar
Found ~/.okta/config.properties

Add the following to ~/.bash_profile or ~/.profile:

#OktaAWSCLI
if [[ -f "$HOME/tmp/bash_functions" ]]; then
    . "$HOME/tmp/bash_functions"
fi
if [[ -d "$HOME/tmp/bin" && ":$PATH:" != *":$HOME/tmp/bin:"* ]]; then
    PATH="$HOME/tmp/bin:$PATH"
fi

@aparkerlue
Copy link
Contributor Author

I modified the installation script to require -i to initiate the installation, so the invocation now looks like this:

bash <(curl -fsSL https://raw.githubusercontent.com/oktadeveloper/okta-aws-cli-assume-role/master/bin/install.sh) -i

It would be best to use a raw Github user content URL for the latest release.

@AlainODea
Copy link
Contributor

@aparkerlue thank you for your contribution. I have reviewed it and tested it. It is a big improvement in code and UX and it works.

@AlainODea AlainODea merged commit 8b0bb9d into oktadev:master Jan 15, 2019
@aparkerlue aparkerlue deleted the improve-install-script branch January 15, 2019 19:05
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

Successfully merging this pull request may close these issues.

None yet

2 participants