Compare commits

..

No commits in common. "master" and "v1.17.3" have entirely different histories.

16 changed files with 197 additions and 438 deletions

View file

@ -19,7 +19,7 @@ Webinoly provides a set of tools and commands that facilitate web server adminis
- Unique commands to create, delete, disable sites.
- Free SSL certificates for your sites with Lets Encrypt and automatic server configuration.
- HTTP/2 dramatically increases the speed of serving your content.
- PHP v8.2 and support for earlier versions if needed (8.1, 8.0 and 7.4).
- PHP v8.1 and support for earlier versions if needed (8.0 and 7.4) or the newest 8.2.
- FastCGI Cache and Redis Object Cache for your WordPress sites.
- Install WP in any subfolder and support for external databases, multisite and domain mapping.
- Reverse Proxy for any app (Java, React, Node, Angular, Vue, etc) or to use your own domain with any external file repo like S3.

View file

@ -1,25 +1,12 @@
#!/bin/bash
# Internal API/Events
# Docs: https://webinoly.com/internal-api-events/
# Internal API or Events
# Docs: https://webinoly.com/en/internal-api-events/
# Description: Execute actions at certain points or events, for example at the end of the "stack" command (each time is executed), or after Nginx is installed, etc.
# - Just rename this file to "api-events".
# - Check for the complete list of status codes in the docs.
# - Status codes can be read in this variable $1
# Description: Execute actions at certain points or events, for example at the end of the "stack" command each time is executed
# or after Nginx is installed. Just rename this file to "api-events" and check for the complete list of status codes in the documentation.
# Just put all your code inside this function:
api-events_catch_status() {
# Example: Status codes will be "echoed" or visible each time a Webinoly command is excecuted.
# You can use this to see where exactly your code will be excecuted.
# This line can be safely removed! (it's for illustrative purposes only)
echo "${blu}API Status: $1 ${end}"
# Example: Install my own package after Nginx is installed!
#if [[ $1 == "in2" ]]; then
# sudo apt install -y my-own-package
#fi
}

70
lib/bkp
View file

@ -67,13 +67,8 @@ bkp_local_db() {
if [[ -z $master_multi_bkp_db && $dbname != "all" ]]; then
if [[ ( -z $wp || $wp == "true") && ( -z $dbname || $dbname == "true" ) ]]; then
read -p "${gre}WordPress site (domain) or Database name: ${end}" dbq
is_url $dbq -split
# We check if is_wp here to give it a second chance as dbname in case it fails.
if [[ -n $url_host && -f /etc/nginx/sites-available/$url_host && $(is_wp $url_host $url_path) == "true" ]]; then
wp=$url_host
[[ -n $url_path ]] && subfolder=$url_path
if [[ -n $dbq && -f /etc/nginx/sites-available/$dbq ]]; then
wp=$dbq
elif [[ -n $dbq ]]; then
dbname=$dbq
wp=""
@ -88,7 +83,7 @@ bkp_local_db() {
echo "${red}[ERROR] Site not found! ${dim}($wp)${end}"
exit 1
elif [[ $(is_wp $wp $subfolder) != "true" ]]; then
echo "${red}[ERROR] Please, enter a valid WP site! ${dim}(${wp}${subfolder})${end}"
echo "${red}[ERROR] Please, enter a valid WP site! ${dim}($wp)${end}"
exit 1
else
wp_conf_retrieve $wp true true $subfolder
@ -219,8 +214,16 @@ bkp_local_db() {
}
check_duply_profile() {
if [[ ! -d $HOME/.duply/$profile ]]; then
echo "${red}[ERROR] Backup profile not found!${end}"
exit 1
fi
}
bkp_s3_profile() {
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
if [[ ! -s $HOME/.aws/credentials && $(conf_read awsiamrole) != true ]]; then
echo "${red}[ERROR] AWS S3 Credentials not found!${end}"
exit 1
fi
@ -235,19 +238,14 @@ bkp_s3_profile() {
fi
fi
# These options needs a valid profile!
if [[ -n $profile && $profile != "true" && ! -d $HOME/.duply/$profile && ( -n $run || -n $info || -n $delete || -n $restore || -n $add_db_pre ) ]]; then
echo "${red}[ERROR] Backup profile not found!${end}"
exit 1
#else
# Create a new profile!
fi
if [[ -n $run ]]; then
check_duply_profile
sudo duply $profile backup_verify_purge --force --allow-source-mismatch
elif [[ -n $info ]]; then
check_duply_profile
local tar=$(grep -E "^TARGET[ ]?=" $HOME/.duply/$profile/conf | cut -f 2 -d "'" )
local sou=$(grep -E "^SOURCE[ ]?=" $HOME/.duply/$profile/conf | cut -f 2 -d "'" )
local age=$(grep -E "^MAX_AGE[ ]?=" $HOME/.duply/$profile/conf | cut -f 2 -d "=" )
@ -267,10 +265,14 @@ bkp_s3_profile() {
echo ""
elif [[ -n $delete ]]; then
check_duply_profile
sudo rm -rf $HOME/.duply/$profile
echo "${gre}Backup profile ${blu}'$profile'${gre} was successfully deleted!${end}"
elif [[ -n $restore ]]; then
check_duply_profile
# Temporary check!!!! Should be removed soon!!!
if [[ $restore != "true" && -z $destination ]]; then
echo "${red}[ERROR] Backup Restore syntax has changed, destination paramater is needed!${end}"
@ -292,6 +294,8 @@ bkp_s3_profile() {
elif [[ -n $add_db_pre && -n $list ]]; then
check_duply_profile
if [[ -s $HOME/.duply/$profile/pre ]]; then
if [[ -z $raw ]]; then
echo ""
@ -306,27 +310,22 @@ bkp_s3_profile() {
elif [[ -n $add_db_pre && -n $purge ]]; then
check_duply_profile
sudo rm -rf $HOME/.duply/$profile/pre
echo "${gre}PRE Database backups for${blu} '$profile' ${gre}has been successfully removed!${end}"
elif [[ -n $add_db_pre ]]; then
if [[ $add_db_pre == "true" ]]; then
read -p "${gre}WordPress site (domain): ${end}" add_db_pre
is_url $add_db_pre -split
if [[ -n $url_host && -n $url_path ]]; then
add_db_pre=$url_host
subfolder=$url_path
fi
fi
check_duply_profile
[[ $add_db_pre == "true" ]] && read -p "${gre}WordPress site: ${end}" add_db_pre
# we dont check is_wp_installed because at this point we are still not doing a backup, just setting it.
if [[ -z $add_db_pre || $(is_wp $add_db_pre $subfolder) != "true" ]]; then
echo "${red}[ERROR] Please, enter a valid WP site!${end}"
exit 1
elif [[ $(wp_config_read $add_db_pre DB_HOST $subfolder) != "localhost" && -z $(conf_read external-dbu) && -z $(conf_read external-dbp) ]]; then
fi
if [[ $(wp_config_read $add_db_pre DB_HOST $subfolder) != "localhost" && -z $(conf_read external-dbu) && -z $(conf_read external-dbp) ]]; then
echo "${red}[ERROR] Database host is not localhost!${dim} (External databases are supported only when credentials are saved in Webinoly Configuration file)${end}"
exit 1
fi
@ -404,7 +403,7 @@ bkp_s3_list() {
s3_send() {
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
if [[ ! -s $HOME/.aws/credentials && $(conf_read awsiamrole) != true ]]; then
echo "${red}[ERROR] AWS S3 Credentials not found!${end}"
exit 1
fi
@ -779,7 +778,7 @@ export_site() {
for sit in "/etc/nginx/apps.d/${siteto}$(echo $subfolder | sed "s/\//_/g")_"*-wpcommon.conf
do
local suby="/$(echo $sit | cut -f 2- -d "_" -s | cut -f -1 -d "-" -s | sed "s/_/\//g")"
if [[ -n $suby && $(is_wp $siteto $suby) == "true" ]]; then
if [[ $(is_wp $siteto $suby) == "true" ]]; then
wp_conf_retrieve $siteto false false $suby
if [[ -n $suby && $(conf_read mysql) == "true" && $wp_dbhost_host == "localhost" && $(is_wp_installed $siteto $suby) == "true" && -n $wp_dbname ]]; then
if [[ -z $export_db_list ]]; then
@ -961,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 $(cat -v $file | grep -m 1 '[^[:space:]]'))) ]]; then
if [[ ! -s $file ]]; then
echo "${red}[ERROR] File not found or empty!${end}"
exit 1
elif ! [[ $import =~ ^(true|sites|stack|full)$ ]]; then
@ -1087,13 +1086,8 @@ bkp_wizard() {
elif [[ $wzd == 8 ]]; then
bkp_s3_list
elif [[ $wzd == 9 ]]; then
read -p "${blu}Site to export (domain): ${end}" site
is_url $site -split
if [[ -n $url_host && -n $url_path ]]; then
sudo webinoly -backup=local -export=$url_host -subfolder=$url_path
else # if not a URL, let it fail in the export function!
sudo webinoly -backup=local -export=$site
fi
read -p "${blu}Site to export: ${end}" site
sudo webinoly -backup=local -export=$site
elif [[ $wzd == 10 ]]; then
export_server
elif [[ $wzd == 11 ]]; then

View file

@ -76,7 +76,7 @@ logrotate_perm() {
local path="/etc/logrotate.d/php$(conf_read php-ver)-fpm"
local owner="root root"
elif [[ $1 == "mysql" ]]; then
[[ -f /etc/logrotate.d/mariadb ]] && local path="/etc/logrotate.d/mariadb" || local path="/etc/logrotate.d/mysql-server"
local path="/etc/logrotate.d/mysql-server"
local owner="mysql adm"
elif [[ $1 == "redis" ]]; then
local path="/etc/logrotate.d/redis-server"
@ -86,7 +86,7 @@ logrotate_perm() {
local owner=""
fi
if [[ -n $path && -n $owner && -f $path ]]; then
if [[ -n $path && -n $owner ]]; then
sudo sed -i "/create [0-9]/d" $path
sudo sed -i "/missingok/i \ create 0644 $owner" $path
fi

View file

@ -4,13 +4,13 @@
# Prevent 'tput' errors when running from Cron
[[ -z $TERM || $TERM == "unknown" || $TERM == "dumb" ]] && export TERM=dumb
readonly app_version="1.17.9"
readonly app_version="1.17.3"
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 8.3) # https://www.php.net/supported-versions.php
readonly php_default="8.2"
readonly php_supported=(7.4 8.0 8.1 8.2) # https://www.php.net/supported-versions.php
readonly php_default="8.1"
readonly mariadb_supported=(10.6 10.11) # https://mariadb.com/kb/en/mariadb-server-release-dates/
readonly mariadb_default="10.11"
readonly mariadb_default="10.6"
readonly mysql_supported=(8.0)
readonly mysql_default="8.0"
readonly datadog_agent_ver="7"
@ -32,8 +32,8 @@ readonly hidend=$(tput sgr0)$(tput el)
# ***********************************************
conf_read() {
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then # Double check!
echo "${red}[ERROR] Webinoly Configuration file not found!${end}"
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then
echo "${red}[ERROR] Config file not found!${end}"
exit 1
fi
@ -41,8 +41,8 @@ conf_read() {
}
conf_delete() {
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then # Double check!
echo "${red}[ERROR] Webinoly Configuration file not found!${end}"
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then
echo "${red}[ERROR] Config file not found!${end}"
exit 1
fi
@ -78,7 +78,7 @@ conf_write() {
if [[ $(whoami) != "root" ]]; then
echo "${red}Please run this script as root or using sudo.${end}"
exit 1
fi
fi
# Check for BASH Shell
# This is a very "shity" method, but checking if file exists is very reliable
@ -354,7 +354,7 @@ check_mysql_connection() {
# Master-admin not needed here for specific dbs.
# Note: You can always use the dynvar 'quiet' set to 'true' to not display messages.
# In this especific case ONLY, there is a third value: false, true and truebutnotmaster (External DB connection successfull but not enough privileges for master-admin)
# In this especific case ONLY, there is a third value: false, true and truebutnotmaster (connection successfull but not enough privileges for master-admin)
local query="quit"
local error_display="true"
@ -441,7 +441,7 @@ password = $4
elif [[ $out == "false" ]]; then
echo "false"
else
[[ $master_priv == "false" ]] && echo "truebutnotmaster" || echo "true"
[[ $(conf_read quiet) != "true" ]] && echo "true" || echo "truebutnotmaster"
fi
}
@ -449,7 +449,7 @@ password = $4
check_external_db_saved() {
if [[ -n $(conf_read external-dbh) && -n $(conf_read external-dbu) && -n $(conf_read external-dbp) && -n $(conf_read external-dbx) ]]; then
external_db="[$(conf_read external-dbu),$(conf_read external-dbp),$(conf_read external-dbh):$(conf_read external-dbx)]"
[[ $(conf_read quiet) != "true" ]] && echo "${blu}${dim}External DB credentials found in your saved configuration! ($(conf_read external-dbh):$(conf_read external-dbx))${end}" >&2
[[ $(conf_read quiet) != "true" ]] && echo "${blu}${dim}External DB credentials found in your saved configuration!${end}" >&2
fi
}
@ -677,7 +677,7 @@ wp_conf_retrieve() {
extdb_host=$wp_dbhost
extdb_url=$wp_dbhost_host
extdb_port=$wp_dbhost_port
echo "${blu}${dim}External DB Credentials found! (${wp_dbhost})${end}" >&2
echo "${blu}${dim}External DB Credentials found!${end}" >&2
fi
fi
@ -692,8 +692,6 @@ wp_conf_retrieve() {
local maindom=$1
fi
# Parked site don't have support for subfolders, but we send it here as double check.
# If we send only the domain and the original request contains the subfolder, we can get a wrong value in return.
if [[ $(is_wp_multisite $maindom $4) =~ ^(subdomain|subdirectory)$ ]]; then
local dbq="USE $wp_dbname; SELECT blog_id FROM ${wp_dbpref}blogs WHERE domain='$1' OR domain='www.$1';"
if [[ $wp_dbhost_host == "localhost" && $(check_mysql_connection localhost $mysql_param) == "true" ]]; then
@ -1175,9 +1173,7 @@ is_subfolder() {
echo "proxy"
elif [[ $(is_html $1 $2) == "true" ]]; then
echo "html"
elif [[ -d /var/www/${1}/htdocs${2} && -z $(find /var/www/${1}/htdocs${2} -maxdepth 1 -type f | head -n 1) ]]; then
echo "empty"
elif [[ -d /var/www/${1}/htdocs${2} ]]; then
elif [[ -d /var/www/$1/htdocs/$2 ]]; then
echo "true"
else
echo "false"
@ -1801,7 +1797,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 $(cat -v $confile | grep -m 1 '[^[:space:]]')) ]] && sudo rm $confile # Better because also check for files containing only empty-spaces!
[[ ! -s $confile || -z $(grep '[^[:space:]]' $confile ) ]] && sudo rm $confile # Better because also check for files containing only empty-spaces!
fi
echo "${gre}Cache rule successfully removed!${end}"
else
@ -1956,7 +1952,7 @@ ads_donate() {
conf_write cron-ads $EPOCHSECONDS
elif ! [[ $(conf_read cron-ads) =~ ^[0-9]+$ ]] || [[ $(conf_read cron-ads) -gt $EPOCHSECONDS ]]; then # Autofix! (Just in case!)
conf_write cron-ads $EPOCHSECONDS
elif [[ $TERM != "dumb" && -n $EPOCHSECONDS && -n $(conf_read cron-ads) && $(($EPOCHSECONDS-$(conf_read cron-ads))) -gt 86400 ]] && ! [[ /dev/stdout -ef /dev/null ]]; then
elif [[ -n $EPOCHSECONDS && -n $(conf_read cron-ads) && $(($EPOCHSECONDS-$(conf_read cron-ads))) -gt 86400 ]] && ! [[ /dev/stdout -ef /dev/null ]]; then
echo "${blu}"
echo "****************************************************************************"
echo "******************** ${bol}Are you enjoying Webinoly?${end}${blu} ********************"

View file

@ -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 $(cat -v /etc/systemd/system/nginx.service.d/nofile_limit.conf | grep -m 1 '[^[:space:]]') ]] && sudo echo "[Service]
[[ ! -s /etc/systemd/system/nginx.service.d/nofile_limit.conf ]] && sudo echo "[Service]
LimitNOFILE=$fd_per_process" >> /etc/systemd/system/nginx.service.d/nofile_limit.conf
# Disable Transparent Huge Pages
@ -188,14 +188,7 @@ nginx_install() {
sudo nginx -t && sudo systemctl start nginx
sudo systemctl enable nginx
conf_write nginx true
if [[ -d /etc/nginx ]] && systemctl is-active --quiet nginx; then
echo "${gre}Nginx has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during Nginx installation!${end}"
fi
echo "${gre}Nginx has been installed successfully! ${end}"
api-events_update in2
}
@ -210,18 +203,11 @@ php_install() {
fi
local ver=$(conf_read php-ver)
sudo apt -y install php${ver}-common php${ver}-cli php${ver}-fpm php${ver}-curl php${ver}-gd php${ver}-imap php${ver}-readline php${ver}-mysql php${ver}-mbstring php${ver}-bcmath php${ver}-opcache php${ver}-zip php${ver}-xml php${ver}-soap php${ver}-imagick php${ver}-msgpack php${ver}-igbinary php${ver}-intl php-pear graphviz ghostscript
sudo apt -y install php${ver}-common php${ver}-cli php${ver}-fpm php${ver}-curl php${ver}-gd php${ver}-imap php${ver}-readline php${ver}-mysql php${ver}-mbstring php${ver}-bcmath php${ver}-mysql php${ver}-opcache php${ver}-zip php${ver}-xml php${ver}-soap php${ver}-imagick php${ver}-msgpack php${ver}-igbinary php${ver}-intl php-pear graphviz ghostscript
conf_write php true
if [[ -d /etc/php/${ver}/fpm ]] && systemctl is-active --quiet php${ver}-fpm; then
echo "${gre}PHP has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during PHP installation!${end}"
fi
api-events_update ip2
echo "${gre}PHP has been installed successfully! ${end}"
}
@ -244,7 +230,7 @@ mysql_install() {
# In case of re-installation after purge with keep-data option.
local AUTOGENPASS_ROOT=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
local AUTOGENPASS_ADMIN=$( echo $(conf_read mysql-admin) | openssl enc -d -a -salt )
conf_write mysql-reinstall true
local reinstall="true"
fi
# MySQL/MariaDB Installation
@ -263,6 +249,13 @@ mysql_install() {
fi
conf_write mysql true
# https://mariadb.com/kb/en/mysql_upgrade/
# The mysql_upgrade client is deprecated in MySQL 8. (This process is done automatically)
if [[ $reinstall == "true" && $(conf_read db-engine) != "mysql" ]]; then
echo "${blu}${dim}Seems like you are reinstalling MySQL/MariaDB... Upgrading your old tables!${end}"
sudo mysql_upgrade --user=root --force --silent
fi
#Instead of mysql_secure_installation we do this: (same but manually, because not acept unattended)
# - Set a password for root accounts
@ -270,9 +263,7 @@ mysql_install() {
# - Remove anonymous-user accounts.
# - Delete the test database, accessible by anonymous users.
# - Reload the user privileges tables.
if [[ $(conf_read mysql-reinstall) != "true" ]]; then # Just for new and fresh installations! (not needed when reinstalling)
echo "${blu}${dim}MySQL/MariaDB Secure Installation! ${end}"
sudo mysql --user=root <<_EOF_
sudo mysql --user=root <<_EOF_
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DROP DATABASE IF EXISTS test;
@ -282,48 +273,29 @@ GRANT ALL PRIVILEGES ON *.* TO 'admin'@'localhost' WITH GRANT OPTION;
FLUSH PRIVILEGES;
_EOF_
if [[ $(conf_read db-engine) == "mysql" ]]; then
sudo mysql --user=root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '${AUTOGENPASS_ROOT}';FLUSH PRIVILEGES;"
else
sudo mysql --user=root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${AUTOGENPASS_ROOT}';FLUSH PRIVILEGES;"
fi
if [[ $(conf_read db-engine) == "mysql" ]]; then
sudo mysql --user=root -e "ALTER USER 'root'@'localhost' IDENTIFIED WITH caching_sha2_password BY '${AUTOGENPASS_ROOT}';FLUSH PRIVILEGES;"
else
sudo mysql --user=root -e "ALTER USER 'root'@'localhost' IDENTIFIED BY '${AUTOGENPASS_ROOT}';FLUSH PRIVILEGES;"
fi
sudo rm -rf $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf
if [[ -d /etc/mysql ]] && systemctl is-active --quiet mysql; then
echo "${gre}MySQL/MariaDB has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during MySQL/MariaDB installation!${end}"
fi
api-events_update im4
echo "${gre}MySQL/MariaDB has been installed successfully! ${end}"
}
mysql_client_install() {
api-events_update im1
[[ $(conf_read db-engine) != "mysql" ]] && sudo apt -y install mariadb-client || sudo apt -y install mysql-client
conf_write mysql-client true
if [[ -d /etc/mysql ]] && which mysql >/dev/null ; then
echo "${gre}MySQL/MariaDB Client has been successfully installed!${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during MySQL/MariaDB installation!${end}"
fi
api-events_update im2
echo "${gre}MySQL/MariaDB Client has been successfully installed!${end}"
}
#NGINX OPTIM
nginx_optim() {
api-events_update in3
if [[ ! -d /etc/nginx ]]; then
echo "${red}[ERROR] Nginx Optimization process aborted!${end}"
return
fi
# Check if exists in case of server-reset
[[ ! -f /opt/webinoly/templates/source/default ]] && sudo cp -p /etc/nginx/sites-available/default /opt/webinoly/templates/source/
@ -436,8 +408,8 @@ location = /xmlrpc.php {
conf_write server-version $svr_version
conf_write nginx-optim true
sudo systemctl reload nginx
echo "${gre}Nginx has been successfully Optimized by Webinoly! ${end}"
api-events_update in4
echo "${gre}Nginx has been successfully Optimized by Webinoly! ${end}"
}
@ -445,13 +417,9 @@ location = /xmlrpc.php {
# PHP OPTIM
php_optim() {
api-events_update ip3
local ver=$(conf_read php-ver)
if [[ ! -d /etc/php/${ver}/fpm ]]; then
echo "${red}[ERROR] PHP Optimization process aborted!${end}"
return
fi
# Check if exist in case of server-reset
local ver=$(conf_read php-ver)
[[ ! -f /opt/webinoly/templates/source/php.ini ]] && sudo cp -p /etc/php/${ver}/fpm/php.ini /opt/webinoly/templates/source/
[[ ! -f /opt/webinoly/templates/source/www.conf ]] && sudo cp -p /etc/php/${ver}/fpm/pool.d/www.conf /opt/webinoly/templates/source/
[[ ! -f /opt/webinoly/templates/source/php-fpm.conf ]] && sudo cp -p /etc/php/${ver}/fpm/php-fpm.conf /opt/webinoly/templates/source/
@ -501,19 +469,14 @@ php_optim() {
[[ $(conf_read php-tool-redis) == "true" && -n $(conf_read redis-max-mem) ]] && redis_optim
conf_write php-optim true
sudo systemctl restart php${ver}-fpm
echo "${gre}PHP has been successfully Optimized by Webinoly! ${end}"
api-events_update ip4
echo "${gre}PHP has been successfully Optimized by Webinoly! ${end}"
}
# MySQL/MariaDB OPTIM
mysql_optim() {
api-events_update im5
if [[ ! -d /etc/mysql ]]; then
echo "${red}[ERROR] MySQL/MariaDB Optimization process aborted!${end}"
return
fi
mysql_default_cnf
# MySQL/MariaDB login data
@ -541,19 +504,9 @@ host = localhost
[[ $(conf_read mysql-public-access) == "true" ]] && sudo webinoly -mysql-public-access=on
[[ $(conf_read mysql-public-access) == "false" ]] && sudo webinoly -mysql-public-access=off
# https://mariadb.com/kb/en/mysql_upgrade/
# The mysql_upgrade client is deprecated in MySQL 8. (This process is done automatically)
# Should do it using admin user, root has password and it may be removed in conf file.
# Should be here in optim, because when reinstalling admin login CNF is removed.
if [[ $(conf_read mysql-reinstall) == "true" && $(conf_read db-engine) != "mysql" ]]; then
echo "${blu}${dim}Seems like you are reinstalling MySQL/MariaDB... Upgrading your old tables!${end}"
sudo mysql_upgrade --user=admin --force --silent
conf_delete mysql-reinstall
fi
conf_write mysql-optim true
echo "${gre}MySQL/MariaDB has been successfully Optimized by Webinoly! ${end}"
api-events_update im6
echo "${gre}MySQL/MariaDB has been successfully Optimized by Webinoly! ${end}"
}
nginx_tool_site() {
@ -628,15 +581,8 @@ nginx_tool_ssl() {
[[ ! -L /usr/bin/certbot ]] && sudo ln -s /snap/bin/certbot /usr/bin/certbot
conf_write nginx-tool-ssl true
if which certbot >/dev/null ; then
echo "${gre}Let's Encrypt (certbot) has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during Let's Encrypt (certbot) installation!${end}"
fi
api-events_update in6
echo "${gre}Let's Encrypt (certbot) has been installed successfully! ${end}"
}
@ -668,15 +614,8 @@ nginx_tool_bkp() {
sudo chmod 755 /usr/bin/duply
conf_write nginx-tool-bkp true
if which duply >/dev/null && which duplicity >/dev/null ; then
echo "${gre}BackUp packages has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during BackUp packages installation!${end}"
fi
api-events_update in8
echo "${gre}BackUp packages has been installed successfully! ${end}"
}
@ -693,24 +632,12 @@ php_tool_postfix() {
sudo systemctl reload postfix
conf_write php-tool-postfix true
if [[ -d /etc/postfix ]] && systemctl is-active --quiet postfix; then
echo "${gre}Postfix has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during Postfix installation!${end}"
fi
api-events_update ip6
echo "${gre}Postfix has been installed successfully! ${end}"
}
redis_optim() {
if [[ ! -d /etc/redis ]]; then
echo "${red}[ERROR] Redis Optimization process aborted!${end}"
return
fi
local maxmem=$((($(grep MemTotal /proc/meminfo | cut -f 2 -d ':' | tr -d ' ' | cut -f 1 -d 'k')*$(check_var redis-max-mem))/100000))
sudo sed -i "/# maxmemory <bytes>/c\maxmemory ${maxmem}mb" /etc/redis/redis.conf
sudo sed -i "/^maxmemory /c\maxmemory ${maxmem}mb" /etc/redis/redis.conf
@ -727,15 +654,8 @@ php_tool_redis() {
sudo systemctl enable redis-server
conf_write php-tool-redis true
if [[ -d /etc/redis ]] && systemctl is-active --quiet redis-server; then
echo "${gre}Redis has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during Redis installation!${end}"
fi
api-events_update ip8
echo "${gre}Redis has been installed successfully! ${end}"
}
@ -747,15 +667,8 @@ php_tool_memcached() {
sudo apt -y install php${ver}-memcached php${ver}-memcache memcached
conf_write php-tool-memcached true
if systemctl is-active --quiet memcached; then
echo "${gre}Memcached has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during Memcached installation!${end}"
fi
api-events_update ip10
echo "${gre}Memcached has been installed successfully! ${end}"
}
@ -781,13 +694,7 @@ mysql_tool_pma() {
sudo find /var/www/$ADMIN_TOOLS_SITE/htdocs/pma -type d -print0 | sudo xargs -r -0 chmod 755
conf_write mysql-tool-pma true
if [[ -s /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/config.inc.php ]]; then
echo "${gre}phpMyAdmin has been installed successfully! ${end}"
else
# Don't need a flag or anything else, because it will be also detected during verify process!
echo "${red}[ERROR] Unexpected error during phpMyAdmin installation!${end}"
fi
echo "${gre}phpMyAdmin has been installed successfully! ${end}"
else
echo "${red}[ERROR] Downloading phpMyAdmin failed!${end}"
fi
@ -984,7 +891,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 $(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!
[[ ! -s /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 ]] && 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 +913,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 $(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!
[[ ! -s /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 ]] && 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 +930,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 $(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!
[[ ! -s /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 ]] && 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 +948,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 $(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!
[[ ! -s /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 ]] && 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 +957,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 $(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!
[[ ! -s /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 ]] && 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

View file

@ -98,8 +98,6 @@ site_ssl_on() {
elif [[ ! -f /etc/letsencrypt/live/$domain/fullchain.pem && $ssl == "force-renewal" ]]; then
echo "${red}[ERROR] Cert you're trying to renew not found!${end}"
exit 1
elif [[ -n $test_cert ]]; then
echo "${dim}[INFO] This is TEST Cert request! (Don't use it on a real/final site)${end}"
fi
@ -149,14 +147,13 @@ site_ssl_on() {
elif [[ ! -f /etc/letsencrypt/live/$domain/fullchain.pem || $ssl == "force-renewal" ]]; then
if [[ -n $manual ]]; then
sudo certbot certonly --manual --preferred-challenges=$manual $domset $param
echo "${dim}[INFO] Be aware that manual Certs are NOT automatically renewed! (Read the docs for manual renewing process)${end}"
else
sudo certbot certonly --webroot -w /var/www/$path/htdocs/ $domset $param
fi
# Existing cert
elif [[ -f /etc/letsencrypt/live/$domain/fullchain.pem ]]; then
echo "${dim}[INFO] Cert NOT requested because already exist!${end}"
echo "${blu}Certificate for${end} $domain ${blu}already exist and found, wait while we configure your server to use it!${end}"
[[ -z $test_cert && $(is_ssl_staging $domain) == "true" ]] && echo "${red}[WARNING] Cert found is a staging cert for testing.${end}"
[[ -n $test_cert && $(is_ssl_staging $domain) != "true" ]] && echo "${red}[WARNING] Test-Cert was requested and cert found is a real/normal cert.${end}"
fi

View file

@ -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 $(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
if [[ $type == [123] && $(conf_read wp-admin-auth) != "purged" && ! -s /etc/nginx/.htpasswd && ! -s /etc/nginx/apps.d/.htpasswd-$domain ]]; 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
@ -34,7 +34,7 @@ wp_cache_plugins() {
echo "${gre} Nginx Helper Plugin has been installed!"
echo " Please, activate this plugin for a better experience with FastCgi Cache."
echo "${blu} ** IMPORTANT - Plugin Settings **"
echo "- Go to “Menu > Settings > Nginx Helper” The “Caching Method” should be set to “Nginx FastCgi Cache”."
echo "- The “Caching Method” should be set to “Nginx FastCgi Cache”."
echo "- Support for purge/url method is a premium feature only included in NGINX Plus (not-free) and we recommend not to trust in solutions or tools that use third-party NGINX modules to offer this feature."
echo "- The Purge Method should be set to “Delete local server cache file”."
echo "${end}"
@ -161,13 +161,6 @@ wpinstall() {
if [[ $dbhost != "localhost" ]]; then
# DB host validation
is_url $dbhost -split
# Prevent example.com/ cause an error that is really easy to fix, just remove the /
if [[ $url_path == "/" ]]; then
dbhost=${dbhost:0:-1}
is_url $dbhost -split # Reset in case data has changed!
fi
if [[ -n $url_path ]]; then
echo "${red}[ERROR] Invalid database host/port!${dim} (Folders in DB host are not supported: ${dbhost}) ${end}"
url_path=""
@ -206,7 +199,7 @@ wpinstall() {
fi
if [[ $ext_login == "true" ]]; then
echo "${blu}${dim}External DB Credentials found! (${dburl}:${dbport})${end}"
echo "${blu}${dim}External DB Credentials found!${end}"
elif [[ -n $retry && $retry -ge 3 ]]; then
setupmysql="N"
local db_error_flag="true"
@ -602,7 +595,6 @@ deletesite() {
# Delete site files
sudo rm -rf /etc/nginx/apps.d/$domain*.conf
sudo rm -rf /etc/nginx/apps.d/.htpasswd-$domain
sudo rm -rf /etc/nginx/apps.d/.htpasswd-www.$domain
sudo rm -rf /etc/nginx/sites-available/$domain
sudo rm -rf /etc/nginx/sites-enabled/$domain
sudo rm -rf /var/www/$domain
@ -610,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 $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ ! -s /etc/nginx/conf.d/webinoly.conf ]] && 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 $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
[[ ! -s /etc/nginx/conf.d/upstream_proxy.conf ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
fi
echo "${gre}Site${blu} $domain ${gre}has been successfully deleted!${end}"
@ -662,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 $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ ! -s /etc/nginx/conf.d/webinoly.conf ]] && 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}"
@ -676,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 $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
[[ ! -s /etc/nginx/conf.d/upstream_proxy.conf ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
fi
sudo rm -rf /var/www/$domain/htdocs$subfolder
@ -708,7 +700,7 @@ delete_all_sites() {
do
[[ ${delete_all,,} == "keep-db" ]] && delete="keep-db" || delete="force"
domain=$(echo $site | cut -f 5 -d "/")
[[ -f /etc/nginx/sites-available/$domain && $domain != "default" && $domain != $ADMIN_TOOLS_SITE && $domain != *".dpkg-"* ]] && deletesite
[[ $domain != "default" && $domain != $ADMIN_TOOLS_SITE && $domi != *".dpkg-"* ]] && deletesite
done
# Delete all files - double check!
@ -815,7 +807,7 @@ createsite() {
# Activate FastCgi cache
if [[ $cache == "on" && $type == [123] ]]; then
sudo sed -i '/php[x]*\.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
[[ -z $wp_cache_plugins || $wp_cache_plugins == "on" ]] && wp_cache_plugins
echo "${gre}WordPress Cache successfully enabled!${end}"
fi
@ -943,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 $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then
if [[ ! -s /etc/nginx/apps.d/$domain-nginx.conf ]]; then
sudo rm /etc/nginx/apps.d/$domain-nginx.conf
sudo sed -i "/$domain-nginx.conf;/d" /etc/nginx/sites-available/$domain
fi
@ -971,12 +963,8 @@ redirection_manager() {
echo "${red}[ERROR] Please, enter a valid from/to redirection path!${end}"
exit 1
elif [[ $from == "/" ]]; then
if [[ -z $exact ]]; then
echo "${red}[ERROR] Root folder redirection is not allowed, use the 'domain forwarding' feature if want to redirect a complete domain, or use the '-exact' parameter to redirect only the main page and not the complete domain.${end}"
exit 1
else
echo "${dim}[INFO] Use the 'domain forwarding' feature if want to redirect a complete domain!${end}"
fi
echo "${red}[ERROR] Root folder redirection is not allowed, use the 'domain forwarding' feature if want to redirect a complete domain!${end}"
exit 1
elif ! [[ $http_code =~ ^(301|302|303|307|308|403|410|444|451)$ ]]; then
echo "${red}[ERROR] Invalid redirection HTTP Code!${end}"
exit 1
@ -1202,9 +1190,6 @@ parked_domain() {
sudo truncate -s 0 /etc/nginx/sites-available/$domain
sudo cat /etc/nginx/sites-available/$parked > /etc/nginx/sites-available/$domain
# Just in case: Remove Force-Redirect if enabled!
sudo sed -i '/WebinolyWWWredirectStart/,/WebinolyWWWredirectEnd/{/.*/d}' /etc/nginx/sites-available/$domain
# Prevent if SSL is enabled in main site and ssl data is copied to parked site causing an error.
[[ $(is_ssl $parked) == "true" ]] && sudo site $domain -ssl=off -revoke=off -no-db-update > /dev/null 2>&1
@ -1213,8 +1198,8 @@ parked_domain() {
sudo sed -i "/include apps.d\/$parked-nginx.conf/d" /etc/nginx/sites-available/$domain
sudo sed -i "/include \/var\/www\/${parked}\/\*-$(echo $parked | sed "s/[^0-9A-Za-z]/_/g")_parked.conf;/d" /etc/nginx/sites-available/$domain
sudo sed -i "s/$(escaped_string $parked)/$domain/g" /etc/nginx/sites-available/$domain
sudo sed -i "/server_name/c \ $sername" /etc/nginx/sites-available/$domain
sudo sed -i "s/$(escaped_string $parked)/$domain/g" /etc/nginx/sites-available/$domain
sudo sed -i "/include apps.d\/.*-proxy.conf;/{s/$domain/$parked/g}" /etc/nginx/sites-available/$domain
sudo sed -i "/root/c \ root /var/www/$parked/htdocs;" /etc/nginx/sites-available/$domain
@ -1323,15 +1308,14 @@ reverse_proxy() {
elif [[ -f /etc/nginx/sites-available/$domain && -n $dedicated_reverse_proxy && $(is_empty_root_site $domain) != "full" && $(is_dedicated_proxy_domain $domain) != "true" ]]; then
echo "${red}[ERROR] Main site is not a Dedicated Reverse Proxy site!${end}"
exit 1
elif [[ $(is_empty_root_site $domain) == "full" && $(is_dedicated_proxy_domain $domain) == "false" ]]; then
echo "${red}[ERROR] This domain is currently set as Empty (blank), to create a site you need to add your own NGINX configuration. ${dim}(/var/www/example.com/*-nginx.conf)!${end}"
exit 1
elif [[ $dedicated_reverse_proxy != "simple" && -n $url_path ]]; then
# URI part (subfolders) are not allowed because the proxy configuration we are using includes the static files location, this location block is using regex which is not allowed!
# Dedicated reverse proxy are also affected (don't have static file location block), but subfolders are not allowed in upstream servers.
echo "${red}[ERROR] Subfolder in your endpoint or upstream server is not supported!${dim} (URI: $url_path)${end}"
exit 1
elif [[ $(is_empty_root_site $domain) == "full" && $(is_dedicated_proxy_domain $domain) == "false" ]]; then
# In case you have intentionally created an empty site with custom conf, it can interfere.
# We allow it because it should be common having a subfolder and remove it, leaving an empty site that can fully support a new dedicated site.
echo "${red}${dim}[WARNING] This domain already exists and it's currently set as Empty (blank), please be sure not to have had any other custom Nginx configuration added by you that can interfere with this site.${end}"
fi
if [[ ( -z $subfolder || ( -n $subfolder && ! -f /etc/nginx/sites-available/$domain )) && $(is_empty_root_site $domain) == "false" ]]; then
@ -1491,8 +1475,6 @@ wp_cache() {
elif [[ $(is_cache $domain $subfolder) == "proxy" ]]; then
sudo sed -i "/proxy_cache .*;/c \ proxy_cache off;" /etc/nginx/apps.d/$domain$subname-proxy.conf
echo "${gre}Proxy Cache in${blu} $domain$subfolder ${gre}has been disabled!${end}"
[[ -n $reset && -n $subfolder ]] && site $domain -cache=custom -reset -subfolder=$subfolder
[[ -n $reset && -z $subfolder ]] && site $domain -cache=custom -reset
elif [[ -n $subfolder && $(is_cache $domain $subfolder) == "wp" ]]; then
sudo sed -i "/apps.d\/$domain$subname-wpfc.conf;/c \ include apps.d/$domain$subname-php.conf;" /etc/nginx/sites-available/$domain
echo "${gre}FastCGI Cache in${blu} $domain$subfolder ${gre}has been disabled!${end}"
@ -1501,15 +1483,11 @@ wp_cache() {
echo "${gre}FastCGI Cache in${blu} $domain ${gre}has been disabled!${end}"
else
echo "${gre}Nginx Cache is already disabled on your site${blu} $domain${end}"
# Needed to support the reset option even when already off
[[ -n $reset && -n $subfolder ]] && site $domain -cache=custom -reset -subfolder=$subfolder
[[ -n $reset && -z $subfolder ]] && site $domain -cache=custom -reset
fi
elif [[ $cache == "on" ]]; then
api-events_update si8
if [[ $(is_wp $domain $subfolder) == "true" && $(is_cache $domain $subfolder) == "false" ]]; then
[[ -z $subfolder ]] && sudo sed -i '/ common\/php[x]*\.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
[[ -z $subfolder ]] && sudo sed -i '/ common\/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
[[ -n $subfolder ]] && sudo sed -i "/ apps.d\/$domain$subname-php.conf;/c \ include apps.d/$domain$subname-wpfc.conf;" /etc/nginx/sites-available/$domain
if [[ $(is_parked $domain) == "false" && ( ! -d /var/www/$domain/htdocs$subfolder/wp-content/plugins/nginx-helper || ! -d /var/www/$domain/htdocs$subfolder/wp-content/plugins/redis-cache ) ]]; then
if [[ -z $wp_cache_plugins ]]; then
@ -1561,7 +1539,6 @@ wp_cache() {
elif [[ $(is_proxy $domain $subfolder) == "true" && -n $(grep -F "# WebinolyProxyCacheStart" /etc/nginx/apps.d/$domain$subname-proxy.conf) ]]; then
sudo sed -i '/WebinolyProxyCacheStart/,/WebinolyProxyCacheEnd/{/.*/d}' /etc/nginx/apps.d/$domain$subname-proxy.conf
sudo sed -i "/^proxy_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/apps.d/${domain}${subname}-site_custom_cache.conf ]] && sudo rm /etc/nginx/apps.d/${domain}${subname}-site_custom_cache.conf
echo "${gre}Custom Proxy Cache configuration has been successfully removed! ${end}"
elif [[ -f /etc/nginx/apps.d/$domain$subname-${fn}.conf ]]; then
sudo rm /etc/nginx/apps.d/$domain$subname-${fn}.conf
@ -1570,7 +1547,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 $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ -f /etc/nginx/conf.d/webinoly.conf && ! -s /etc/nginx/conf.d/webinoly.conf ]] && 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
@ -1601,8 +1578,10 @@ wp_cache() {
echo "${gre}Custom Proxy Cache in${blu} $domain$subfolder ${gre}has been successfully enabled! ${end}"
elif [[ $(is_cache $domain $subfolder) == "false" ]]; then
[[ -z $subfolder ]] && sudo sed -i "/ common\/php[x]*\.conf/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
[[ -n $subfolder ]] && sudo sed -i "/ apps.d\/$domain$subname-php[x]*\.conf;/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
[[ -z $subfolder ]] && sudo sed -i "/ common\/php.conf/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
[[ -z $subfolder ]] && sudo sed -i "/ common\/phpx.conf/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
[[ -n $subfolder ]] && sudo sed -i "/ apps.d\/$domain$subname-php.conf;/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
[[ -n $subfolder ]] && sudo sed -i "/ apps.d\/$domain$subname-phpx.conf;/c \ include apps.d/$domain$subname-${fn}.conf;" /etc/nginx/sites-available/$domain
# Creates the custom Webinoly Cache File (.cnf) only if not exists.
if [[ ! -f /etc/nginx/apps.d/$domain$subname-${fn}.conf ]]; then
@ -1903,7 +1882,7 @@ list_sites() {
for site in "/etc/nginx/sites-available"/*
do
local domi=$(echo $site | cut -f 5 -d "/")
[[ ! -f /etc/nginx/sites-available/$domi || $domi == "default" || $domi == $ADMIN_TOOLS_SITE || $domi == *".dpkg-"* ]] && continue
[[ $domi == "default" || $domi == $ADMIN_TOOLS_SITE || $domi == *".dpkg-"* ]] && continue
if [[ $list != "true" ]]; then
[[ ${list,,} == "disabled" && -L /etc/nginx/sites-enabled/$domi ]] && continue
@ -2168,6 +2147,6 @@ _EOF_
echo "${red}${dim}[ERROR] Discourage Search Engines WP option not updated! (WP Configuration corrupted)${end}"
fi
echo "${gre}WordPress Environment Type has been set successfully! ${dim}(${env})${end}"
echo "${gre}WordPress Environment Type has been set successfully!${end}"
}

View file

@ -44,7 +44,7 @@ must-staple = True" | tee -a /etc/letsencrypt/cli.ini
for site in "/etc/nginx/sites-available"/*
do
domi=$(echo $site | cut -f 5 -d "/")
[[ -f /etc/nginx/sites-available/$domi && $domi != "html" && $domi != $(conf_read tools-port) && $domi != *".dpkg-"* ]] && sudo sed -i "/#include \/var\/www\//c\ include /var/www/$domi/*-nginx.conf;" /etc/nginx/sites-available/$domi
[[ $domi != "html" && $domi != $(conf_read tools-port) && $domi != *".dpkg-"* ]] && sudo sed -i "/#include \/var\/www\//c\ include /var/www/$domi/*-nginx.conf;" /etc/nginx/sites-available/$domi
done
fi
@ -64,7 +64,7 @@ onetwo_to_onethree() {
for site in "/etc/nginx/sites-available"/*
do
domi=$(echo $site | cut -f 5 -d "/")
[[ -f /etc/nginx/sites-available/$domi && $domi != "html" && $domi != $(conf_read tools-port) ]] && sudo sed -i "/ssl on;/c\ #ssl on;" /etc/nginx/sites-available/$domi
[[ $domi != "html" && $domi != $(conf_read tools-port) ]] && sudo sed -i "/ssl on;/c\ #ssl on;" /etc/nginx/sites-available/$domi
done
# swappines is now included by default in linux optimization.
@ -82,13 +82,13 @@ 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 $(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/apps.d/whitelist-acl.conf && ! -s /etc/nginx/apps.d/whitelist-acl.conf ]] && 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"/*
do
domi=$(echo $site | cut -f 5 -d "/")
if [[ -f /etc/nginx/sites-available/$domi && $domi != "html" && $domi != $(conf_read tools-port) ]]; then
if [[ $domi != "html" && $domi != $(conf_read tools-port) ]]; then
if [[ $(is_proxy $domi) == "true" ]]; then
pat="\t}"
elif [[ $(is_wp $domi) == "true" || $(is_php $domi) == "true" ]]; then

View file

@ -1,7 +1,4 @@
#!/bin/bash
# Example: sudo webinoly -verify
# Example: sudo webinoly -verify=critical
# Example: sudo webinoly -verify -check-for-updates
webinoly_verify() {
@ -234,11 +231,6 @@ if [[ ! -f /usr/bin/stack ]]; then
local ver_one_err="1"
fi
if [[ -n $(conf_read init-error-flag) ]]; then
echo "- [ERROR] This copy of Webinoly is not genuine!"
local ver_one_err="1"
fi
if [[ -z $critical_mode ]]; then
# Check if Webinoly is updated
@ -299,10 +291,6 @@ if [[ -z $critical_mode ]]; then
echo "${dim}- [WARNING] Temporal variable (stack-update) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read mysql-reinstall) ]]; then
echo "${dim}- [WARNING] Temporal variable (mysql-reinstall) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ $ver_one_err == "1" ]]; then
@ -346,11 +334,11 @@ if [[ $(conf_read nginx) == "true" ]]; then
local ver_two_err="1"
fi
else
if [[ ! -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 '[^[:space:]]') ]]; then
if [[ ! -f /usr/share/keyrings/nginx-archive-keyring.gpg || ! -s /usr/share/keyrings/nginx-archive-keyring.gpg ]]; 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 $(cat -v /etc/apt/sources.list.d/nginx.list | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /etc/apt/sources.list.d/nginx.list || ! -s /etc/apt/sources.list.d/nginx.list ]]; then
echo "- [ERROR] Nginx PPA not found in sources list!"
local ver_two_err="1"
fi
@ -573,20 +561,20 @@ 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 $(cat -v /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || ! -s /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg ]]; 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 $(cat -v /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list | grep -m 1 '[^[:space:]]') ]]; 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 ]]; then
echo "- [ERROR] PHP PPA not found in sources list!"
local ver_three_err="1"
fi
else
if [[ ! -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 '[^[:space:]]') ]]; then
if [[ ! -f /usr/share/keyrings/php-archive-keyring.gpg || ! -s /usr/share/keyrings/php-archive-keyring.gpg ]]; 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 $(cat -v /etc/apt/sources.list.d/php.list | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /etc/apt/sources.list.d/php.list || ! -s /etc/apt/sources.list.d/php.list ]]; then
echo "- [ERROR] PHP PPA not found in sources list!"
local ver_three_err="1"
fi
@ -665,14 +653,14 @@ if [[ -z $critical_mode ]]; then
local ver_three_war="1"
fi
if ! [[ $ver_php_ver =~ ^(5.6|7.0|7.1|7.2|7.3|7.4|8.0|8.1|8.2|8.3)$ ]]; then
if ! [[ $ver_php_ver =~ ^(5.6|7.0|7.1|7.2|7.3|7.4|8.0|8.1|8.2)$ ]]; then
echo "${dim}- [WARNING] Unknown PHP version!${end}${red}"
local ver_three_war="1"
elif [[ $ver_php_ver =~ ^(5.6|7.0|7.1|7.2|7.3|7.4|8.0)$ ]]; then
echo "${dim}- [WARNING] You have an obsolete PHP version installed (${ver_php_ver}) that not even receive security updates!${end}${red}"
elif [[ $ver_php_ver =~ ^(5.6|7.0|7.1|7.2|7.3|7.4)$ ]]; then
echo "${dim}- [WARNING] You have an obsolete PHP version (${ver_php_ver}) installed that not even receive security updates!${end}${red}"
local ver_three_war="1"
#elif [[ $ver_php_ver == "8.1" ]]; then
# echo "${blu}${dim}- [INFO] PHP v8.2 or later is recommended to get an optimal perfomance! (Current: ${ver_php_ver}) ${end}${red}"
elif [[ $ver_php_ver == "8.0" ]]; then
echo "${blu}${dim}- [INFO] PHP v8.1 or later is recommended to get an optimal perfomance! (Current: ${ver_php_ver}) ${end}${red}"
fi
fi
@ -697,7 +685,7 @@ local ver_four_err="0"
local ver_four_war="0"
# MySQL/MariaDB
if [[ $(conf_read mysql) == "true" || $(conf_read mysql-client) == "true" ]]; then
if [[ $(conf_read mysql) == "true" ]]; then
# Check if MYSQL command is installed
if ! which mysql >/dev/null ; then
echo "- [ERROR] Seems like MYSQL command is not installed!"
@ -707,9 +695,7 @@ if [[ $(conf_read mysql) == "true" || $(conf_read mysql-client) == "true" ]]; th
echo "- [ERROR] Folder: /etc/mysql not found!"
local ver_four_err="1"
fi
fi
if [[ $(conf_read mysql) == "true" ]]; then
if [[ $(conf_read db-engine) == "mysql" ]]; then
local ver_mysql_ver=$(sudo mysql --version | grep -Eo "Ver [0-9\.]+" | cut -f 2 -d' ' | cut -f 1-2 -d'.')
if [[ -n $(sudo mysql --version | grep -Fio "MariaDb") ]]; then
@ -736,11 +722,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 $(cat -v /usr/share/keyrings/mysql-archive-keyring.gpg | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg || ! -s /usr/share/keyrings/mysql-archive-keyring.gpg ]]; 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 $(cat -v /etc/apt/sources.list.d/mysql.list | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /etc/apt/sources.list.d/mysql.list || ! -s /etc/apt/sources.list.d/mysql.list ]]; then
echo "- [ERROR] MySQL PPA not found in sources list!"
local ver_four_err="1"
fi
@ -754,17 +740,19 @@ if [[ $(conf_read mysql) == "true" ]]; then
local ver_four_err="1"
fi
else
if [[ ! -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 '[^[:space:]]') ]]; then
if [[ ! -f /usr/share/keyrings/mariadb-archive-keyring.gpg || ! -s /usr/share/keyrings/mariadb-archive-keyring.gpg ]]; 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 $(cat -v /etc/apt/sources.list.d/mariadb.list | grep -m 1 '[^[:space:]]') ]]; then
if [[ ! -f /etc/apt/sources.list.d/mariadb.list || ! -s /etc/apt/sources.list.d/mariadb.list ]]; then
echo "- [ERROR] MariaDB PPA not found in sources list!"
local ver_four_err="1"
fi
fi
fi
# MySQL/MariaDB Connection
# MySQL/MariaDB Connection
if [[ $(conf_read mysql) == "true" ]]; then
if [[ -n $(conf_read mysql-root) ]]; then # Dynvar can be removed safely!
local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
[[ -z $ROOT_PASS ]] && ROOT_PASS="dUmb"
@ -868,32 +856,32 @@ fi
local ver_five_err="0"
local ver_five_war="0"
if [[ $(conf_read nginx) == "true" ]] && ! systemctl is-active --quiet nginx; then
if ! systemctl is-active --quiet nginx && [[ $(conf_read nginx) == "true" ]]; then
echo "- [ERROR] Nginx service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read php) == "true" ]] && ! systemctl is-active --quiet php$(conf_read php-ver)-fpm; then
if ! systemctl is-active --quiet php$(conf_read php-ver)-fpm && [[ $(conf_read php) == "true" ]]; then
echo "- [ERROR] PHP service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read mysql) == "true" ]] && ! systemctl is-active --quiet mysql; then
if ! systemctl is-active --quiet mysql && [[ $(conf_read mysql) == "true" ]]; then
echo "- [ERROR] MySQL/MariaDB service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read php-tool-redis) == "true" ]] && ! systemctl is-active --quiet redis-server; then
if ! systemctl is-active --quiet redis-server && [[ $(conf_read php-tool-redis) == "true" ]]; then
echo "- [ERROR] Redis service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read php-tool-memcached) == "true" ]] && ! systemctl is-active --quiet memcached; then
if ! systemctl is-active --quiet memcached && [[ $(conf_read php-tool-memcached) == "true" ]]; then
echo "- [ERROR] Memcached service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read php-tool-postfix) == "true" ]] && ! systemctl is-active --quiet postfix; then
if ! systemctl is-active --quiet postfix && [[ $(conf_read php-tool-postfix) == "true" ]]; then
echo "- [ERROR] Postfix service not running!"
local ver_five_err="1"
fi
if [[ $(conf_read nginx) == "true" ]] && ! sudo nginx -t 2>/dev/null; then
if ! sudo nginx -t 2>/dev/null && [[ $(conf_read nginx) == "true" ]]; then
echo "- [ERROR] Nginx Configuration check failed!"
local ver_five_err="1"
fi
@ -953,18 +941,7 @@ if ! which wget >/dev/null ; then
local ver_six_err="1"
fi
# Check for OS Updates
# Run in non-critical mode and when updating Webinoly to remember that is important to keep the OS updated, not only Webinoly.
# For example, we can implement new Nginx directives and it will fails if Nginx package is not updated.
if [[ -z $critical_mode || -n $check_for_updates ]]; then
if [[ -f /usr/lib/update-notifier/apt-check ]]; then
local ver_os_updates=$(echo $(/usr/lib/update-notifier/apt-check --human-readable) | grep -Eo "[0-9]+ " | head -1 | sed "s/ //")
if [[ $ver_os_updates =~ ^[0-9]+$ && $ver_os_updates -gt 0 ]]; then
echo "${dim}- [WARNING] Operating System is not updated, $ver_os_updates updates can be installed immediately.${end}${red}"
local ver_six_war="1"
fi
fi
fi
if [[ -z $critical_mode ]]; then
# Check for BASH Shell
# This is a very "shity" method, but checking if file exists is very reliable
@ -984,6 +961,15 @@ if [[ -z $critical_mode ]]; then
fi
fi
# Check for updates
if [[ -a /usr/lib/update-notifier/apt-check ]]; then
local ver_os_updates=$(echo $(/usr/lib/update-notifier/apt-check --human-readable) | grep -Eo "^[0-9]+ " | head -1 | sed "s/ //")
if [[ $ver_os_updates =~ ^[0-9]+$ && $ver_os_updates -gt 0 ]]; then
echo "${dim}- [WARNING] Operating System is not updated, $ver_os_updates updates can be installed immediately.${end}${red}"
local ver_six_war="1"
fi
fi
# Check if timezone is set
if [[ -z $(conf_read timezone) ]] || ! grep -Fxq $(conf_read timezone) /opt/webinoly/lib/timezone.dat; then
echo "${dim}- [WARNING] Timezone is not set or not valid!${end}${red}"
@ -1024,14 +1010,14 @@ if [[ $(conf_read php-tool-redis) == "true" ]]; then
# 18.04 - /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg
# 20.04 - /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg
# 22.04 - /usr/share/keyrings/redis-archive-keyring.gpg
if [[ ( ! -f /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg || ! -s /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg || -z $(cat -v /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg | grep '[^[:space:]]') ) && ( ! -f /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg || ! -s /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg || -z $(cat -v /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg | grep '[^[:space:]]') ) && ( ! -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 '[^[:space:]]') ) ]]; then
if [[ ( ! -f /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg || ! -s /etc/apt/trusted.gpg.d/redislabs_ubuntu_redis.gpg ) && ( ! -f /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg || ! -s /etc/apt/trusted.gpg.d/redislabs-ubuntu-redis.gpg ) && ( ! -f /usr/share/keyrings/redis-archive-keyring.gpg || ! -s /usr/share/keyrings/redis-archive-keyring.gpg ) ]]; then
echo "- [ERROR] Redis Apt Key not found!"
local ver_seven_err="1"
fi
# 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 $(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
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 ) && ( ! -f /etc/apt/sources.list.d/redis.list || ! -s /etc/apt/sources.list.d/redis.list ) ]]; then
echo "- [ERROR] Redis PPA not found in sources list!"
local ver_seven_err="1"
fi
@ -1081,7 +1067,7 @@ if [[ -z $critical_mode ]]; then
for cert in "/etc/letsencrypt/live"/*
do
domain=$(echo $cert | cut -f 5 -d "/")
if [[ -d $cert && ! -f /etc/nginx/sites-available/$domain && -n $domain ]]; then
if [[ -d $cert && ! -f /etc/nginx/sites-available/$domain ]]; then
echo "${blu}${dim}- [INFO] SSL Orphan-Cert found ($domain)!${end}${red}"
fi
done
@ -1160,11 +1146,6 @@ if [[ -z $critical_mode ]]; then
local ver_check_dir="/var/www"
local ver_check_user="www-data"
local ver_count_ssh=2
# Always check root when logname user is different!
elif [[ $ver_count_ssh == 2 && $CURRENT_HOME != "/root" ]]; then
local ver_check_dir="/root"
local ver_check_user="root"
local ver_count_ssh=3
else
break
fi
@ -1219,12 +1200,10 @@ if [[ -z $critical_mode ]]; then
for ver_site in "/etc/nginx/sites-available"/*
do
local ver_domi=$(echo $ver_site | cut -f 5 -d "/")
[[ ! -f /etc/nginx/sites-available/$ver_domi ]] && continue # Double check!
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 $(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
if [[ ! -s /etc/nginx/.htpasswd && ! -s /etc/nginx/apps.d/.htpasswd-$ver_domi && $(is_wp_auth $ver_domi) == "true" ]]; then
echo "${blu}${dim}- [INFO] HTTP Authentication Credentials not found for $ver_domi${end}${red}"
fi

View file

@ -30,8 +30,7 @@ system_info() {
echo "${blu}${bol}[NGINX]${end}"
if [[ $(conf_read nginx) == "true" ]]; then
[[ -z $(conf_read nginx-ppa) ]] && local nginxbranch="stable" || local nginxbranch=$(conf_read nginx-ppa)
echo "${blu}Branch:${end}${dim} ${nginxbranch} ${end}"
echo "${blu}Branch:${end}${dim} $(conf_read nginx-ppa) ${end}"
echo "${blu}Version:${end}${dim} $(sudo nginx -v 2>&1 | cut -d'/' -f 2- -s) ${end}"
echo "${blu}worker_processes:${end}${dim} $(grep worker_processes /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';') ${end}"
echo "${blu}worker_connections:${end}${dim} $(grep worker_connections /etc/nginx/nginx.conf | cut -f 2 -d ' ' | tr -d ';') ${end}"
@ -415,13 +414,6 @@ fix_permissions() {
sudo find $CURRENT_HOME/.ssh -path "$CURRENT_HOME/.ssh/*.pub" -type f -print0 | sudo xargs -r -0 chmod 644
sudo chown -R ${CURRENT_USER}:${CURRENT_USER} $CURRENT_HOME/.ssh
fi
# Always check root when logname user is different!
if [[ $CURRENT_HOME != "/root" && -d /root/.ssh ]]; then
sudo find /root/.ssh -type d -print0 | sudo xargs -r -0 chmod 700
sudo find /root/.ssh ! -path "/root/.ssh/*.pub" -type f -print0 | sudo xargs -r -0 chmod 600
sudo find /root/.ssh -path "/root/.ssh/*.pub" -type f -print0 | sudo xargs -r -0 chmod 644
sudo chown -R root:root /root/.ssh
fi
sudo chown -R www-data:www-data /var/www
[[ $(conf_read login-www-data) == "true" ]] && sudo chown root:root /var/www
@ -696,7 +688,7 @@ set_tools_site() {
fi
# Warning Message
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
if [[ ( ! -s /etc/nginx/.htpasswd && $tools_site == "default" ) || ( ! -s /etc/nginx/.htpasswd && $tools_site != "default" && -f /etc/nginx/sites-available/$tools_site && ! -s /etc/nginx/apps.d/.htpasswd-$tools_site ) ]]; then
echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to access these tools!${end}"
fi
}
@ -708,22 +700,13 @@ www_data_sftp_access() {
elif [[ $login_www_data == "off" && $(conf_read login-www-data) != "true" ]]; then
echo "${gre}SFTP access for www-data user is already disabled! ${end}"
elif [[ $login_www_data == "on" ]]; then
# Remove if empty! (prevent empty files with spaces taken as valid)
if [[ -f /var/www/.ssh/authorized_keys && ( ! -s /var/www/.ssh/authorized_keys || -z $(cat -v /var/www/.ssh/authorized_keys | grep -m 1 '[^[:space:]]')) ]]; then
sudo rm -rf /var/www/.ssh/authorized_keys
fi
# Allow access for www-data user
if [[ -f /var/www/.ssh/authorized_keys ]]; then
echo "${blu}${dim}SSH keys already exists in www-data folder!${end}"
elif [[ ! -f /var/www/.ssh/authorized_keys && -f $CURRENT_HOME/.ssh/authorized_keys ]]; then
if [[ -f $CURRENT_HOME/.ssh/authorized_keys ]]; then
echo "${blu}${dim}Copying your SSH keys from '${CURRENT_USER}' to www-data access!${end}"
sudo mkdir -p /var/www/.ssh
sudo chmod 700 /var/www/.ssh
sudo cat $CURRENT_HOME/.ssh/authorized_keys > /var/www/.ssh/authorized_keys
sudo chmod 600 /var/www/.ssh/*
else
echo "${red}${dim}[WARNING] SSH keys not found!${end}"
fi
sudo chown -R www-data:www-data /var/www
@ -750,6 +733,7 @@ Match Group sftponly
echo "${gre}SFTP access for www-data user has been successfuly enabled! ${end}"
elif [[ $login_www_data == "off" ]]; then
sudo rm -rf /var/www/.ssh
sudo sed -i '/www-data:/c\www-data:x:33:33:www-data:\/var\/www:\/usr\/sbin\/nologin' /etc/passwd
sudo gpasswd -d www-data sftponly > /dev/null 2>&1
sudo delgroup sftponly > /dev/null 2>&1
@ -842,7 +826,7 @@ clear_caches() {
sudo redis-cli flushall
echo "${gre}- Redis Cache has been successfully cleared!${end}"
else
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear Redis Cache because is not installed!${end}"
echo "${red}[ERROR] We can not clear Redis Cache because is not installed!${end}"
err_cont=true
fi
fi
@ -853,7 +837,7 @@ clear_caches() {
echo flush_all > /dev/tcp/$memhost/$memport
echo "${gre}- Memcached has been successfully cleared!${end}"
else
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear Memcache because is not installed!${end}"
echo "${red}[ERROR] We can not clear Memcache because is not installed!${end}"
err_cont=true
fi
fi
@ -869,7 +853,7 @@ clear_caches() {
wget --spider --no-check-certificate --timeout=15 -t 1 localhost:$(conf_read tools-port)/php/opcache/ > /dev/null 2>&1 &
echo "${gre}- OpCache has been successfully cleared!${end}"
else
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear OpCache because PHP or NGINX are not installed!${end}"
echo "${red}[ERROR] We can not clear OpCache because PHP or NGINX are not installed!${end}"
err_cont=true
fi
fi
@ -878,7 +862,7 @@ clear_caches() {
sudo rm -Rf /run/nginx-cache/*
echo "${gre}- FastCgi Cache has been successfully cleared!${end}"
else
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear FastCGI Cache because NGINX is not installed!${end}"
echo "${red}[ERROR] We can not clear FastCGI Cache because NGINX is not installed!${end}"
err_cont=true
fi
fi
@ -886,9 +870,6 @@ clear_caches() {
if [[ $(conf_read nginx) == "true" && $(is_cache $clear_cache $subfolder) =~ ^(custom|proxy)$ ]]; then
sudo rm -Rf /run/nginx-cache/$(echo $domain | sed 's/[^0-9A-Za-z]/_/g')$(echo $subfolder | sed "s/\//_/g")
echo "${gre}Custom Nginx Cache for${blu} ${clear_cache}${subfolder} ${gre}has been successfully cleared!${end}"
elif [[ $(is_subfolder $clear_cache $subfolder) == "false" ]]; then
echo "${red}[ERROR] Please, enter a valid site! ${dim}(${clear_cache}${subfolder})${end}"
err_cont=true
elif ! [[ $(is_cache $clear_cache $subfolder) =~ ^(custom|proxy)$ ]]; then
echo "${red}[ERROR] Custom Cache is not enabled for this site!${end}"
err_cont=true
@ -962,7 +943,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 $(cat -v /etc/nginx/conf.d/blockips.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/blockips.conf
[[ -f /etc/nginx/conf.d/blockips.conf && ! -s /etc/nginx/conf.d/blockips.conf ]] && sudo rm /etc/nginx/conf.d/blockips.conf
echo "${gre}The IP address ${blu}'$blockip'${gre} was successfully unblocked!${end}"
else
@ -1081,7 +1062,6 @@ database_import() {
fi
check_external_db_saved
echo "${dim}Wait while we import your db... ${end}"
if [[ -n $external_db ]]; then
external_db_parse
@ -1090,22 +1070,15 @@ database_import() {
exit 1
fi
echo "${dim}Wait while we import your db... ${end}"
sudo mysql --defaults-group-suffix=_${extdb_url}:${extdb_port}_default --connect-timeout=10 -h "$extdb_url" -P "$extdb_port" < $file
if [[ $? == "0" ]]; then
sudo mysql --defaults-group-suffix=_${extdb_url}:${extdb_port}_default --connect-timeout=10 -h "$extdb_url" -P "$extdb_port" -e "FLUSH PRIVILEGES;"
echo "${gre}Database successfully imported!${end}"
else
echo "${red}[ERROR] An error occurred while we tried to import your database!${end}"
fi
sudo mysql --defaults-group-suffix=_${extdb_url}:${extdb_port}_default --connect-timeout=10 -h "$extdb_url" -P "$extdb_port" -e "FLUSH PRIVILEGES;"
echo "${gre}Database successfully imported!${end}"
elif [[ -z $external_db && $(check_mysql_connection localhost) == "true" ]]; then
check_for_mysql -ask
sudo mysql -u admin < $file
if [[ $? == "0" ]]; then
sudo mysql --connect-timeout=10 --user=admin -e "FLUSH PRIVILEGES;"
echo "${gre}Database successfully imported!${end}"
else
echo "${red}[ERROR] An error occurred while we tried to import your database!${end}"
fi
sudo mysql --connect-timeout=10 --user=admin -e "FLUSH PRIVILEGES;"
echo "${gre}Database successfully imported!${end}"
else
echo "${red}[ERROR] A connection can not be established with MySQL/MariaDB localhost!${end}"
exit 1

View file

@ -9,17 +9,8 @@ source /opt/webinoly/lib/general
check_for_parameters $@
api-events_update has
# Only these commands are supported with subfolders
if [[ -n $subfolder && -z $wp_admin && -z $path ]]; then
echo "${red}[ERROR] Subfolder option not supported!${end}"
exit 1
fi
[[ -z $empty_param && -z $h && -z $H && -z $help ]] && ! [[ -n $wp_admin && -z $domain ]] && check_for_nginx -ask
# Check for domain.
if [[ -n $domain && -f /etc/nginx/sites-available/$domain ]]; then
authfile="apps.d/.htpasswd-$domain"
@ -96,7 +87,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 $(cat -v $authfile | grep -m 1 '[^[:space:]]')) ]]; then
if [[ -n $domain && -f /etc/nginx/$authfile && ! -s /etc/nginx/$authfile ]]; then
sudo rm /etc/nginx/$authfile
sudo rm -rf /etc/nginx/apps.d/.htpasswd-www.$domain
fi
@ -212,7 +203,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 $(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/apps.d/whitelist-acl.conf && ! -s /etc/nginx/apps.d/whitelist-acl.conf ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf
echo "${gre}The IP address ${blu}'$whitelist'${gre} was successfully removed from whitelist!${end}"
else
@ -242,7 +233,7 @@ elif [[ -n $path && -n $domain ]]; then
x="1"
while [[ -n $(echo $path | rev | cut -d'/' -f ${x}- -s | rev) ]]
do
if ! [[ $(is_subfolder $domain $(echo $path | rev | cut -d'/' -f ${x}- -s | rev)) =~ ^(true|false|empty)$ ]]; then
if ! [[ $(is_subfolder $domain $(echo $path | rev | cut -d'/' -f ${x}- -s | rev)) =~ ^(true|false)$ ]]; then
echo "${red}[ERROR] Subfolder parameter not found!${end}"
exit 1
fi
@ -327,7 +318,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 $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then
if [[ ! -s /etc/nginx/apps.d/$domain-nginx.conf ]]; 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 +367,7 @@ elif [[ -n $list ]]; then
done
}
fi
[[ ( ! -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}"
[[ ! -s /etc/nginx/$authfile && -z $raw && $list != "raw" ]] && echo "${blu}[Empty] No users were found!${end}"
echo ""
nginx_not="true" # Nginx-Reload not-needed.

View file

@ -19,11 +19,8 @@ waiting_for_log() {
}
# Only these commands are supported with subfolders
if [[ -n $subfolder && -z $wp ]]; then
echo "${red}[ERROR] Subfolder option not supported!${end}"
exit 1
fi
# Logs are for the entire domain, except when WP is in subfolder we need it to set the especific wp-config file.
[[ -n $subfolder && -z $wp ]] && echo "${red}${dim}[WARNING] The subfolder parameter will be ignored!${end}"
# Check for custom "lines" value
@ -329,7 +326,7 @@ elif [[ -n $domain && -f /etc/nginx/sites-available/$domain ]]; then
fi
elif [[ -n $wp ]]; then
echo "${red}[ERROR] Please, enter a valid WP site! ${dim}(${domain}${subfolder})${end}"
echo "${red}[ERROR] WordPress configuration file not found!${end}"
exit 1
# Access and error logs

View file

@ -36,7 +36,7 @@ if [[ -n $wp || -n $mysql ]]; then
[[ $wp == "true" ]] && wp="[true,true,${exth},${dona},${dona},random,wp_,$(conf_read external-dbu),$(conf_read external-dbp)]"
[[ $mysql == "true" ]] && mysql="[${exth},${dona},${dona},random,$(conf_read external-dbu),$(conf_read external-dbp)]"
echo "${blu}${dim}External DB credentials found! (${exth})${end}"
echo "${blu}${dim}External DB credentials found!${end}"
fi
if [[ ( -n $wp && $wp != true ) || ( -n $mysql && $mysql != true ) ]]; then
@ -100,12 +100,11 @@ fi
if [[ -n $subfolder && ! ( $subfolder =~ ^\/([A-Za-z0-9_\/\-]+)?[^\/]$ ) ]]; then
echo "${red}[ERROR] Please, enter a valid value for subfolder!${end}"
exit 1
# Only these commands are supported with subfolders (Parked is not supported, for instance)
elif [[ -n $subfolder && -z $delete && -z $cache && -z $multisite_convert && -z $clone_from && -z $replace_content && -z $wp && -z $html && -z $php && -z $mysql && -z $proxy && -z $env && -z $info ]]; then
echo "${red}[ERROR] Subfolder option not supported!${end}"
exit 1
# Clone-from empty is here to allow -cache=on when cloning a site
elif [[ -n $subfolder && -z $wp && ( $cache == "on" || -n $multisite_convert || -n $replace_content || -n $env ) && $(is_subfolder $domain $subfolder) != "wp" && -z $clone_from ]]; then
elif [[ -n $subfolder && ( $cache == "on" || -n $multisite_convert || -n $replace_content ) && $(is_subfolder $domain $subfolder) != "wp" && -z $clone_from ]]; then
echo "${red}[ERROR] Subfolder not found or is not a WP site!${end}"
exit 1
else
@ -127,11 +126,10 @@ if [[ -n $delete_all ]]; then
elif [[ -n $mysql || ( -n $php && -n $domain ) ]]; then
if [[ -n $domain ]]; then
full_empty_not_allowed
if [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $(is_subfolder $domain $subfolder) != "false" && $(is_subfolder $domain $subfolder) != "empty" ]]; then
if [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $(is_subfolder $domain $subfolder) != "false" ]]; then
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists!${end}"
exit 1
elif [[ -n $subfolder ]]; then
[[ $(is_subfolder $domain $subfolder) == "empty" ]] && echo "${dim}[INFO] Subfolder already exists, but it's empty!${end}"
elif [[ -n $subfolder ]]; then
[[ ! -f /etc/nginx/sites-available/$domain ]] && create_empty_site
php_subfolder
sudo mkdir -p /var/www/$domain/htdocs$subfolder
@ -155,7 +153,7 @@ elif [[ -n $mysql || ( -n $php && -n $domain ) ]]; then
# Create EMPTY site
elif [[ -n $empty && -n $domain ]]; then
full_empty_not_allowed
echo "${blu}You've created an EMPTY site, which means that you need to add your own NGINX configuration. ${dim}(/var/www/${domain}/*-nginx.conf)${end}"
echo "${blu}You've created an EMPTY site, which means that you need to add your own NGINX configuration. ${dim}(/var/www/example.com/*-nginx.conf)${end}"
[[ $empty == "blank" ]] && create_empty_site -full || create_empty_site
@ -163,7 +161,7 @@ elif [[ -n $empty && -n $domain ]]; then
elif [[ -n $html && -n $domain ]]; then
full_empty_not_allowed
if [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $(is_subfolder $domain $subfolder) != "false" ]]; then
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists! ${dim}(Just put the HTML files in it, a separate conf is not needed)${end}"
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists!${end}"
exit 1
fi
@ -199,15 +197,8 @@ elif [[ -n $wp && -n $domain ]]; then
[[ -n $env ]] && sudo site $domain -env=$env
else
if [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $type == [123] && $(is_subfolder $domain $subfolder) != "false" ]]; then
# Check if subfolder is empty!
if [[ $(is_subfolder $domain $subfolder) == "empty" ]]; then
# Install WP in an empty folder!
echo "${dim}[INFO] Subfolder already exists, but it's empty!${end}"
wpinstall
else
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists and it's not empty!${end}"
exit 1
fi
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists!${end}"
exit 1
elif [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $type == [123] ]]; then
wpinstall
else

View file

@ -13,13 +13,6 @@ check_for_parameters $@
api-events_update wys
# Only these commands are supported with subfolders
if [[ -n $subfolder && -z $clear_cache && -z $backup ]]; then
echo "${red}[ERROR] Subfolder option not supported!${end}"
exit 1
fi
if [[ -n $update ]]; then
api-events_update wy1
webinoly_update
@ -43,7 +36,6 @@ elif [[ -n $verify ]]; then
webinoly_verify
[[ $? != 0 ]] && exit 1
nginx_not="true" # Nginx-Reload not-needed.
[[ $verify == "critical" ]] && ads_block="true" # Don't show ads
elif [[ -n $dbpass ]]; then
@ -264,7 +256,6 @@ elif [[ -n $datadog ]]; then
elif [[ -n $db_import ]]; then
check_for_mysql
database_import
nginx_not="true" # Nginx-Reload not-needed.

39
weby
View file

@ -113,7 +113,6 @@ if [[ -n $ver ]]; then
if [[ $code == 200 ]]; then
sudo wget --timeout=15 -t 1 -qrO $HOME/webinoly.tar https://qrok.es/webinoly?version=$ver
[[ $ver == "beta" ]] && echo "$(tput setaf 1)[WARNING] You are installing a BETA version of Webinoly and it's not recommended for production enviroments.$(tput sgr0)"
type="Custom"
else
echo "$(tput setaf 1)[ERROR] Version not found or not available! ($code) $(tput sgr0)"
sudo rm weby
@ -158,19 +157,6 @@ if [[ -f /opt/webinoly/webinoly.conf ]]; then
oldver=$(conf_read server-version)
newver=$svr_version
echo "${gre}${dim}Webinoly Configuration file was found, so we will use it!${end}"
# Reinstall after uninstalled! (Can be considered new)
if [[ -z $update ]] && ! [[ $ver =~ ^(alpha|beta)$ ]]; then
new_install="true"
echo "${blu}${dim}It seems like you're reinstalling Webinoly! (Upgrading from: ${oldapp})${end} ${blu}${bol}Welcome back!!!${end}"
# Downgrade!
elif [[ -n $update && $type == "Custom" ]]; then
echo "${blu}Updating to the latest version is always recommended! ${dim}(Downgrade to: ${ver})${end}"
fi
elif [[ $type == "Custom" ]]; then
echo "${blu}Custom version installed: ${ver}${end}"
else
new_install="true"
fi
@ -179,10 +165,7 @@ fi
# Write app version
webyversion=$app_version
conf_write app-version $webyversion
if [[ $ver =~ ^(alpha|beta)$ ]]; then
conf_write branch $ver
echo "${blu}${bol}This is a testing version, please don't use it in production!${end}"
fi
[[ $ver =~ ^(alpha|beta)$ ]] && conf_write branch $ver
# Ping to Webinoly Stats
@ -194,19 +177,19 @@ if [[ $statskip != "true" ]]; then
type="New"
elif [[ $ver == "beta" ]]; then
type="Beta"
elif [[ -n $update && $type == "Custom" ]]; then
elif [[ -n $update && $ver =~ ^[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then
type="Downgrade"
webyversion=$(wget --timeout=10 -t 1 -qO- https://api.webinoly.com/check?text=true)
opt=$ver
elif [[ -n $setup && $ver =~ ^[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then
type="Custom"
webyversion=$(wget --timeout=10 -t 1 -qO- https://api.webinoly.com/check?text=true)
opt=$ver
elif [[ -n $update && -n $oldapp ]]; then
type="Updates"
opt=$oldapp
elif [[ $type == "Custom" ]]; then
webyversion=$(wget --timeout=10 -t 1 -qO- https://api.webinoly.com/check?text=true)
opt=$ver
else
type="Error"
conf_write init-error-flag true
echo "${red}[ERROR] Installation method not recognized!${end}"
fi
@ -222,16 +205,10 @@ fi
[[ $setup == 1 ]] && stack -nginx
[[ $setup == 2 ]] && stack -php=nginx
[[ $setup == 3 ]] && stack -lemp
# Verify installation!
if [[ $setup != [123] && -n $update && -n $oldapp ]]; then
sudo webinoly -verify=critical -check-for-updates
elif [[ $setup != [123] ]]; then
sudo webinoly -verify=critical
fi
[[ $setup != [123] ]] && sudo webinoly -verify=critical
# Message Center
if [[ -z $(conf_read stack-build-error-flag) && $type != "Error" ]]; then # We use $type instead of dynvar to not make it persistant!
if [[ -z $(conf_read stack-build-error-flag) ]]; then
if [[ $new_install == "true" && $setup == 0 ]]; then
echo "${blu}You have chosen the option '0', it means that you have to manually build your own stack."
echo "But, don't worry! With Webinoly this is an easy task, just use the stack command, i.e. 'sudo stack -lemp' ${end}"