#!/bin/bash source /opt/webinoly/lib/install # Verify Integrity of all "required" files and system webinoly_verify() { local error="0" local warning="0" local info="0" echo "${blu}Verifying integrity of the entire Webinoly system..." echo "${red}" # Webinoly if [[ ! -a /opt/webinoly/lib/general ]]; then echo "[ERROR] File: /opt/webinoly/lib/general not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/install ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/sites ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/site-ssl ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/webin ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/update ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/public_suffix_list.dat ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/timezone.dat ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/lib/api-events_sample ]]; then echo "[ERROR] File: /opt/webinoly/lib/install not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/template-site-php ]]; then echo "[ERROR] File: /opt/webinoly/templates/template-site-php not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/template-site-proxy ]]; then echo "[ERROR] File: /opt/webinoly/templates/template-site-php not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/template-site-ssl ]]; then echo "[ERROR] File: /opt/webinoly/templates/template-site-php not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/template-site-sslredirect ]]; then echo "[ERROR] File: /opt/webinoly/templates/template-site-php not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/template-site-wwwredirect ]]; then echo "[ERROR] File: /opt/webinoly/templates/template-site-php not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/nginx.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/nginx.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/22222 ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/22222 not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/conf.d/blockips.conf ]]; then echo "[WARNING] File: /opt/webinoly/templates/nginx/conf.d/blockips.conf not found!" warning="1" fi if [[ ! -a /opt/webinoly/templates/nginx/conf.d/fastcgi.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/conf.d/fastcgi.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/conf.d/upstream.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/conf.d/upstream.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/acl.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/acl.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/locations.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/locations.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/php.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/php.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/wpcommon.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/wpcommon.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/wpfc.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/wpfc.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/wpsubdir.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/wpsubdir.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/headers-html.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/headers-html.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/headers-http.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/headers-http.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/nginx/common/headers-https.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/nginx/common/headers-https.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/webinoly.conf ]]; then echo "[ERROR] File: /opt/webinoly/webinoly.conf not found!" error="1" fi if [[ ! -a /usr/bin/webinoly ]]; then echo "[ERROR] File: /usr/bin/webinoly not found!" error="1" fi if [[ ! -a /usr/bin/site ]]; then echo "[ERROR] File: /usr/bin/site not found!" error="1" fi if [[ ! -a /usr/bin/httpauth ]]; then echo "[ERROR] File: /usr/bin/httpauth not found!" error="1" fi if [[ ! -a /usr/bin/log ]]; then echo "[ERROR] File: /usr/bin/log not found!" error="1" fi if [[ ! -a /usr/bin/stack ]]; then echo "[ERROR] File: /usr/bin/stack not found!" error="1" fi # NGINX if [[ $(conf_read nginx) == "true" ]]; then if [[ ! -a /etc/nginx/nginx.conf ]]; then echo "[ERROR] File: /etc/nginx/nginx.conf not found!" error="1" fi if [[ ! -a /etc/nginx/fastcgi.conf ]]; then echo "[ERROR] File: /etc/nginx/fastcgi.conf not found!" error="1" fi fi if [[ $(conf_read nginx) != "true" ]]; then if [[ -a /etc/nginx/nginx.conf ]]; then echo "[WARNING] Seems like NGINX is installed but Webinoly can not detect it!" warning="1" fi if [[ -a /etc/nginx/fastcgi.conf ]]; then echo "[WARNING] Seems like NGINX is installed but Webinoly can not detect it!" warning="1" fi fi # NGINX Optim if [[ $(conf_read nginx-optim) == "true" ]]; then if [[ ! -a /etc/nginx/fastcgi_params ]]; then echo "[ERROR] File: /etc/nginx/fastcgi_params not found!" error="1" fi if [[ ! -a /etc/nginx/.htpasswd ]]; then echo "[INFO] File: /etc/nginx/.htpasswd not found!" info="1" fi if [[ ! -a /etc/nginx/conf.d/blockips.conf ]]; then echo "[WARNING] File: /etc/nginx/conf.d/blockips.conf not found!" warning="1" fi if [[ ! -a /etc/nginx/conf.d/fastcgi.conf ]]; then echo "[ERROR] File: /etc/nginx/conf.d/fastcgi.conf not found!" error="1" fi if [[ ! -a /etc/nginx/conf.d/upstream.conf ]]; then echo "[ERROR] File: /etc/nginx/conf.d/upstream.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/acl.conf ]]; then echo "[ERROR] File: /etc/nginx/common/acl.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/locations.conf ]]; then echo "[ERROR] File: /etc/nginx/common/locations.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/php.conf ]]; then echo "[ERROR] File: /etc/nginx/common/php.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/wpcommon.conf ]]; then echo "[ERROR] File: /etc/nginx/common/wpcommon.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/wpfc.conf ]]; then echo "[ERROR] File: /etc/nginx/common/wpfc.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/wpsubdir.conf ]]; then echo "[ERROR] File: /etc/nginx/common/wpsubdir.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/headers-html.conf ]]; then echo "[ERROR] File: /etc/nginx/common/headers-html.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/headers-http.conf ]]; then echo "[ERROR] File: /etc/nginx/common/headers-http.conf not found!" error="1" fi if [[ ! -a /etc/nginx/common/headers-https.conf ]]; then echo "[ERROR] File: /etc/nginx/common/headers-https.conf not found!" error="1" fi fi # NGINX Tools if [[ $(conf_read nginx-tool) == "true" ]]; then if [[ ! -a /etc/nginx/sites-available/$(conf_read tools-port) ]]; then echo "[ERROR] File: /etc/nginx/sites-available/$(conf_read tools-port) not found!" error="1" fi if [[ ! -d /var/www/$(conf_read tools-port) ]]; then echo "[ERROR] Folder: /var/www/$(conf_read tools-port) not found!" error="1" fi if [[ -z $(conf_read tools-port) ]]; then echo "[ERROR] Port Tools not found!" error="1" fi fi if [[ $(conf_read nginx-tool) != "true" ]]; then if [[ -a /etc/nginx/sites-available/$(conf_read tools-port) ]]; then echo "[WARNING] Seems like Nginx Tools are enabled but Webinoly can not detect it!" warning="1" fi if [[ -d /var/www/$(conf_read tools-port) ]]; then echo "[WARNING] Seems like Nginx Tools are enabled but Webinoly can not detect it!" warning="1" fi fi # NGINX Conf check if [[ $(conf_read nginx) != "true" && ( $(conf_read nginx-optim) == "true" || $(conf_read nginx-tool) == "true" ) ]]; then echo "[WARNING] NGINX Configuration corrupted!" warning="1" fi # PHP if [[ ! -a /etc/php/$(conf_read php-ver)/fpm/php.ini && $(conf_read php) == "true" ]]; then echo "[ERROR] File: /etc/php/$(conf_read php-ver)/fpm/php.ini not found!" error="1" elif [[ -a /etc/php/$(conf_read php-ver)/fpm/php.ini && $(conf_read php) != "true" ]]; then echo "[WARNING] Seems like PHP is installed but Webinoly can not detect it!" warning="1" fi # PHP Optim if [[ $(conf_read php-optim) == "true" ]]; then if [[ ! -a /etc/php/$(conf_read php-ver)/fpm/php-fpm.conf ]]; then echo "[ERROR] File: /etc/php/$(conf_read php-ver)/fpm/php-fpm.conf not found!" error="1" fi if [[ ! -a /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf ]]; then echo "[ERROR] File: /etc/php/$(conf_read php-ver)/fpm/pool.d/debug.conf not found!" error="1" fi if [[ ! -a /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf ]]; then echo "[ERROR] File: /etc/php/$(conf_read php-ver)/fpm/pool.d/www.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/source/www.conf ]]; then echo "[ERROR] File: /opt/webinoly/templates/source/www.conf not found!" error="1" fi if [[ ! -a /opt/webinoly/templates/source/php.ini ]]; then echo "[ERROR] File: /opt/webinoly/templates/source/php.ini not found!" error="1" fi fi # PHP Tools if [[ $(conf_read php-tool) == "true" && $(conf_read nginx) == "true" ]]; then if [[ ! -a /var/www/$(conf_read tools-port)/htdocs/fpm/status/php ]]; then echo "[ERROR] File: /var/www/$(conf_read tools-port)/htdocs/fpm/status/php not found!" error="1" fi if [[ ! -a /var/www/$(conf_read tools-port)/htdocs/fpm/status/debug ]]; then echo "[ERROR] File: /var/www/$(conf_read tools-port)/htdocs/fpm/status/debug not found!" error="1" fi if [[ ! -a /var/www/$(conf_read tools-port)/htdocs/php/index.php ]]; then echo "[ERROR] File: /var/www/$(conf_read tools-port)/htdocs/php/index.php not found!" error="1" fi fi if [[ $(conf_read php-tool) != "true" && $(conf_read nginx) == "true" ]]; then if [[ -a /var/www/$(conf_read tools-port)/htdocs/fpm/status/php ]]; then echo "[WARNING] Seems like PHP Tools are enabled but Webinoly can not detect it!" warning="1" fi if [[ -a /var/www/$(conf_read tools-port)/htdocs/fpm/status/debug ]]; then echo "[WARNING] Seems like PHP Tools are enabled but Webinoly can not detect it!" error="1" fi if [[ -a /var/www/$(conf_read tools-port)/htdocs/php/index.php ]]; then echo "[WARNING] Seems like PHP Tools are enabled but Webinoly can not detect it!" warning="1" fi fi # PHP Conf check if [[ $(conf_read php) != "true" && ( $(conf_read php-optim) == "true" || $(conf_read php-tool) == "true" ) ]]; then echo "[WARNING] PHP Configuration corrupted!" warning="1" fi # MySQL if [[ ! -d /etc/mysql && $(conf_read mysql) == "true" ]]; then echo "[ERROR] Folder: /etc/mysql not found!" error="1" elif [[ -d /etc/mysql && $(conf_read mysql) != "true" ]]; then echo "[WARNING] Seems like MySQL is installed but Webinoly can not detect it!" warning="1" fi # MySQL Tools if [[ ! -d /var/www/$(conf_read tools-port)/htdocs/pma && $(conf_read mysql-tool) == "true" ]]; then echo "[ERROR] Folder: /var/www/$(conf_read tools-port)/htdocs/pma not found!" error="1" elif [[ ( -d /var/www/$(conf_read tools-port)/htdocs/pma || -d /usr/share/phpmyadmin ) && $(conf_read mysql-tool) != "true" ]]; then echo "[WARNING] Seems like MySQL Tools (PhpMyAdmin) are enabled but Webinoly can not detect it!" warning="1" fi # MySQL Conf check if [[ $(conf_read mysql) != "true" && $(conf_read mysql-tool) == "true" ]]; then echo "[WARNING] MySQL Configuration corrupted!" warning="1" fi # Web Tools if [[ $(conf_read php-tool) == "true" ]]; then if [[ ! -d /etc/redis ]]; then echo "[ERROR] Folder: /etc/redis not found!" error="1" fi if [[ ! -d /etc/postfix ]]; then echo "[ERROR] Folder: /etc/postfix not found!" error="1" fi fi if [[ $(conf_read nginx-tool) == "true" ]]; then if [[ ! -a /usr/bin/duplicity ]]; then echo "[ERROR] File: /usr/bin/duplicity not found!" error="1" fi if [[ ! -a /usr/bin/letsencrypt ]]; then echo "[ERROR] File: /usr/bin/letsencrypt not found!" error="1" fi fi # Check if services are running and check configurations if ! systemctl is-active --quiet nginx && [[ $(conf_read nginx) == "true" ]]; then echo "[ERROR] Nginx service not running!" error="1" fi if ! systemctl is-active --quiet php$(conf_read php-ver)-fpm && [[ $(conf_read php) == "true" ]]; then echo "[ERROR] PHP service not running!" error="1" fi if ! systemctl is-active --quiet mysql && [[ $(conf_read mysql) == "true" ]]; then echo "[ERROR] MySQL (MariaDB) service not running!" error="1" fi if ! systemctl is-active --quiet redis-server && [[ $(conf_read php-tool) == "true" ]]; then echo "[ERROR] Redis service not running!" error="1" fi if ! systemctl is-active --quiet memcached && [[ $(conf_read php-tool) == "true" ]]; then echo "[ERROR] Memcached service not running!" error="1" fi if ! systemctl is-active --quiet postfix && [[ $(conf_read php-tool) == "true" ]]; then echo "[ERROR] Postfix service not running!" error="1" fi if ! sudo nginx -t 2>/dev/null && [[ $(conf_read nginx) == "true" ]]; then echo "[ERROR] Nginx Configuration check failed!" error="1" fi local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt ) if ! sudo mysql --connect-timeout=10 --user=root -p$ROOT_PASS -e "quit" 2>/dev/null && [[ $(conf_read mysql) == "true" ]]; then echo "[ERROR] MySQL Connection to localhost failed!" error="1" fi # Linux Optim local swapkb=$(grep SwapTotal /proc/meminfo | cut -f 2 -d ':' | tr -d ' ' | cut -f 1 -d 'k') if [[ $(conf_read linux-optim) == "true" && ( -z $swapkb || $swapkb == "0" ) && $(conf_read swap-mem) != 0 ]]; then echo "[ERROR] SWAP Memory File not found!" error="1" fi echo "" if [ $error != 0 ]; then echo "*******************************************************" echo "******** ${gre}> > > E R R O R < < <${red} ***********" echo "******** ${gre}System could not work properly${red} ***********" echo "******************************************************* ${end}" exit 1 elif [ $warning != 0 ]; then echo "***********************************************************************************************************" echo "******** ${gre}[ W A R N I N G ] System seems to be corrupted and could not work properly${red} ***********" echo "*********************************************************************************************************** ${end}" exit 2 else echo "${gre}Integrity test passed!! ${end}" exit 0 fi } system_info() { ramv=$(($(grep MemTotal /proc/meminfo | cut -f 2 -d ':' | tr -d ' ' | cut -f 1 -d 'k')/1024)) [[ $ramv -ge 1024 ]] && ramv="$(($ramv/1024))Gb" || ramv="${ramv}Mb" swapv=$(($(grep SwapTotal /proc/meminfo | cut -f 2 -d ':' | tr -d ' ' | cut -f 1 -d 'k')/1024)) [[ $swapv -ge 1024 ]] && swapv="$(($swapv/1024))Gb" || swapv="${swapv}Mb" echo "${blu}" echo "[SYSTEM]" echo "Operating System: $(sudo cat /proc/version) " echo "$(sudo lsb_release -d) " echo "$(sudo lsb_release -c) " echo "Cores: $(grep ^processor /proc/cpuinfo | wc -l) " echo "RAM: ${ramv} " echo "SWAP: ${swapv} " echo "File descriptors: $(sudo cat /proc/sys/fs/file-max) " echo "" echo [Disk Usage] sudo df -Th / echo "" echo "[NGINX]" if [[ $(conf_read nginx) == "true" ]]; then sudo nginx -v echo "nginx file descriptors: $(grep 'Max open files' /proc/$(cat /run/nginx.pid)/limits | cut -f 15 -d ' ') " echo "worker_processes: $(grep worker_processes /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';') " echo "worker_connections: $(grep worker_connections /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';')" echo "worker_rlimit_nofile: $(grep worker_rlimit_nofile /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';')" echo "client_max_body_size: $(grep client_max_body_size /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';')" echo "" echo "[CACHE]" echo "FastCGI 200: $( grep -F "fastcgi_cache_valid 200" /etc/nginx/conf.d/fastcgi.conf | rev | cut -d' ' -f 1 | rev | tr -d ';')" echo "FastCGI 3xx/4xx: $( grep -F "fastcgi_cache_valid 301 302 307 404" /etc/nginx/conf.d/fastcgi.conf | rev | cut -d' ' -f 1 | rev | tr -d ';' )" echo "FastCGI inactive: $( grep -F "fastcgi_cache_path" /etc/nginx/conf.d/fastcgi.conf | rev | cut -d' ' -f 1 | rev | cut -d'=' -f 2 | tr -d ';')" echo "FastCGI max-size: $( grep -F "fastcgi_cache_path" /etc/nginx/conf.d/fastcgi.conf | rev | cut -d' ' -f 2 | rev | cut -f 2 -d '=' )" echo "open_file_cache_valid: $(grep open_file_cache_valid /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';')" echo "open_file_cache max: $(grep -w open_file_cache /etc/nginx/nginx.conf | cut -f 2 -d ' ' | cut -f 2 -d '=')" echo "open_file_cache inactive: $(grep -w open_file_cache /etc/nginx/nginx.conf | cut -f 3 -d ' ' | cut -f 2 -d '=' | tr -d ';')" echo "" else echo "${red} NGINX is not installed! ${blu}" echo "" fi echo "[PHP]" if [[ $(conf_read php) == "true" ]]; then echo $(php -v | grep -m1 "") echo "memory_limit: $(grep memory_limit /etc/php/$(conf_read php-ver)/fpm/php.ini | cut -f 2 -d '=' )" echo "post_max_size: $(grep post_max_size /etc/php/$(conf_read php-ver)/fpm/php.ini | cut -f 2 -d '=' )" echo "upload_max_filesize: $(grep upload_max_filesize /etc/php/$(conf_read php-ver)/fpm/php.ini | cut -f 2 -d '=' )" echo "max_file_uploads: $(grep max_file_uploads /etc/php/$(conf_read php-ver)/fpm/php.ini | cut -f 2 -d '=' )" echo "max_execution_time: $(grep max_execution_time /etc/php/$(conf_read php-ver)/fpm/php.ini | cut -f 2 -d '=' )" echo "" else echo "${red} PHP is not installed! ${blu}" echo "" fi echo "[MYSQL]" if [[ $(conf_read mysql) == "true" ]]; then [[ $(conf_read mysql-tool) == "true" ]] && pmaver=$(grep -e "\$this->set('PMA_VERSION',.*'[0-9\.]*');" /var/www/22222/htdocs/pma/libraries/classes/Config.php | cut -f 4 -d "'") || pmaver="Not installed!" sudo mysql --version echo "PhpMyAdmin: $pmaver" echo "" else echo "${red} MySQL is not installed! ${blu}" echo "" fi echo "[Raw Conf]" if [[ -a /opt/webinoly/webinoly.conf ]]; then sudo cat /opt/webinoly/webinoly.conf else echo "${red} [ERROR] Configuration File not found! ${blu}" fi echo "" echo "${end}" }