diff --git a/scripts/includes/common.sh b/scripts/includes/common.sh index 36aaeaf8..1e10a09b 100644 --- a/scripts/includes/common.sh +++ b/scripts/includes/common.sh @@ -1,3 +1,23 @@ + +###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation. +set_password(){ + typeset PASSWORD + regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*" + #echo $regex + echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******" + echo "Please enter password for User to be created: " + read PASSWORD + if [ "${PASSWORD}" = '' ]; then + echo "Password cannot be empty." + exit 1 + fi + while ! echo "$PASSWORD" | grep -P "$regex" + do + echo "Enter password to match criteria" + read PASSWORD + done +} + function configure_proxy() { # Allow bypassing 'proxy' env vars via sudo local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"' diff --git a/scripts/st2bootstrap-deb.sh b/scripts/st2bootstrap-deb.sh index 9f1f934f..2c4b4654 100644 --- a/scripts/st2bootstrap-deb.sh +++ b/scripts/st2bootstrap-deb.sh @@ -28,6 +28,7 @@ if [[ "$SUBTYPE" != 'xenial' && "$SUBTYPE" != 'focal' && "$SUBTYPE" != 'bionic' exit 2 fi + setup_args() { for i in "$@" do @@ -111,12 +112,7 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [ "${PASSWORD}" = '' ]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi # Python 3.6 package is not available in Ubuntu Xenial @@ -147,6 +143,26 @@ setup_args() { } + +###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation. +set_password(){ + typeset PASSWORD + regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*" + #echo $regex + echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******" + echo "Please enter password for User to be created: " + read PASSWORD + if [ "${PASSWORD}" = '' ]; then + echo "Password cannot be empty." + exit 1 + fi + while ! echo "$PASSWORD" | grep -P "$regex" + do + echo "Enter password to match criteria" + read PASSWORD + done +} + function configure_proxy() { # Allow bypassing 'proxy' env vars via sudo local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"' diff --git a/scripts/st2bootstrap-deb.template.sh b/scripts/st2bootstrap-deb.template.sh index 85c08a77..68bafb27 100644 --- a/scripts/st2bootstrap-deb.template.sh +++ b/scripts/st2bootstrap-deb.template.sh @@ -20,6 +20,7 @@ if [[ "$SUBTYPE" != 'xenial' && "$SUBTYPE" != 'focal' && "$SUBTYPE" != 'bionic' exit 2 fi + setup_args() { for i in "$@" do @@ -103,12 +104,7 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [ "${PASSWORD}" = '' ]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi # Python 3.6 package is not available in Ubuntu Xenial diff --git a/scripts/st2bootstrap-el7.sh b/scripts/st2bootstrap-el7.sh index ddff48d4..498be35c 100644 --- a/scripts/st2bootstrap-el7.sh +++ b/scripts/st2bootstrap-el7.sh @@ -22,6 +22,7 @@ ST2_PKG='st2' ST2WEB_PKG='st2web' ST2CHATOPS_PKG='st2chatops' + setup_args() { for i in "$@" do @@ -99,16 +100,31 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [ "${PASSWORD}" = '' ]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi } + +###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation. +set_password(){ + typeset PASSWORD + regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*" + #echo $regex + echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******" + echo "Please enter password for User to be created: " + read PASSWORD + if [ "${PASSWORD}" = '' ]; then + echo "Password cannot be empty." + exit 1 + fi + while ! echo "$PASSWORD" | grep -P "$regex" + do + echo "Enter password to match criteria" + read PASSWORD + done +} + function configure_proxy() { # Allow bypassing 'proxy' env vars via sudo local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"' diff --git a/scripts/st2bootstrap-el7.template.sh b/scripts/st2bootstrap-el7.template.sh index 58a98ea2..f2d8e3e9 100644 --- a/scripts/st2bootstrap-el7.template.sh +++ b/scripts/st2bootstrap-el7.template.sh @@ -14,6 +14,7 @@ ST2_PKG='st2' ST2WEB_PKG='st2web' ST2CHATOPS_PKG='st2chatops' + setup_args() { for i in "$@" do @@ -91,12 +92,7 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [ "${PASSWORD}" = '' ]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi } diff --git a/scripts/st2bootstrap-el8.sh b/scripts/st2bootstrap-el8.sh index a5b1076e..fff9bccc 100644 --- a/scripts/st2bootstrap-el8.sh +++ b/scripts/st2bootstrap-el8.sh @@ -26,6 +26,7 @@ is_rhel() { return $(cat /etc/os-release | grep 'ID="rhel"') } + setup_args() { for i in "$@" do @@ -103,16 +104,31 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [[ "${PASSWORD}" = '' ]]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi } + +###This will ask user to create strong password containing one Upper case alphabet, one lower case alphabet, one digut and if it matches the criteria then only user will be given access to the installation. +set_password(){ + typeset PASSWORD + regex="^(?=[a-zA-Z0-9#@!\-&+=\$\/?]{8,120}$)(?=.*?[a-z])(?=.*?[A-Z])(?=.*?[0-9])(?=.*?[#@!\-&+=\$\/]).*" + #echo $regex + echo "******Please Note: Password should be at least 8 characters long with one digit, one Upper case Alphabet, one lower case alphabet and one special character ******" + echo "Please enter password for User to be created: " + read PASSWORD + if [ "${PASSWORD}" = '' ]; then + echo "Password cannot be empty." + exit 1 + fi + while ! echo "$PASSWORD" | grep -P "$regex" + do + echo "Enter password to match criteria" + read PASSWORD + done +} + function configure_proxy() { # Allow bypassing 'proxy' env vars via sudo local sudoers_proxy='Defaults env_keep += "http_proxy https_proxy no_proxy proxy_ca_bundle_path DEBIAN_FRONTEND"' diff --git a/scripts/st2bootstrap-el8.template.sh b/scripts/st2bootstrap-el8.template.sh index 84d59f92..ac8a630f 100644 --- a/scripts/st2bootstrap-el8.template.sh +++ b/scripts/st2bootstrap-el8.template.sh @@ -18,6 +18,7 @@ is_rhel() { return $(cat /etc/os-release | grep 'ID="rhel"') } + setup_args() { for i in "$@" do @@ -95,12 +96,7 @@ setup_args() { echo "You can also use \"--user\" and \"--password\" for unattended installation." echo "Press \"ENTER\" to continue or \"CTRL+C\" to exit/abort" read -e -p "Admin username: " -i "st2admin" USERNAME - read -e -s -p "Password: " PASSWORD - - if [[ "${PASSWORD}" = '' ]]; then - echo "Password cannot be empty." - exit 1 - fi + set_password fi }