From de8a66848d3f836d0d62949ee7ed544cdf77037c Mon Sep 17 00:00:00 2001 From: Drew Hubl Date: Thu, 14 Jun 2018 16:51:11 -0700 Subject: [PATCH 1/6] Fix configuration directory and file permissions --- scripts/includes/common.sh | 26 +++++++------------------- scripts/st2bootstrap-deb.sh | 26 +++++++------------------- scripts/st2bootstrap-el6.sh | 26 +++++++------------------- scripts/st2bootstrap-el7.sh | 26 +++++++------------------- 4 files changed, 28 insertions(+), 76 deletions(-) diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index 2279e54e..61c6a6f1 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -181,15 +181,9 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - if ! sudo test -d ${ROOT_USER_CLI_CONFIG_DIRECTORY}; then - sudo mkdir -p ${ROOT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${ROOT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -197,18 +191,12 @@ EOT" fi # Write config for current user (in case current user != root) - if [ ! -d ${CURRENT_USER_CLI_CONFIG_DIRECTORY} ]; then - sudo mkdir -p ${CURRENT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${CURRENT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Fix the permissions - sudo chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} + chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index ebdd561e..86a09329 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -298,15 +298,9 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - if ! sudo test -d ${ROOT_USER_CLI_CONFIG_DIRECTORY}; then - sudo mkdir -p ${ROOT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${ROOT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -314,18 +308,12 @@ EOT" fi # Write config for current user (in case current user != root) - if [ ! -d ${CURRENT_USER_CLI_CONFIG_DIRECTORY} ]; then - sudo mkdir -p ${CURRENT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${CURRENT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Fix the permissions - sudo chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} + chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-el6.sh b/scripts/st2bootstrap-el6.sh index dcde3d49..ee768909 100644 --- a/scripts/st2bootstrap-el6.sh +++ b/scripts/st2bootstrap-el6.sh @@ -293,15 +293,9 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - if ! sudo test -d ${ROOT_USER_CLI_CONFIG_DIRECTORY}; then - sudo mkdir -p ${ROOT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${ROOT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -309,18 +303,12 @@ EOT" fi # Write config for current user (in case current user != root) - if [ ! -d ${CURRENT_USER_CLI_CONFIG_DIRECTORY} ]; then - sudo mkdir -p ${CURRENT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${CURRENT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Fix the permissions - sudo chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} + chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index 07eb2715..2e5d36c4 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -293,15 +293,9 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - if ! sudo test -d ${ROOT_USER_CLI_CONFIG_DIRECTORY}; then - sudo mkdir -p ${ROOT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${ROOT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -309,18 +303,12 @@ EOT" fi # Write config for current user (in case current user != root) - if [ ! -d ${CURRENT_USER_CLI_CONFIG_DIRECTORY} ]; then - sudo mkdir -p ${CURRENT_USER_CLI_CONFIG_DIRECTORY} - fi - - sudo sh -c "cat < ${CURRENT_USER_CLI_CONFIG_PATH} -[credentials] -username = ${USERNAME} -password = ${PASSWORD} -EOT" + st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + --write-password \ + --username ${USERNAME} --password ${PASSWORD} # Fix the permissions - sudo chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} + chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } From 2c2cad3959d467a1d4072d813e9c00bf21b3fd3b Mon Sep 17 00:00:00 2001 From: Drew Hubl Date: Thu, 21 Jun 2018 13:16:33 -0700 Subject: [PATCH 2/6] Don't redundantly chown the configuration file, and move the --config-file option to st2 instead of the login subcommand --- scripts/includes/common.sh | 8 ++++---- scripts/st2bootstrap-deb.sh | 8 ++++---- scripts/st2bootstrap-el6.sh | 8 ++++---- scripts/st2bootstrap-el7.sh | 8 ++++---- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index 61c6a6f1..c9b2c548 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -181,8 +181,8 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - --write-password \ + sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Write config for root user @@ -191,8 +191,8 @@ configure_st2_cli_config() { fi # Write config for current user (in case current user != root) - st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - --write-password \ + st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Fix the permissions diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index 86a09329..3d354f66 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -298,8 +298,8 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - --write-password \ + sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Write config for root user @@ -308,8 +308,8 @@ configure_st2_cli_config() { fi # Write config for current user (in case current user != root) - st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - --write-password \ + st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Fix the permissions diff --git a/scripts/st2bootstrap-el6.sh b/scripts/st2bootstrap-el6.sh index ee768909..cc4ad9b6 100644 --- a/scripts/st2bootstrap-el6.sh +++ b/scripts/st2bootstrap-el6.sh @@ -293,8 +293,8 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - --write-password \ + sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Write config for root user @@ -303,8 +303,8 @@ configure_st2_cli_config() { fi # Write config for current user (in case current user != root) - st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - --write-password \ + st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Fix the permissions diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index 2e5d36c4..5cfde65f 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -293,8 +293,8 @@ configure_st2_cli_config() { CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - sudo st2 login --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - --write-password \ + sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Write config for root user @@ -303,8 +303,8 @@ configure_st2_cli_config() { fi # Write config for current user (in case current user != root) - st2 login --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - --write-password \ + st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ + login --write-password \ --username ${USERNAME} --password ${PASSWORD} # Fix the permissions From 4c6aff4318ed1225bde105d144e324fc06df6509 Mon Sep 17 00:00:00 2001 From: Drew Hubl Date: Thu, 21 Jun 2018 15:41:49 -0700 Subject: [PATCH 3/6] Remove unnecessary chown --- scripts/includes/common.sh | 3 --- scripts/st2bootstrap-deb.sh | 3 --- scripts/st2bootstrap-el6.sh | 3 --- scripts/st2bootstrap-el7.sh | 3 --- 4 files changed, 12 deletions(-) diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index c9b2c548..48ccc574 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -194,9 +194,6 @@ configure_st2_cli_config() { st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ --username ${USERNAME} --password ${PASSWORD} - - # Fix the permissions - chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index 3d354f66..38b2c4f4 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -311,9 +311,6 @@ configure_st2_cli_config() { st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ --username ${USERNAME} --password ${PASSWORD} - - # Fix the permissions - chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-el6.sh b/scripts/st2bootstrap-el6.sh index cc4ad9b6..3bff8259 100644 --- a/scripts/st2bootstrap-el6.sh +++ b/scripts/st2bootstrap-el6.sh @@ -306,9 +306,6 @@ configure_st2_cli_config() { st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ --username ${USERNAME} --password ${PASSWORD} - - # Fix the permissions - chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index 5cfde65f..d149609d 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -306,9 +306,6 @@ configure_st2_cli_config() { st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ --username ${USERNAME} --password ${PASSWORD} - - # Fix the permissions - chown -R ${CURRENT_USER}:${CURRENT_USER} ${CURRENT_USER_CLI_CONFIG_DIRECTORY} } From 38fdd4e6eafdcf6c1417178021bc18fb7af12232 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:57:50 +0200 Subject: [PATCH 4/6] Fix syntax, username is a position argument. --- scripts/includes/common.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index 48ccc574..42fadec3 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -183,7 +183,7 @@ configure_st2_cli_config() { sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -193,7 +193,7 @@ configure_st2_cli_config() { # Write config for current user (in case current user != root) st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} } From 6c58eb4e3b7f4ae7f548a08afd7c781776780687 Mon Sep 17 00:00:00 2001 From: Tomaz Muraus Date: Fri, 29 Jun 2018 10:58:21 +0200 Subject: [PATCH 5/6] Re-generate scripts. --- scripts/st2bootstrap-deb.sh | 4 ++-- scripts/st2bootstrap-el6.sh | 4 ++-- scripts/st2bootstrap-el7.sh | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index 38b2c4f4..b8746a21 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -300,7 +300,7 @@ configure_st2_cli_config() { sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -310,7 +310,7 @@ configure_st2_cli_config() { # Write config for current user (in case current user != root) st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} } diff --git a/scripts/st2bootstrap-el6.sh b/scripts/st2bootstrap-el6.sh index 3bff8259..77489f04 100644 --- a/scripts/st2bootstrap-el6.sh +++ b/scripts/st2bootstrap-el6.sh @@ -295,7 +295,7 @@ configure_st2_cli_config() { sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -305,7 +305,7 @@ configure_st2_cli_config() { # Write config for current user (in case current user != root) st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} } diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index d149609d..300bbadc 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -295,7 +295,7 @@ configure_st2_cli_config() { sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} # Write config for root user if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then @@ -305,7 +305,7 @@ configure_st2_cli_config() { # Write config for current user (in case current user != root) st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ login --write-password \ - --username ${USERNAME} --password ${PASSWORD} + ${USERNAME} --password ${PASSWORD} } From ef10eccba8824a92a6a73f453a0f1e70eb46fe84 Mon Sep 17 00:00:00 2001 From: armab Date: Fri, 29 Jun 2018 18:15:33 +0300 Subject: [PATCH 6/6] Fix scripted installer to use 'st2 login' to write password --- scripts/includes/common.sh | 26 +++++--------------------- scripts/st2bootstrap-deb.sh | 26 +++++--------------------- scripts/st2bootstrap-el6.sh | 26 +++++--------------------- scripts/st2bootstrap-el7.sh | 26 +++++--------------------- 4 files changed, 20 insertions(+), 84 deletions(-) diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index 42fadec3..4a82021a 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -167,33 +167,17 @@ configure_st2_user () { } +# Configure CLI config (write credentials for the root user and user which ran the script) configure_st2_cli_config() { - # Configure CLI config (write credentials for the root user and user which ran the script) - ROOT_USER="root" - CURRENT_USER=$(whoami) + # Write config for the root user + sudo -i st2 login "${USERNAME}" --password "${PASSWORD}" --write-password - ROOT_HOME=$(eval echo ~${ROOT_USER}) - : "${HOME:=$(eval echo ~${CURRENT_USER})}" - - ROOT_USER_CLI_CONFIG_DIRECTORY="${ROOT_HOME}/.st2" - ROOT_USER_CLI_CONFIG_PATH="${ROOT_USER_CLI_CONFIG_DIRECTORY}/config" - - CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" - CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - - sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} - - # Write config for root user - if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then + if [ "$(whoami)" == "root" ]; then return fi # Write config for current user (in case current user != root) - st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} + st2 login "${USERNAME}" --password "${PASSWORD}" --write-password } diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index b8746a21..02289639 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -284,33 +284,17 @@ configure_st2_user () { } +# Configure CLI config (write credentials for the root user and user which ran the script) configure_st2_cli_config() { - # Configure CLI config (write credentials for the root user and user which ran the script) - ROOT_USER="root" - CURRENT_USER=$(whoami) + # Write config for the root user + sudo -i st2 login "${USERNAME}" --password "${PASSWORD}" --write-password - ROOT_HOME=$(eval echo ~${ROOT_USER}) - : "${HOME:=$(eval echo ~${CURRENT_USER})}" - - ROOT_USER_CLI_CONFIG_DIRECTORY="${ROOT_HOME}/.st2" - ROOT_USER_CLI_CONFIG_PATH="${ROOT_USER_CLI_CONFIG_DIRECTORY}/config" - - CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" - CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - - sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} - - # Write config for root user - if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then + if [ "$(whoami)" == "root" ]; then return fi # Write config for current user (in case current user != root) - st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} + st2 login "${USERNAME}" --password "${PASSWORD}" --write-password } diff --git a/scripts/st2bootstrap-el6.sh b/scripts/st2bootstrap-el6.sh index 77489f04..4f6aabd9 100644 --- a/scripts/st2bootstrap-el6.sh +++ b/scripts/st2bootstrap-el6.sh @@ -279,33 +279,17 @@ configure_st2_user () { } +# Configure CLI config (write credentials for the root user and user which ran the script) configure_st2_cli_config() { - # Configure CLI config (write credentials for the root user and user which ran the script) - ROOT_USER="root" - CURRENT_USER=$(whoami) + # Write config for the root user + sudo -i st2 login "${USERNAME}" --password "${PASSWORD}" --write-password - ROOT_HOME=$(eval echo ~${ROOT_USER}) - : "${HOME:=$(eval echo ~${CURRENT_USER})}" - - ROOT_USER_CLI_CONFIG_DIRECTORY="${ROOT_HOME}/.st2" - ROOT_USER_CLI_CONFIG_PATH="${ROOT_USER_CLI_CONFIG_DIRECTORY}/config" - - CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" - CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - - sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} - - # Write config for root user - if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then + if [ "$(whoami)" == "root" ]; then return fi # Write config for current user (in case current user != root) - st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} + st2 login "${USERNAME}" --password "${PASSWORD}" --write-password } diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index 300bbadc..85c00a10 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -279,33 +279,17 @@ configure_st2_user () { } +# Configure CLI config (write credentials for the root user and user which ran the script) configure_st2_cli_config() { - # Configure CLI config (write credentials for the root user and user which ran the script) - ROOT_USER="root" - CURRENT_USER=$(whoami) + # Write config for the root user + sudo -i st2 login "${USERNAME}" --password "${PASSWORD}" --write-password - ROOT_HOME=$(eval echo ~${ROOT_USER}) - : "${HOME:=$(eval echo ~${CURRENT_USER})}" - - ROOT_USER_CLI_CONFIG_DIRECTORY="${ROOT_HOME}/.st2" - ROOT_USER_CLI_CONFIG_PATH="${ROOT_USER_CLI_CONFIG_DIRECTORY}/config" - - CURRENT_USER_CLI_CONFIG_DIRECTORY="${HOME}/.st2" - CURRENT_USER_CLI_CONFIG_PATH="${CURRENT_USER_CLI_CONFIG_DIRECTORY}/config" - - sudo st2 --config-file ${ROOT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} - - # Write config for root user - if [ "${CURRENT_USER}" == "${ROOT_USER}" ]; then + if [ "$(whoami)" == "root" ]; then return fi # Write config for current user (in case current user != root) - st2 --config-file ${CURRENT_USER_CLI_CONFIG_PATH} \ - login --write-password \ - ${USERNAME} --password ${PASSWORD} + st2 login "${USERNAME}" --password "${PASSWORD}" --write-password }