diff --git a/add_missing_columns.sh b/add_missing_columns.sh index 8332d58..6c4af73 100755 --- a/add_missing_columns.sh +++ b/add_missing_columns.sh @@ -217,34 +217,9 @@ echo -e "\033[32m-----\033[m" echo "Add missing columns" echo -e "\033[32m-----\033[m" - -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS diff --git a/add_missing_indices.sh b/add_missing_indices.sh index dc65686..ca718f4 100755 --- a/add_missing_indices.sh +++ b/add_missing_indices.sh @@ -217,34 +217,9 @@ echo -e "\033[32m-----\033[m" echo "Create missing indices" echo -e "\033[32m-----\033[m" - -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS diff --git a/add_missing_primary-keys.sh b/add_missing_primary-keys.sh index 099c9e0..9ac1e5c 100755 --- a/add_missing_primary-keys.sh +++ b/add_missing_primary-keys.sh @@ -217,34 +217,9 @@ echo -e "\033[32m-----\033[m" echo "Create missing indices" echo -e "\033[32m-----\033[m" - -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS diff --git a/add_user_to_group.sh b/add_user_to_group.sh index da403a5..c668c2e 100755 --- a/add_user_to_group.sh +++ b/add_user_to_group.sh @@ -255,34 +255,9 @@ echo -e "\033[32m-----\033[m" echo -e "Add User to Group - \033[1mBoth, User and Group has to exist\033[m" echo -e "\033[32m-----\033[m" - -WEBSITE= -_OK=false -echo "" -echo "Cloud instance that you want to change?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS diff --git a/check_encryption_scan_legacy-format b/check_encryption_scan_legacy-format index 2e462e3..078d32e 100755 --- a/check_encryption_scan_legacy-format +++ b/check_encryption_scan_legacy-format @@ -226,33 +226,9 @@ echo "Create missing indices" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -420,81 +396,7 @@ fi # Check PHP Version # -if [[ "$PHP_ENGINE" = "FPM" ]] ; then - if [[ -z "$PHP_VERSION" ]] ; then - if [[ -z "$VHOST_CONFIG_FILE" ]] ; then - if $NGINX_IS_ENABLED ; then - - if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")" - fi - - elif $APACHE2_IS_ENABLED ; then - - if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" - elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" - elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf" - fi - - fi - fi - if [[ -n "$VHOST_CONFIG_FILE" ]] ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - fi - if [[ -z "$PHP_VERSION" ]] ; then - - if $NGINX_IS_ENABLED ; then - upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )" - for _file in $(ls /etc/nginx/conf.d/) ; do - _rp_file="$(realpath "/etc/nginx/conf.d/${_file}")" - if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - break - fi - done - fi - - if [[ -z "$PHP_VERSION" ]] ; then - - warn "Cannot determin the PHP version\! Enter it manually" - - main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$" - - echo "" - echo -e "\033[32m--\033[m" - echo "" - echo "Enter the PHP main version, e.g. 7.4 or 8.2 .." - echo "" - echo "" - PHP_VERSION= - while [ "X$PHP_VERSION" = "X" ] - do - echononl " PHP main version: " - read PHP_VERSION - if [ "X$PHP_VERSION" = "X" ]; then - echo "" - echo -e "\033[33m\033[1mInput is required !!\033[m" - echo "" - fi - if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then - echo "" - echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m" - echo "" - PHP_VERSION= - fi - - done - - fi - - fi - fi -fi +source ${snippet_dir}/get-php-major-version if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php" diff --git a/check_for_old_files.sh b/check_for_old_files.sh index 8c36b94..5e79e07 100755 --- a/check_for_old_files.sh +++ b/check_for_old_files.sh @@ -226,32 +226,9 @@ echo -e "Add User to Group - \033[1mBoth, User and Group has to exist\033[m" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Cloud instance that you want to change?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -420,81 +397,7 @@ fi # Check PHP Version # -if [[ "$PHP_ENGINE" = "FPM" ]] ; then - if [[ -z "$PHP_VERSION" ]] ; then - if [[ -z "$VHOST_CONFIG_FILE" ]] ; then - if $NGINX_IS_ENABLED ; then - - if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")" - fi - - elif $APACHE2_IS_ENABLED ; then - - if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" - elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" - elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf" - fi - - fi - fi - if [[ -n "$VHOST_CONFIG_FILE" ]] ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - fi - if [[ -z "$PHP_VERSION" ]] ; then - - if $NGINX_IS_ENABLED ; then - upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )" - for _file in $(ls /etc/nginx/conf.d/) ; do - _rp_file="$(realpath "/etc/nginx/conf.d/${_file}")" - if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - break - fi - done - fi - - if [[ -z "$PHP_VERSION" ]] ; then - - warn "Cannot determin the PHP version\! Enter it manually" - - main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$" - - echo "" - echo -e "\033[32m--\033[m" - echo "" - echo "Enter the PHP main version, e.g. 7.4 or 8.2 .." - echo "" - echo "" - PHP_VERSION= - while [ "X$PHP_VERSION" = "X" ] - do - echononl " PHP main version: " - read PHP_VERSION - if [ "X$PHP_VERSION" = "X" ]; then - echo "" - echo -e "\033[33m\033[1mInput is required !!\033[m" - echo "" - fi - if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then - echo "" - echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m" - echo "" - PHP_VERSION= - fi - - done - - fi - - fi - fi -fi +source ${snippet_dir}/get-php-major-version if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php" diff --git a/convert_filecache_bigint.sh b/convert_filecache_bigint.sh index 95d4630..9634275 100755 --- a/convert_filecache_bigint.sh +++ b/convert_filecache_bigint.sh @@ -226,33 +226,9 @@ echo "Create missing indices" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -420,81 +396,7 @@ fi # Check PHP Version # -if [[ "$PHP_ENGINE" = "FPM" ]] ; then - if [[ -z "$PHP_VERSION" ]] ; then - if [[ -z "$VHOST_CONFIG_FILE" ]] ; then - if $NGINX_IS_ENABLED ; then - - if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="$(realpath "/etc/nginx/sites-enabled/${WEBSITE}.conf")" - fi - - elif $APACHE2_IS_ENABLED ; then - - if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" - elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" - elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf" - fi - - fi - fi - if [[ -n "$VHOST_CONFIG_FILE" ]] ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" $VHOST_CONFIG_FILE \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - fi - if [[ -z "$PHP_VERSION" ]] ; then - - if $NGINX_IS_ENABLED ; then - upstream_handler="$(grep -o -E "^[^#]*fastcgi_pass\s+[^;]+" ${VHOST_CONFIG_FILE} | awk '{print$2}' )" - for _file in $(ls /etc/nginx/conf.d/) ; do - _rp_file="$(realpath "/etc/nginx/conf.d/${_file}")" - if $(grep -q -E "\s+${upstream_handler}\s*" ${_rp_file} 2> /dev/null) ; then - PHP_VERSION="$(grep -o -E "^[^#]*php-?[[:digit:]]{1,2}\.[[:digit:]]{1}-fpm" ${_rp_file} \ - | grep -o -E "[[:digit:]]{1,2}\.[[:digit:]]{1}")" - break - fi - done - fi - - if [[ -z "$PHP_VERSION" ]] ; then - - warn "Cannot determin the PHP version\! Enter it manually" - - main_version_regex="^[[:digit:]]{1,2}\.[[:digit:]]{1}$" - - echo "" - echo -e "\033[32m--\033[m" - echo "" - echo "Enter the PHP main version, e.g. 7.4 or 8.2 .." - echo "" - echo "" - PHP_VERSION= - while [ "X$PHP_VERSION" = "X" ] - do - echononl " PHP main version: " - read PHP_VERSION - if [ "X$PHP_VERSION" = "X" ]; then - echo "" - echo -e "\033[33m\033[1mInput is required !!\033[m" - echo "" - fi - if [[ ! $PHP_VERSION =~ $main_version_regex ]] ; then - echo "" - echo -e "\033[33m\033[1mWrong entry (${PHP_VERSION}) for main PHP version !!\033[m" - echo "" - PHP_VERSION= - fi - - done - - fi - - fi - fi -fi +source ${snippet_dir}/get-php-major-version if [[ -x "/usr/local/php-${PHP_VERSION}/bin/php" ]] ; then PHP_BIN="/usr/local/php-${PHP_VERSION}/bin/php" diff --git a/occ_file_scan_all_accounts.sh b/occ_file_scan_all_accounts.sh index 4929572..8906141 100755 --- a/occ_file_scan_all_accounts.sh +++ b/occ_file_scan_all_accounts.sh @@ -197,7 +197,23 @@ while getopts hs: opt ; do done if [[ -z "$WEBSITE" ]] ; then - fatal "No website ios given on commandline - Missing Parameter '-s '" + + while IFS='' read -r -d '' _conf_file ; do + source $_conf_file + if [[ -n "$WEBSITE" ]] ; then + unsorted_website_arr+=("${WEBSITE}:$_conf_file") + fi + WEBSITE="" + done < <(find "${conf_dir}" -maxdepth 1 -type f -name "*.conf" -print0) + + # - Sort array + # - + IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) + + # Which cloud instance (website) would you like to update + # + source ${snippet_dir}/get-cloud-instance-to-update + fi WEB_BASE_DIR="/var/www/${WEBSITE}" diff --git a/occ_file_scan_app-data.sh b/occ_file_scan_app-data.sh index d1902ab..32b2763 100755 --- a/occ_file_scan_app-data.sh +++ b/occ_file_scan_app-data.sh @@ -217,38 +217,10 @@ if [[ -z "$WEBSITE" ]] ; then # - IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) - WEBSITE= - _OK=false - echo "" - echo "Which site would you like to update?" - echo "" - declare -i i=0 - for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) - done - echo - echononl " Eingabe: " - while ! $_OK ; do - read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi - done + # Which cloud instance (website) would you like to update + # + source ${snippet_dir}/get-cloud-instance-to-update - WEBSITE="$_WEBSITE" - - - #fatal "No website ios given on commandline - Missing Parameter '-s '" fi diff --git a/occ_maintenance.sh b/occ_maintenance.sh index 340aef4..258ae80 100755 --- a/occ_maintenance.sh +++ b/occ_maintenance.sh @@ -216,35 +216,9 @@ if [[ -z "$WEBSITE" ]] ; then # - IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) - WEBSITE= - _OK=false - echo "" - echo "Which site would you like to update?" - echo "" - declare -i i=0 - for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) - done - echo - echononl " Eingabe: " - while ! $_OK ; do - read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi - done - - WEBSITE="$_WEBSITE" + # Which cloud instance (website) would you like to update + # + source ${snippet_dir}/get-cloud-instance-to-update #fatal "No website ios given on commandline - Missing Parameter '-s '" fi diff --git a/occ_manual_upgrade.sh b/occ_manual_upgrade.sh index a76b6bd..15a7f40 100755 --- a/occ_manual_upgrade.sh +++ b/occ_manual_upgrade.sh @@ -216,35 +216,9 @@ if [[ -z "$WEBSITE" ]] ; then # - IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) - WEBSITE= - _OK=false - echo "" - echo "Which site would you like to update?" - echo "" - declare -i i=0 - for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) - done - echo - echononl " Eingabe: " - while ! $_OK ; do - read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi - done - - WEBSITE="$_WEBSITE" + # Which cloud instance (website) would you like to update + # + source ${snippet_dir}/get-cloud-instance-to-update #fatal "No website ios given on commandline - Missing Parameter '-s '" fi diff --git a/remove_user_from_group.sh b/remove_user_from_group.sh index ee640b4..3ba129d 100755 --- a/remove_user_from_group.sh +++ b/remove_user_from_group.sh @@ -256,33 +256,9 @@ echo -e "Remove User from Group - \033[1mBoth, User and Group has to exist\033[m echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Cloud instance that you want to change?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS diff --git a/replace_favicon.sh b/replace_favicon.sh index 6e202f6..9ea4c25 100755 --- a/replace_favicon.sh +++ b/replace_favicon.sh @@ -214,37 +214,13 @@ clear echo "" echo -e "\033[32m-----\033[m" -echo "Create missing indices" +echo "Replace favicon icon" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -278,10 +254,6 @@ DEFAULT_HTTP_GROUP="www-data" DEFAULT_PHP_ENGINE="FPM" -if [[ -z ${WEBSITE} ]] ; then - WEBSITE="$DEFAULT_WEBSITE" -fi - DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE" [[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR diff --git a/replace_logo.sh b/replace_logo.sh index 788e6b3..c5f6b9e 100755 --- a/replace_logo.sh +++ b/replace_logo.sh @@ -218,33 +218,9 @@ echo "Create missing indices" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to update?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - DEFAULT_WEBSITE="${_arr[0]}" - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -278,10 +254,6 @@ DEFAULT_HTTP_GROUP="www-data" DEFAULT_PHP_ENGINE="FPM" -if [[ -z ${WEBSITE} ]] ; then - WEBSITE="$DEFAULT_WEBSITE" -fi - DEFAULT_WEB_BASE_DIR="/var/www/$WEBSITE" [[ -n "$WEB_BASE_DIR" ]] || WEB_BASE_DIR=$DEFAULT_WEB_BASE_DIR diff --git a/restore_nextcloud.sh b/restore_nextcloud.sh index 1f658dd..78332af 100755 --- a/restore_nextcloud.sh +++ b/restore_nextcloud.sh @@ -223,32 +223,9 @@ echo "Update Nextcloud" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -echo "" -echo "Which site would you like to restore?" -echo "" -declare -i i=0 -for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) -done -echo -echononl " Eingabe: " -while ! $_OK ; do -read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi -done +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS @@ -405,33 +382,7 @@ fi # Check PHP Version # -if [[ "$PHP_ENGINE" = "FPM" ]] ; then - if [[ -z "$PHP_VERSION" ]] ; then - if [[ -z "$VHOST_CONFIG_FILE" ]] ; then - if $NGINX_IS_ENABLED ; then - - if [[ -f "/etc/nginx/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="" - fi - - elif $APACHE2_IS_ENABLED ; then - - if [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf.php-fpm" - elif [[ -f "/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/usr/local/apache2/conf/vhosts/${WEBSITE}.conf" - elif [[ -f "/etc/apache2/sites-enabled/${WEBSITE}.conf" ]] ; then - VHOST_CONFIG_FILE="/etc/apache2/sites-enabled/${WEBSITE}.conf" - fi - - fi - fi - PHP_VERSION="$(grep -o -E "php-?.{1}\..{1}-fpm" $VHOST_CONFIG_FILE | grep -o -E ".{1}\..{1}")" - if [[ -z "$PHP_VERSION" ]] ; then - fatal "PHP Version must be givven if running PHP-FPM engine (parameter 'PHP_VERSION')" - fi - fi -fi +source ${snippet_dir}/get-php-major-version diff --git a/snippets/get-cloud-instance-to-update b/snippets/get-cloud-instance-to-update new file mode 100644 index 0000000..fbb86df --- /dev/null +++ b/snippets/get-cloud-instance-to-update @@ -0,0 +1,36 @@ +WEBSITE= +_OK=false +declare -i i=0 +if [[ ${#website_arr[@]} -eq 1 ]] ; then + IFS=':' read -a _arr <<< ${website_arr[0]} + conf_file=${_arr[1]} + WEBSITE=${_arr[0]} + echo "" + echo -e "Update site \033[1m ${_arr[0]}" + echo "" +else + echo "" + echo "Which site would you like to update?" + echo "" + for _site in ${website_arr[@]} ; do + IFS=':' read -a _arr <<< ${_site} + echo " [$i] ${_arr[0]}" + ((i++)) + done + echo + echononl " Eingabe: " + while ! $_OK ; do + read _IN + if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then + IFS=':' read -a _arr <<< ${website_arr[$_IN]} + conf_file=${_arr[1]} + WEBSITE=${_arr[0]} + _OK=true + else + echo "" + echo -e "\tFalsche Eingabe !" + echo "" + echononl " Eingabe: " + fi + done +fi diff --git a/update_nextcloud.sh b/update_nextcloud.sh index f451000..4fad4aa 100755 --- a/update_nextcloud.sh +++ b/update_nextcloud.sh @@ -247,41 +247,9 @@ echo "Update Nextcloud" echo -e "\033[32m-----\033[m" -WEBSITE= -_OK=false -_HEAD=false -declare -i i=0 -if [[ ${#website_arr[@]} -eq 1 ]] ; then - IFS=':' read -a _arr <<< ${website_arr[0]} - conf_file=${_arr[1]} - echo "" - echo -e "Update site \033[1m ${_arr[0]}" - echo "" -else - echo "" - echo "Which site would you like to update?" - echo "" - for _site in ${website_arr[@]} ; do - IFS=':' read -a _arr <<< ${_site} - echo " [$i] ${_arr[0]}" - ((i++)) - done - echo - echononl " Eingabe: " - while ! $_OK ; do - read _IN - if is_number "$_IN" && [[ -n ${website_arr[$_IN]} ]]; then - IFS=':' read -a _arr <<< ${website_arr[$_IN]} - conf_file=${_arr[1]} - _OK=true - else - echo "" - echo -e "\tFalsche Eingabe !" - echo "" - echononl " Eingabe: " - fi - done -fi +# Which cloud instance (website) would you like to update +# +source ${snippet_dir}/get-cloud-instance-to-update # - Reset IFS