From 6debbfc6345d13cec971f1d2b511ada5df49c6bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Mart=C3=ADnez=20Ochoa?= Date: Thu, 19 Oct 2023 18:05:33 -0700 Subject: [PATCH] hotfix Error detecting empty files. --- lib/bkp | 6 +++--- lib/general | 4 ++-- lib/install | 12 ++++++------ lib/sites | 14 +++++++------- lib/update | 2 +- lib/verify | 18 +++++++++--------- lib/webin | 4 ++-- usr/httpauth | 8 ++++---- 8 files changed, 34 insertions(+), 34 deletions(-) diff --git a/lib/bkp b/lib/bkp index c85c153..5877335 100644 --- a/lib/bkp +++ b/lib/bkp @@ -223,7 +223,7 @@ check_duply_profile() { bkp_s3_profile() { - if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(grep '[^[:space:]]' $HOME/.aws/credentials )))) && $(conf_read awsiamrole) != true ]]; then + if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(cat -v $HOME/.aws/credentials | grep -m 1 '[^[:space:]]')))) && $(conf_read awsiamrole) != true ]]; then echo "${red}[ERROR] AWS S3 Credentials not found!${end}" exit 1 fi @@ -403,7 +403,7 @@ bkp_s3_list() { s3_send() { - if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(grep '[^[:space:]]' $HOME/.aws/credentials )))) && $(conf_read awsiamrole) != true ]]; then + if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(cat -v $HOME/.aws/credentials | grep -m 1 '[^[:space:]]')))) && $(conf_read awsiamrole) != true ]]; then echo "${red}[ERROR] AWS S3 Credentials not found!${end}" exit 1 fi @@ -960,7 +960,7 @@ _EOF_ import_server() { [[ -z $file || $file == "true" ]] && read -p "${blu}Path file to import: ${end}" file - if [[ ! -f $file || ( -f $file && ( ! -s $file || -z $(grep '[^[:space:]]' $file ))) ]]; then + if [[ ! -f $file || ( -f $file && ( ! -s $file || -z $(cat -v $file | grep -m 1 '[^[:space:]]'))) ]]; then echo "${red}[ERROR] File not found or empty!${end}" exit 1 elif ! [[ $import =~ ^(true|sites|stack|full)$ ]]; then diff --git a/lib/general b/lib/general index db787e1..c52edfb 100644 --- a/lib/general +++ b/lib/general @@ -4,7 +4,7 @@ # Prevent 'tput' errors when running from Cron [[ -z $TERM || $TERM == "unknown" || $TERM == "dumb" ]] && export TERM=dumb -readonly app_version="1.17.6" +readonly app_version="1.17.7" readonly svr_version="1.8" readonly os_ubuntu_supported=(bionic focal jammy) # https://ubuntu.com/about/release-cycle readonly php_supported=(7.4 8.0 8.1 8.2) # https://www.php.net/supported-versions.php @@ -1801,7 +1801,7 @@ custom_cache_global() { [[ -n $skip_cache ]] && local value=$skip_cache sudo sed -Ei "/^# Value: $(escaped_string $value)( .*)?$/,/^# CacheRuleEnd/{/.*/d}" $confile - [[ -f $confile && ( ! -s $confile || -z $(grep '[^[:space:]]' $confile )) ]] && sudo rm $confile # Better because also check for files containing only empty-spaces! + [[ -f $confile && ( ! -s $confile || -z $(cat -v $confile | grep -m 1 '[^[:space:]]')) ]] && sudo rm $confile # Better because also check for files containing only empty-spaces! fi echo "${gre}Cache rule successfully removed!${end}" else diff --git a/lib/install b/lib/install index 5346007..9f0a894 100644 --- a/lib/install +++ b/lib/install @@ -101,7 +101,7 @@ linux_optim() { # File directors for Nginx [[ ! -d /etc/systemd/system/nginx.service.d ]] && sudo mkdir /etc/systemd/system/nginx.service.d [[ ! -f /etc/systemd/system/nginx.service.d/nofile_limit.conf ]] && sudo touch /etc/systemd/system/nginx.service.d/nofile_limit.conf - [[ ! -s /etc/systemd/system/nginx.service.d/nofile_limit.conf || -z $(grep '[^[:space:]]' /etc/systemd/system/nginx.service.d/nofile_limit.conf ) ]] && sudo echo "[Service] + [[ ! -s /etc/systemd/system/nginx.service.d/nofile_limit.conf || -z $(cat -v /etc/systemd/system/nginx.service.d/nofile_limit.conf | grep -m 1 '[^[:space:]]') ]] && sudo echo "[Service] LimitNOFILE=$fd_per_process" >> /etc/systemd/system/nginx.service.d/nofile_limit.conf # Disable Transparent Huge Pages @@ -984,7 +984,7 @@ stack_builder() { echo | sudo add-apt-repository "deb https://nginx.org/packages/ubuntu/ $(check_osname) nginx" fi else - [[ -f /usr/share/keyrings/nginx-archive-keyring.gpg && ( ! -s /usr/share/keyrings/nginx-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/nginx-archive-keyring.gpg )) ]] && sudo rm -rf /usr/share/keyrings/nginx-archive-keyring.gpg # Prevent issues! + [[ -f /usr/share/keyrings/nginx-archive-keyring.gpg && ( ! -s /usr/share/keyrings/nginx-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/nginx-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/nginx-archive-keyring.gpg # Prevent issues! [[ ! -f /usr/share/keyrings/nginx-archive-keyring.gpg ]] && wget -nv -O- https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg if [[ $(conf_read nginx-ppa) == "mainline" ]]; then echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/mainline/ubuntu/ $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list @@ -1006,7 +1006,7 @@ stack_builder() { #sudo apt install -y language-pack-en-base sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php else - [[ -f /usr/share/keyrings/php-archive-keyring.gpg && ( ! -s /usr/share/keyrings/php-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/php-archive-keyring.gpg )) ]] && sudo rm -rf /usr/share/keyrings/php-archive-keyring.gpg # Prevent issues! + [[ -f /usr/share/keyrings/php-archive-keyring.gpg && ( ! -s /usr/share/keyrings/php-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/php-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/php-archive-keyring.gpg # Prevent issues! [[ ! -f /usr/share/keyrings/php-archive-keyring.gpg ]] && wget -nv -O- 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | sudo gpg --dearmor -o /usr/share/keyrings/php-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/php.list fi @@ -1023,7 +1023,7 @@ stack_builder() { # Snap is available but it has no support for ARM architecture: https://snapcraft.io/redis echo | sudo add-apt-repository ppa:redislabs/redis else - [[ -f /usr/share/keyrings/redis-archive-keyring.gpg && ( ! -s /usr/share/keyrings/redis-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/redis-archive-keyring.gpg )) ]] && sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg # Prevent issues! + [[ -f /usr/share/keyrings/redis-archive-keyring.gpg && ( ! -s /usr/share/keyrings/redis-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/redis-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg # Prevent issues! [[ ! -f /usr/share/keyrings/redis-archive-keyring.gpg ]] && wget -nv -O- https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list fi @@ -1041,7 +1041,7 @@ stack_builder() { fi if [[ $(conf_read db-engine) == "mysql" ]]; then - [[ -f /usr/share/keyrings/mysql-archive-keyring.gpg && ( ! -s /usr/share/keyrings/mysql-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/mysql-archive-keyring.gpg )) ]] && sudo rm -rf /usr/share/keyrings/mysql-archive-keyring.gpg # Prevent issues! + [[ -f /usr/share/keyrings/mysql-archive-keyring.gpg && ( ! -s /usr/share/keyrings/mysql-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/mysql-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/mysql-archive-keyring.gpg # Prevent issues! [[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg ]] && wget -nv -O- 'https://repo.mysql.com/RPM-GPG-KEY-mysql-2022' | sudo gpg --dearmor -o /usr/share/keyrings/mysql-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/mysql-archive-keyring.gpg] http://repo.mysql.com/apt/ubuntu $(lsb_release -cs) mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql.list @@ -1050,7 +1050,7 @@ stack_builder() { sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' echo | sudo add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mirrors.syringanetworks.net/mariadb/repo/$(conf_read mysql-ver)/ubuntu $(check_osname) main" else - [[ -f /usr/share/keyrings/mariadb-archive-keyring.gpg && ( ! -s /usr/share/keyrings/mariadb-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/mariadb-archive-keyring.gpg )) ]] && sudo rm -rf /usr/share/keyrings/mariadb-archive-keyring.gpg # Prevent issues! + [[ -f /usr/share/keyrings/mariadb-archive-keyring.gpg && ( ! -s /usr/share/keyrings/mariadb-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/mariadb-archive-keyring.gpg | grep -m 1 '[^[:space:]]' )) ]] && sudo rm -rf /usr/share/keyrings/mariadb-archive-keyring.gpg # Prevent issues! [[ ! -f /usr/share/keyrings/mariadb-archive-keyring.gpg ]] && wget -nv -O- 'https://mariadb.org/mariadb_release_signing_key.asc' | sudo gpg --dearmor -o /usr/share/keyrings/mariadb-archive-keyring.gpg echo "deb [signed-by=/usr/share/keyrings/mariadb-archive-keyring.gpg] http://mirrors.syringanetworks.net/mariadb/repo/$(conf_read mysql-ver)/ubuntu $(check_osname) main" | sudo tee /etc/apt/sources.list.d/mariadb.list fi diff --git a/lib/sites b/lib/sites index 513bb8e..8e0b2f2 100644 --- a/lib/sites +++ b/lib/sites @@ -11,7 +11,7 @@ warning_messages() { if [[ $type == [123] && $dbhost != "localhost" && $(conf_read dbrole) =~ ^(all|grant)$ ]]; then echo "${dim}[WARNING] You have set '$(conf_read dbrole)' as default privileges, some external DB services may not support it!${end}" fi - if [[ $type == [123] && $(conf_read wp-admin-auth) != "purged" && ( ! -s /etc/nginx/.htpasswd || -z $(grep '[^[:space:]]' /etc/nginx/.htpasswd )) && ( ! -s /etc/nginx/apps.d/.htpasswd-$domain || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/.htpasswd-$domain )) ]]; then + if [[ $type == [123] && $(conf_read wp-admin-auth) != "purged" && ( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && ( ! -s /etc/nginx/apps.d/.htpasswd-$domain || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$domain | grep -m 1 '[^[:space:]]')) ]]; then echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to complete the WordPress installation process!!${end}" fi if [[ $(conf_read login-www-data) != "true" && (( -z $forward && -z $proxy && -z $parked && -z $mysql ) || ( -n $mysql && -n $domain )) ]]; then @@ -602,14 +602,14 @@ deletesite() { # In case of custom cache if [[ -f /etc/nginx/conf.d/webinoly.conf ]]; then sudo sed -i "/^fastcgi_cache_path \/run\/nginx-cache\/$(echo $domain | sed 's/[^0-9A-Za-z]/_/g').*/d" /etc/nginx/conf.d/webinoly.conf - [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/webinoly.conf )) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf + [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf fi # Check for Reverse Proxy upstreams if [[ -f /etc/nginx/conf.d/upstream_proxy.conf ]]; then local domvar=$(echo "$domain" | sed "s/[^0-9A-Za-z]/_/g") sudo sed -i "/upstream ${domvar}/,/} #End/{/.*/d}" /etc/nginx/conf.d/upstream_proxy.conf - [[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/upstream_proxy.conf )) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf + [[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf fi echo "${gre}Site${blu} $domain ${gre}has been successfully deleted!${end}" @@ -654,7 +654,7 @@ deletesite_subfolder() { # In case of custom cache if [[ -f /etc/nginx/conf.d/webinoly.conf ]]; then sudo sed -i "/^fastcgi_cache_path \/run\/nginx-cache\/$(echo $domain | sed 's/[^0-9A-Za-z]/_/g')${subname} .*/d" /etc/nginx/conf.d/webinoly.conf - [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/webinoly.conf )) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf + [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf fi echo "${gre}${dim}Subfolder${blu} $subfolder ${gre}from${blu} $domain ${gre}has been successfully deleted!${end}" @@ -668,7 +668,7 @@ deletesite_subfolder() { if [[ -f /etc/nginx/conf.d/upstream_proxy.conf ]]; then local domvar=$(echo "$domain$subfolder" | sed "s/[^0-9A-Za-z]/_/g") sudo sed -i "/upstream ${domvar}/,/} #End/{/.*/d}" /etc/nginx/conf.d/upstream_proxy.conf - [[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/upstream_proxy.conf )) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf + [[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf fi sudo rm -rf /var/www/$domain/htdocs$subfolder @@ -935,7 +935,7 @@ redirection_manager() { if [[ -f /etc/nginx/apps.d/$domain-nginx.conf ]]; then sudo sed -Ei '/^# RedirectFrom: '$(escaped_string $from)'( .*)?$/,/^# RedirectEnd/{/.*/d}' /etc/nginx/apps.d/$domain-nginx.conf - if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/$domain-nginx.conf )) ]]; then + if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then sudo rm /etc/nginx/apps.d/$domain-nginx.conf sudo sed -i "/$domain-nginx.conf;/d" /etc/nginx/sites-available/$domain fi @@ -1558,7 +1558,7 @@ wp_cache() { else echo "${gre}Custom Nginx Cache configuration not found! ${end}" fi - [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/webinoly.conf )) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf + [[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf elif [[ -n $query_string_never_cache || $query_string_cache || $skip_cache || -n $skip_cookie_cache ]]; then custom_cache_global -site elif [[ -n $query_string_cache_default ]]; then diff --git a/lib/update b/lib/update index 3a332cc..42430ae 100644 --- a/lib/update +++ b/lib/update @@ -82,7 +82,7 @@ onethree_to_onefour() { sudo mkdir -p /etc/nginx/apps.d sudo cp /etc/nginx/common/acl.conf /opt/webinoly/templates/source/acl.conf.old grep "^allow [^127.0.0.1]" /opt/webinoly/templates/source/acl.conf.old > /etc/nginx/apps.d/whitelist-acl.conf - [[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/whitelist-acl.conf )) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf + [[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(cat -v /etc/nginx/apps.d/whitelist-acl.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf [[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i "/acl.conf;/i \ include common\/auth.conf;" /etc/nginx/sites-available/$(conf_read tools-port) for site in "/etc/nginx/sites-available"/* diff --git a/lib/verify b/lib/verify index a89b788..1e8e76b 100644 --- a/lib/verify +++ b/lib/verify @@ -350,7 +350,7 @@ if [[ $(conf_read nginx) == "true" ]]; then echo "- [ERROR] Nginx Apt Key not found!" local ver_two_err="1" fi - if [[ ! -f /etc/apt/sources.list.d/nginx.list || ! -s /etc/apt/sources.list.d/nginx.list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/nginx.list ) ]]; then + if [[ ! -f /etc/apt/sources.list.d/nginx.list || ! -s /etc/apt/sources.list.d/nginx.list || -z $(cat -v /etc/apt/sources.list.d/nginx.list | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] Nginx PPA not found in sources list!" local ver_two_err="1" fi @@ -573,11 +573,11 @@ if [[ $(conf_read php) == "true" ]]; then fi if [[ $(lsb_release -c | cut -d':' -f 2 | xargs) =~ ^(bionic|focal)$ ]]; then - if [[ ! -f /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || ! -s /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || -z $(grep '[^[:space:]]' /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg ) ]]; then + if [[ ! -f /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || ! -s /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || -z $(cat -v /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] PHP Apt Key not found!" local ver_three_err="1" fi - if [[ ! -f /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list ) ]]; then + if [[ ! -f /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || -z $(cat -v /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] PHP PPA not found in sources list!" local ver_three_err="1" fi @@ -586,7 +586,7 @@ if [[ $(conf_read php) == "true" ]]; then echo "- [ERROR] PHP Apt Key not found!" local ver_three_err="1" fi - if [[ ! -f /etc/apt/sources.list.d/php.list || ! -s /etc/apt/sources.list.d/php.list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/php.list ) ]]; then + if [[ ! -f /etc/apt/sources.list.d/php.list || ! -s /etc/apt/sources.list.d/php.list || -z $(cat -v /etc/apt/sources.list.d/php.list | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] PHP PPA not found in sources list!" local ver_three_err="1" fi @@ -736,11 +736,11 @@ if [[ $(conf_read mysql) == "true" ]]; then # PPA & Keys if [[ $(conf_read db-engine) == "mysql" ]]; then - if [[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg || ! -s /usr/share/keyrings/mysql-archive-keyring.gpg || -z $(grep '[^[:space:]]' /usr/share/keyrings/mysql-archive-keyring.gpg ) ]]; then + if [[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg || ! -s /usr/share/keyrings/mysql-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/mysql-archive-keyring.gpg | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] MySQL Apt Key not found!" local ver_four_err="1" fi - if [[ ! -f /etc/apt/sources.list.d/mysql.list || ! -s /etc/apt/sources.list.d/mysql.list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/mysql.list ) ]]; then + if [[ ! -f /etc/apt/sources.list.d/mysql.list || ! -s /etc/apt/sources.list.d/mysql.list || -z $(cat -v /etc/apt/sources.list.d/mysql.list | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] MySQL PPA not found in sources list!" local ver_four_err="1" fi @@ -758,7 +758,7 @@ if [[ $(conf_read mysql) == "true" ]]; then echo "- [ERROR] MariaDB Apt Key not found!" local ver_four_err="1" fi - if [[ ! -f /etc/apt/sources.list.d/mariadb.list || ! -s /etc/apt/sources.list.d/mariadb.list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/mariadb.list ) ]]; then + if [[ ! -f /etc/apt/sources.list.d/mariadb.list || ! -s /etc/apt/sources.list.d/mariadb.list || -z $(cat -v /etc/apt/sources.list.d/mariadb.list | grep -m 1 '[^[:space:]]') ]]; then echo "- [ERROR] MariaDB PPA not found in sources list!" local ver_four_err="1" fi @@ -1031,7 +1031,7 @@ if [[ $(conf_read php-tool-redis) == "true" ]]; then # 18.04 - /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list # 20.04 - /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list # 22.04 - /etc/apt/sources.list.d/redis.list - if [[ ( ! -f /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || ! -s /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list ) ) && ( ! -f /etc/apt/sources.list.d/redis.list || ! -s /etc/apt/sources.list.d/redis.list || -z $(grep '[^[:space:]]' /etc/apt/sources.list.d/redis.list )) ]]; then + if [[ ( ! -f /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || ! -s /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || -z $(cat -v /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list | grep -m 1 '[^[:space:]]')) && ( ! -f /etc/apt/sources.list.d/redis.list || ! -s /etc/apt/sources.list.d/redis.list || -z $(cat -v /etc/apt/sources.list.d/redis.list | grep -m 1 '[^[:space:]]')) ]]; then echo "- [ERROR] Redis PPA not found in sources list!" local ver_seven_err="1" fi @@ -1222,7 +1222,7 @@ if [[ -z $critical_mode ]]; then if [[ $ver_domi != "html" && $ver_domi != $ADMIN_TOOLS_SITE ]]; then # If WordPress, then check connection! if [[ $(is_wp $ver_domi) == "true" ]]; then - if [[ ( ! -s /etc/nginx/.htpasswd || -z $(grep '[^[:space:]]' /etc/nginx/.htpasswd )) && ( ! -s /etc/nginx/apps.d/.htpasswd-$ver_domi || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/.htpasswd-$ver_domi )) && $(is_wp_auth $ver_domi) == "true" ]]; then + if [[ ( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && ( ! -s /etc/nginx/apps.d/.htpasswd-$ver_domi || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$ver_domi | grep -m 1 '[^[:space:]]')) && $(is_wp_auth $ver_domi) == "true" ]]; then echo "${blu}${dim}- [INFO] HTTP Authentication Credentials not found for $ver_domi${end}${red}" fi diff --git a/lib/webin b/lib/webin index 71c3bad..2e257c7 100644 --- a/lib/webin +++ b/lib/webin @@ -695,7 +695,7 @@ set_tools_site() { fi # Warning Message - if [[ (( ! -s /etc/nginx/.htpasswd || -z $(grep '[^[:space:]]' /etc/nginx/.htpasswd )) && $tools_site == "default" ) || (( ! -s /etc/nginx/.htpasswd || -z $(grep '[^[:space:]]' /etc/nginx/.htpasswd )) && $tools_site != "default" && -f /etc/nginx/sites-available/$tools_site && ( ! -s /etc/nginx/apps.d/.htpasswd-$tools_site || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/.htpasswd-$tools_site ))) ]]; then + if [[ (( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && $tools_site == "default" ) || (( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && $tools_site != "default" && -f /etc/nginx/sites-available/$tools_site && ( ! -s /etc/nginx/apps.d/.htpasswd-$tools_site || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$tools_site | grep -m 1 '[^[:space:]]'))) ]]; then echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to access these tools!${end}" fi } @@ -953,7 +953,7 @@ nginx_blockip() { [[ -f /etc/nginx/conf.d/blockips.conf ]] && sed -i "\#^deny ${blockip};#d" /etc/nginx/conf.d/blockips.conf # Remove site-auth-file if empty. - [[ -f /etc/nginx/conf.d/blockips.conf && ( ! -s /etc/nginx/conf.d/blockips.conf || -z $(grep '[^[:space:]]' /etc/nginx/conf.d/blockips.conf )) ]] && sudo rm /etc/nginx/conf.d/blockips.conf + [[ -f /etc/nginx/conf.d/blockips.conf && ( ! -s /etc/nginx/conf.d/blockips.conf || -z $(cat -v /etc/nginx/conf.d/blockips.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/blockips.conf echo "${gre}The IP address ${blu}'$blockip'${gre} was successfully unblocked!${end}" else diff --git a/usr/httpauth b/usr/httpauth index b674897..a9af84c 100644 --- a/usr/httpauth +++ b/usr/httpauth @@ -96,7 +96,7 @@ elif [[ -n $delete ]]; then sudo sed -i "/^$userpurge:/d" /etc/nginx/$authfile # Remove site-auth-file if empty. - if [[ -n $domain && -f /etc/nginx/$authfile && ( ! -s /etc/nginx/$authfile || -z $(grep '[^[:space:]]' $authfile )) ]]; then + if [[ -n $domain && -f /etc/nginx/$authfile && ( ! -s /etc/nginx/$authfile || -z $(cat -v $authfile | grep -m 1 '[^[:space:]]')) ]]; then sudo rm /etc/nginx/$authfile sudo rm -rf /etc/nginx/apps.d/.htpasswd-www.$domain fi @@ -212,7 +212,7 @@ elif [[ -n $whitelist ]]; then [[ -f /etc/nginx/apps.d/whitelist-acl.conf ]] && sudo sed -i "\#^allow ${whitelist};#d" /etc/nginx/apps.d/whitelist-acl.conf # Remove site-auth-file if empty. - [[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/whitelist-acl.conf )) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf + [[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(cat -v /etc/nginx/apps.d/whitelist-acl.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf echo "${gre}The IP address ${blu}'$whitelist'${gre} was successfully removed from whitelist!${end}" else @@ -327,7 +327,7 @@ location $sign$path { elif [[ $path =~ ^\/([A-Za-z0-9_\/\.\-]+)?$ ]]; then if [[ -f /etc/nginx/apps.d/$domain-nginx.conf ]]; then sudo sed -i "/^# Path: $(echo $path | sed "s#/#\\\/#g")/,/^# PathEnd/{/.*/d}" /etc/nginx/apps.d/$domain-nginx.conf - if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(grep '[^[:space:]]' /etc/nginx/apps.d/$domain-nginx.conf )) ]]; then + if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then sudo rm /etc/nginx/apps.d/$domain-nginx.conf sudo sed -i "/$domain-nginx.conf;/d" /etc/nginx/sites-available/$domain fi @@ -376,7 +376,7 @@ elif [[ -n $list ]]; then done } fi - [[ ( ! -s /etc/nginx/$authfile || -z $(grep '[^[:space:]]' /etc/nginx/$authfile )) && -z $raw && $list != "raw" ]] && echo "${blu}[Empty] No users were found!${end}" + [[ ( ! -s /etc/nginx/$authfile || -z $(cat -v /etc/nginx/$authfile | grep -m 1 '[^[:space:]]')) && -z $raw && $list != "raw" ]] && echo "${blu}[Empty] No users were found!${end}" echo "" nginx_not="true" # Nginx-Reload not-needed.