diff --git a/README.md b/README.md index e174e88..87419b6 100644 --- a/README.md +++ b/README.md @@ -14,7 +14,7 @@ gruntwork-install --module-name 'vault-ssh-helper' --tag '0.0.3' ## Installing gruntwork-install ```bash -curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version 0.0.5 +curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version 0.0.6 ``` Notice the `--version` parameter at the end where you specify which version of `gruntwork-install` to install. See the @@ -77,7 +77,7 @@ and then uses it to install several modules: }], "provisioners": [{ "type": "shell", - "inline": "curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version 0.0.5" + "inline": "curl -Ls https://raw.githubusercontent.com/gruntwork-io/gruntwork-installer/master/bootstrap-gruntwork-installer.sh | bash /dev/stdin --version 0.0.6" },{ "type": "shell", "inline": [ diff --git a/bootstrap-gruntwork-installer.sh b/bootstrap-gruntwork-installer.sh index 2cf95b3..ce813ab 100755 --- a/bootstrap-gruntwork-installer.sh +++ b/bootstrap-gruntwork-installer.sh @@ -19,6 +19,7 @@ set -e readonly BIN_DIR="/usr/local/bin" +readonly USER_DATA_DIR="/etc/user-data" readonly DEFAULT_FETCH_VERSION="v0.0.3" readonly FETCH_DOWNLOAD_URL_BASE="https://github.com/gruntwork-io/fetch/releases/download" @@ -38,6 +39,7 @@ function print_usage { echo echo -e " --version\t\tRequired. The version of $GRUNTWORK_INSTALLER_SCRIPT_NAME to install (e.g. 0.0.3)." echo -e " --fetch-version\tOptional. The version of fetch to install. Default: $DEFAULT_FETCH_VERSION." + echo -e " --user-data-owner\tOptional. The user who shown own the $USER_DATA_DIR folder. Default: (current user)." echo echo "Examples:" echo @@ -150,9 +152,31 @@ function assert_not_empty { fi } +function create_user_data_folder { + local readonly user_data_folder="$1" + local readonly user_data_folder_owner="$2" + local readonly user_data_folder_readme="$user_data_folder/README.txt" + + echo "Creating $user_data_folder as a place to store scripts intended to be run in the User Data of an EC2 instance during boot" + sudo mkdir -p "$user_data_folder" + +sudo tee "$user_data_folder_readme" > /dev/null < 0 ]]; do local key="$1" @@ -166,6 +190,10 @@ function bootstrap { fetch_version="$2" shift ;; + --user-data-owner) + user_data_folder_owner="$2" + shift + ;; --help) print_usage exit @@ -182,10 +210,12 @@ function bootstrap { assert_not_empty "--version" "$installer_version" assert_not_empty "--fetch-version" "$fetch_version" + assert_not_empty "--user-data-owner" "$user_data_folder_owner" echo "Installing $GRUNTWORK_INSTALLER_SCRIPT_NAME..." install_fetch "$FETCH_INSTALL_PATH" "$fetch_version" install_gruntwork_installer "$GRUNTWORK_INSTALLER_INSTALL_PATH" "$installer_version" + create_user_data_folder "$USER_DATA_DIR" "$user_data_folder_owner" echo "Success!" }