Compare commits

..

40 commits

Author SHA1 Message Date
Cristhian Martínez Ochoa
1e9eda764a messages
More messages improved.
2024-02-26 19:23:31 -07:00
Cristhian Martínez Ochoa
88e7581511 messages
Messages improved for a better experience.
2024-02-24 10:53:49 -07:00
Cristhian Martínez Ochoa
af49aaf3ae import db
Fixed successfull message even when error.
Also, missing mysql package check.
2024-02-23 11:44:05 -07:00
Cristhian Martínez Ochoa
8fb402d039 www-data ssh
better check for ssh keys in www-data login access.
2024-02-21 20:14:10 -07:00
Cristhian Martínez Ochoa
81c315e829 ssl messages
Improved messages for SSL.
2024-02-20 16:47:20 -07:00
Cristhian Martínez Ochoa
72de42e9b6 info
Fixed - nginx branch empty.
2024-02-19 17:37:12 -07:00
Cristhian Martínez Ochoa
ded051a70d slash
Better support for root domain options.
2023-11-30 12:48:31 -07:00
Cristhian Martínez Ochoa
ec95bb3c7d subfolder
subfolder support improved.
2023-11-28 13:05:25 -07:00
Cristhian Martínez Ochoa
f5dc8020ea loops
Double check for loops.
Datadog fixed.
2023-11-27 20:52:03 -07:00
Cristhian Martínez Ochoa
fd00a8b182 backups
Minor refactored code.
2023-11-27 16:22:05 -07:00
Cristhian Martínez Ochoa
3870484a72 php
8.3 support added.
2023-11-26 16:48:36 -07:00
Cristhian Martínez Ochoa
380f3a8dad fixes
Clear cache now check if package is installed to not show an error.
Symlink not removed when http auth is using per domain users.
2023-11-02 16:32:54 -07:00
Cristhian Martínez Ochoa
6debbfc634 hotfix
Error detecting empty files.
2023-10-19 18:05:33 -07:00
Cristhian Martínez Ochoa
22bd82213a hotfix
AWS IAM Roles failing with backups.
Installer fixed for wrng errors displayed.
2023-10-06 16:35:14 -07:00
Cristhian Martínez Ochoa
8a06fb6485 test
Small fix
2023-09-29 20:56:09 -07:00
Cristhian Martínez Ochoa
0bd87a4969 blank
Now we are sure every file is removed when empty.
2023-09-29 15:20:27 -07:00
Cristhian Martínez Ochoa
438bf832bb permissions
Always check root when logname user is different!
2023-09-27 16:42:18 -07:00
Cristhian Martínez Ochoa
5f9ebaecc1 subfolders
Improved experience for subfolders.
2023-09-26 16:28:40 -07:00
Cristhian Martínez Ochoa
7306dcdc95 php info
PHP Info support for custom cases, prevent failing.
2023-09-21 13:51:03 -07:00
Cristhian Martínez Ochoa
7de09c3460 subfolders
Now we can create a new site conf in /one when is empty, even when /one/two exists.
2023-09-20 17:20:04 -07:00
Cristhian Martínez Ochoa
5cb6de8df6 proxy
Reverse proxy now allows add a site directly in an empty site domain. For example, after a subfolder has been deleted.
2023-09-18 16:47:09 -07:00
Cristhian Martínez Ochoa
a9d36d7a67 installation messages
Now we verify installation messages before displayed.
2023-09-17 17:06:32 -07:00
Cristhian Martínez Ochoa
6bd295d8fb repeated package
Repeated packaged removed.
2023-09-14 16:09:58 -07:00
Cristhian Martínez Ochoa
e378f4e494 php
PHP 8.2 is now default!
2023-06-22 10:57:13 -07:00
Cristhian Martínez Ochoa
2baf0a9e9d sites
Fixed - Parked sites nginx error when main site has the force redirect option enabled.
Fixed - Create WP site with subfolder failing when cache parameter is passed in the same line and main site exists.
Fixed - Reset custom cache not working in proxy sites.
Improved - Reset custom cache now works even when cache is already disabled.
2023-06-22 07:43:02 -07:00
Cristhian Martínez Ochoa
d0891dc095 updates
Check for OS updates when Webinoly is updated.
Fixed the check for updates function failing in verify.
2023-06-16 10:30:16 -07:00
Cristhian Martínez Ochoa
eb5f32a3f8 fixes
Fixed: Multisite not working!
Fixed: Parked failing with some subdomains.
2023-06-14 13:49:06 -07:00
Cristhian Martínez Ochoa
7270636513 versions
PHP and MariaDB default versions raised.
2023-06-11 08:54:56 -07:00
Cristhian Martínez Ochoa
4a1eb9ae98 internal api
Better documented.
2023-06-11 08:53:56 -07:00
Cristhian Martínez Ochoa
ac8a76e2b5 ads fix
Ads should not be displayed when running via cron.
2023-06-10 10:52:30 -07:00
Cristhian Martínez Ochoa
2695a76164 mysql upgrade
Fixed some small errors displayed when upgrading mysql.
2023-06-05 11:07:20 -07:00
Cristhian Martínez Ochoa
ce9279ab47 verify
Verify process improved and updated.
2023-06-02 12:39:56 -07:00
Cristhian Martínez Ochoa
059456ee19 fixes
Small fixes after testing.
2023-05-30 16:15:21 -07:00
Cristhian Martínez Ochoa
2709ad9f6d template
Better message in some internal templates.
2023-05-28 16:40:30 -07:00
Cristhian Martínez Ochoa
1042833c3d stack
- Fixed - PHP install asking for Nginx when PHP is already installed.
- Fixed - When mysql-client alone an error is displayed when check connection for external db.
2023-05-28 11:49:31 -07:00
Cristhian Martínez Ochoa
58b048bc28 webinoly
- FIX timezone dynvar overwriting with wrong or empty values.
- FIX Custom cache file not removed when empty.
2023-05-26 11:22:14 -07:00
Cristhian Martínez Ochoa
8521ff0e74 log
Subfolder parameter is ignored, except for wp.
2023-05-25 16:51:18 -07:00
Cristhian Martínez Ochoa
cc17ed8c2a ads
Donation reminder once a day.
2023-05-25 15:09:19 -07:00
Cristhian Martínez Ochoa
84a1c29c87 internal api
Internal API and events, codes updated.
2023-05-23 15:18:06 -07:00
Cristhian Martínez Ochoa
8cf1b6e716 blackhole
FIX - nginx warn protocol options redefined for...
2023-05-21 11:20:37 -07:00
18 changed files with 680 additions and 239 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.1 and support for earlier versions if needed (8.0 and 7.4) or the newest 8.2.
- PHP v8.2 and support for earlier versions if needed (8.1, 8.0 and 7.4).
- 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,12 +1,25 @@
#!/bin/bash
# Internal API or Events
# Docs: https://webinoly.com/en/internal-api-events/
# Internal API/Events
# Docs: https://webinoly.com/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. Just rename this file to "api-events" and check for the complete list of status codes in the documentation.
# 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
# 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,8 +67,13 @@ 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
if [[ -n $dbq && -f /etc/nginx/sites-available/$dbq ]]; then
wp=$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
elif [[ -n $dbq ]]; then
dbname=$dbq
wp=""
@ -83,7 +88,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)${end}"
echo "${red}[ERROR] Please, enter a valid WP site! ${dim}(${wp}${subfolder})${end}"
exit 1
else
wp_conf_retrieve $wp true true $subfolder
@ -214,16 +219,8 @@ 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 [[ ! -s $HOME/.aws/credentials && $(conf_read awsiamrole) != true ]]; then
if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(cat -v $HOME/.aws/credentials | grep -m 1 '[^[:space:]]')))) && $(conf_read awsiamrole) != true ]]; then
echo "${red}[ERROR] AWS S3 Credentials not found!${end}"
exit 1
fi
@ -238,14 +235,19 @@ 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 "=" )
@ -265,14 +267,10 @@ 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}"
@ -294,8 +292,6 @@ 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 ""
@ -310,22 +306,27 @@ 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
check_duply_profile
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
[[ $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
fi
if [[ $(wp_config_read $add_db_pre DB_HOST $subfolder) != "localhost" && -z $(conf_read external-dbu) && -z $(conf_read external-dbp) ]]; then
elif [[ $(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
@ -403,7 +404,7 @@ bkp_s3_list() {
s3_send() {
if [[ ! -s $HOME/.aws/credentials && $(conf_read awsiamrole) != true ]]; then
if [[ ( ! -f $HOME/.aws/credentials || ( -f $HOME/.aws/credentials && ( ! -s $HOME/.aws/credentials || -z $(cat -v $HOME/.aws/credentials | grep -m 1 '[^[:space:]]')))) && $(conf_read awsiamrole) != true ]]; then
echo "${red}[ERROR] AWS S3 Credentials not found!${end}"
exit 1
fi
@ -778,7 +779,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 [[ $(is_wp $siteto $suby) == "true" ]]; then
if [[ -n $suby && $(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
@ -960,7 +961,7 @@ _EOF_
import_server() {
[[ -z $file || $file == "true" ]] && read -p "${blu}Path file to import: ${end}" file
if [[ ! -s $file ]]; then
if [[ ! -f $file || ( -f $file && ( ! -s $file || -z $(cat -v $file | grep -m 1 '[^[:space:]]'))) ]]; then
echo "${red}[ERROR] File not found or empty!${end}"
exit 1
elif ! [[ $import =~ ^(true|sites|stack|full)$ ]]; then
@ -1086,8 +1087,13 @@ bkp_wizard() {
elif [[ $wzd == 8 ]]; then
bkp_s3_list
elif [[ $wzd == 9 ]]; then
read -p "${blu}Site to export: ${end}" site
sudo webinoly -backup=local -export=$site
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
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
local path="/etc/logrotate.d/mysql-server"
[[ -f /etc/logrotate.d/mariadb ]] && local path="/etc/logrotate.d/mariadb" || 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 ]]; then
if [[ -n $path && -n $owner && -f $path ]]; 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.2"
readonly app_version="1.17.9"
readonly svr_version="1.8"
readonly os_ubuntu_supported=(bionic focal jammy) # https://ubuntu.com/about/release-cycle
readonly php_supported=(7.4 8.0 8.1 8.2) # https://www.php.net/supported-versions.php
readonly php_default="8.1"
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 mariadb_supported=(10.6 10.11) # https://mariadb.com/kb/en/mariadb-server-release-dates/
readonly mariadb_default="10.6"
readonly mariadb_default="10.11"
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
echo "${red}[ERROR] Config file not found!${end}"
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then # Double check!
echo "${red}[ERROR] Webinoly Configuration file not found!${end}"
exit 1
fi
@ -41,8 +41,8 @@ conf_read() {
}
conf_delete() {
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then
echo "${red}[ERROR] Config file not found!${end}"
if [[ ! -f /opt/webinoly/webinoly.conf ]]; then # Double check!
echo "${red}[ERROR] Webinoly Configuration 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
@ -353,6 +353,9 @@ check_mysql_connection() {
# External DB if login group exist: $(check_mysql_connection $extdb_url $extdb_port $wp_dbuser -login-file $wp_dbname)
# 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)
local query="quit"
local error_display="true"
@ -389,13 +392,17 @@ password = $4
sudo mysql --defaults-group-suffix=_${suffix_group_name} --connect-timeout=10 -h "$1" -P "$2" $user_param -e "$query" 2>/dev/null
if [[ $? != "0" ]]; then
local out="false"
sudo sed -i "/\[client_${suffix_group_name}\]/,/# ClientEnd/{/.*/d}" $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf
[[ -f $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf ]] && sudo sed -i "/\[client_${suffix_group_name}\]/,/# ClientEnd/{/.*/d}" $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf
else
# Display a warning message when not enough privileges!
if [[ $5 == "-master-admin" ]]; then
local priv=$(sudo mysql --defaults-group-suffix=_${suffix_group_name} --connect-timeout=10 -h "$1" -P "$2" -e "SHOW GRANTS FOR CURRENT_USER();")
if ! [[ -n $(echo $priv | grep -Fo "WITH GRANT OPTION") && ( -n $(echo $priv | grep -Fo "GRANT ALL PRIVILEGES") || ( -n $(echo $priv | grep -Fo "CREATE USER") && -n $(echo $priv | grep -Fo "ALTER"))) ]]; then
echo "${red}${dim}[WARNING] Seems like '$(echo $priv | grep -oP -m 1 'Grants for \K\w+')' is not a Master user!${end}" >&2
if [[ $(conf_read quiet) != "true" ]]; then
echo "${red}${dim}[WARNING] Seems like '$(echo $priv | grep -oP -m 1 'Grants for \K\w+')' is not a Master user!${end}" >&2
else
local master_priv="false"
fi
fi
fi
fi
@ -425,7 +432,7 @@ password = $4
local out="false"
fi
if [[ $out == "false" && $error_display != "false" ]]; then
if [[ $out == "false" && $error_display != "false" && $(conf_read quiet) != "true" ]]; then
echo "${red}===================================================" >&2
echo " [Error] Database conection failed! (${1})" >&2
echo "===================================================${end}" >&2
@ -434,7 +441,7 @@ password = $4
elif [[ $out == "false" ]]; then
echo "false"
else
echo "true"
[[ $master_priv == "false" ]] && echo "truebutnotmaster" || echo "true"
fi
}
@ -442,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!${end}" >&2
[[ $(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
fi
}
@ -670,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!${end}" >&2
echo "${blu}${dim}External DB Credentials found! (${wp_dbhost})${end}" >&2
fi
fi
@ -685,6 +692,8 @@ 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
@ -1166,7 +1175,9 @@ is_subfolder() {
echo "proxy"
elif [[ $(is_html $1 $2) == "true" ]]; then
echo "html"
elif [[ -d /var/www/$1/htdocs/$2 ]]; then
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
echo "true"
else
echo "false"
@ -1484,6 +1495,10 @@ mysql_default_cnf() {
sudo chown -R root:root $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly.cnf
echo "# Webinoly MySQL/MariaDB Configuration File
######################################################################
# Webinoly (This configuration file is only for internal use) #
# Please, DO NOT MODIFY this file, it can cause unexpected behavior. #
######################################################################
[mysqld]
log_error = /var/log/mysql/error.log" >> $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly.cnf
fi
@ -1496,6 +1511,10 @@ mysql_login_cnf() {
sudo chown -R root:root $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf
echo "# Webinoly MySQL/MariaDB Login Configuration File
######################################################################
# Webinoly (This configuration file is only for internal use) #
# Please, DO NOT MODIFY this file, it can cause unexpected behavior. #
######################################################################
" >> $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf
fi
@ -1782,7 +1801,7 @@ custom_cache_global() {
[[ -n $skip_cache ]] && local value=$skip_cache
sudo sed -Ei "/^# Value: $(escaped_string $value)( .*)?$/,/^# CacheRuleEnd/{/.*/d}" $confile
[[ ! -s $confile ]] && sudo rm $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!
fi
echo "${gre}Cache rule successfully removed!${end}"
else
@ -1928,3 +1947,23 @@ help_message() {
echo "${dim}Link: https://webinoly.com/documentation/ ${end}"
echo ""
}
ads_donate() {
# Donations message displayed once a day!
# Note: Don't run when stdout is redirected to /dev/null: https://unix.stackexchange.com/questions/484228/how-to-check-if-stdin-is-dev-null-from-the-shell
if [[ -z $(conf_read cron-ads) && -n $EPOCHSECONDS ]]; then
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
echo "${blu}"
echo "****************************************************************************"
echo "******************** ${bol}Are you enjoying Webinoly?${end}${blu} ********************"
echo "*** ${dim}With just \$1 you can make a difference to keep this project alive!${end}${blu} ***"
echo "*********** ${bol}Donate Now!${end}${blu}${dim} https://github.com/sponsors/QROkes${end}${blu} ***********"
echo "****************************************************************************"
echo "${end}"
conf_write cron-ads $EPOCHSECONDS
fi
}

View file

@ -22,13 +22,13 @@ fi
linux_optim() {
api-events_update in4
api-events_update ic1
[[ $(conf_read linux-optim) == "true" ]] && return
# Kernel Optimization
if [[ $(conf_read kernel-optim) != "false" ]]; then
echo "${gre}Wait while Webinoly optimize your Ubuntu Operating System...${end}"
api-events_update in5
api-events_update ic2
[[ -f /etc/sysctl.d/90-webinoly.conf ]] && sudo rm -rf /etc/sysctl.d/90-webinoly.conf
sudo cp /opt/webinoly/templates/general/sysctl /etc/sysctl.d/90-webinoly.conf
sudo modprobe tcp_bbr
@ -82,7 +82,7 @@ linux_optim() {
# Also: 'sudo service procps force-reload' but we prefer this method to better display errors (just in case)
sudo sysctl -p -q /etc/sysctl.d/90-webinoly.conf
api-events_update in6
api-events_update ic3
fi
# File directors per process
@ -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 ]] && sudo echo "[Service]
[[ ! -s /etc/systemd/system/nginx.service.d/nofile_limit.conf || -z $(cat -v /etc/systemd/system/nginx.service.d/nofile_limit.conf | grep -m 1 '[^[:space:]]') ]] && sudo echo "[Service]
LimitNOFILE=$fd_per_process" >> /etc/systemd/system/nginx.service.d/nofile_limit.conf
# Disable Transparent Huge Pages
@ -133,7 +133,7 @@ WantedBy=multi-user.target" >> /etc/systemd/system/webinoly-disable-thp.service
sudo systemctl daemon-reload
[[ $(conf_read nginx) == "true" ]] && sudo systemctl restart nginx # We need to kill the process, don't use reload
conf_write linux-optim true
api-events_update in9
api-events_update ic6
}
@ -188,7 +188,14 @@ nginx_install() {
sudo nginx -t && sudo systemctl start nginx
sudo systemctl enable nginx
conf_write nginx true
echo "${gre}Nginx has been installed successfully! ${end}"
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
api-events_update in2
}
@ -203,16 +210,23 @@ 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}-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
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
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}"
}
mysql_install() {
api-events_update im1
api-events_update im3
echo "${gre}MySQL/MariaDB version '$(conf_read mysql-ver)' is set as default.${end}"
# debconf-utils for unattended scripts
@ -230,7 +244,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 )
local reinstall="true"
conf_write mysql-reinstall true
fi
# MySQL/MariaDB Installation
@ -249,13 +263,6 @@ 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
@ -263,7 +270,9 @@ mysql_install() {
# - Remove anonymous-user accounts.
# - Delete the test database, accessible by anonymous users.
# - Reload the user privileges tables.
sudo mysql --user=root <<_EOF_
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_
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;
@ -273,29 +282,48 @@ 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;"
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
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 im2
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
api-events_update im3
echo "${gre}MySQL/MariaDB Client has been successfully installed!${end}"
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
}
#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/
@ -408,8 +436,8 @@ location = /xmlrpc.php {
conf_write server-version $svr_version
conf_write nginx-optim true
sudo systemctl reload nginx
api-events_update in10
echo "${gre}Nginx has been successfully Optimized by Webinoly! ${end}"
api-events_update in4
}
@ -417,9 +445,13 @@ 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/
@ -469,14 +501,19 @@ 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
api-events_update ip4
echo "${gre}PHP has been successfully Optimized by Webinoly! ${end}"
api-events_update ip4
}
# 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
@ -504,9 +541,19 @@ 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
api-events_update im6
echo "${gre}MySQL/MariaDB has been successfully Optimized by Webinoly! ${end}"
api-events_update im6
}
nginx_tool_site() {
@ -561,7 +608,7 @@ php_tool_site() {
nginx_tool_ssl() {
api-events_update in11
api-events_update in5
# Install LetsEncrypt
local certb=0
@ -581,13 +628,20 @@ nginx_tool_ssl() {
[[ ! -L /usr/bin/certbot ]] && sudo ln -s /snap/bin/certbot /usr/bin/certbot
conf_write nginx-tool-ssl true
api-events_update in12
echo "${gre}Let's Encrypt (certbot) has been installed successfully! ${end}"
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
}
nginx_tool_bkp() {
api-events_update in13
api-events_update in7
# Instalar Duply & Duplicity with S3 support
# Now there is an Official PPA: https://launchpad.net/~duplicity-team/+archive/ubuntu/duplicity-release-git
@ -614,8 +668,15 @@ nginx_tool_bkp() {
sudo chmod 755 /usr/bin/duply
conf_write nginx-tool-bkp true
api-events_update in14
echo "${gre}BackUp packages has been installed successfully! ${end}"
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
}
@ -632,12 +693,24 @@ 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
@ -654,8 +727,15 @@ 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}"
}
@ -667,8 +747,15 @@ 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}"
}
@ -694,7 +781,13 @@ 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
echo "${gre}phpMyAdmin has been installed successfully! ${end}"
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
else
echo "${red}[ERROR] Downloading phpMyAdmin failed!${end}"
fi
@ -742,7 +835,7 @@ swap_create() {
# https://help.ubuntu.com/community/SwapFaq
if [[ -z $sw || $sw == "0" ]]; then
api-events_update in7
api-events_update ic4
if [[ -n $(conf_read swap-mem) && $(conf_read swap-mem) =~ ^[0-9]+$ ]]; then
local newswap=$(conf_read swap-mem)
elif [[ $ram -le 2 ]]; then
@ -805,7 +898,7 @@ swap_create() {
conf_write swap-owner webinoly
echo "${gre}A new SWAP file (${newswap}Gb) has been created! ${end}"
fi
api-events_update in8
api-events_update ic5
elif [[ -n $sw && $sw =~ ^[0-9]+$ ]]; then
[[ $(conf_read swap-owner) != "webinoly" ]] && conf_write swap-owner system
echo "${gre}SWAP file (${sw}Gb) detected!${end}"
@ -816,6 +909,7 @@ swap_create() {
message_welcome() {
# Only displayed once, when pre-pack is installed!
echo "${blu}"
echo "***************************************************************"
echo "***************** ${bol}Welcome to Webinoly ${end}${blu}*********************"
@ -856,10 +950,10 @@ stack_builder() {
# Set Welcome Message
[[ -n $4 ]] && local mess=$4 || local mess="partial" # We trust in build variable validation
[[ -n $lemp && -z $4 ]] && local mess="full"
message_welcome $mess
message_welcome $mess # Only displayed once, when pre-pack is installed!
# Any action run after the meesage is displayed!
api-events_update i1
api-events_update ics
sudo apt -qq update
# Usually comes by default with Ubuntu. Ensure we have it always! (software-properties-common debconf-utils zip)
@ -873,10 +967,11 @@ stack_builder() {
linux_optim
conf_write pre-packs true
api-events_update i2
api-events_update ice
fi
# PPA's
api-events_update iks
if [[ $1 == "nginx" && $(conf_read nginx) != "true" ]]; then
[[ $nginx =~ ^(stable|mainline)$ ]] && conf_write nginx-ppa $nginx
[[ $lemp =~ ^(stable|mainline)$ ]] && conf_write nginx-ppa $lemp
@ -889,7 +984,7 @@ stack_builder() {
echo | sudo add-apt-repository "deb https://nginx.org/packages/ubuntu/ $(check_osname) nginx"
fi
else
[[ ! -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 && ( ! -s /usr/share/keyrings/nginx-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/nginx-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/nginx-archive-keyring.gpg # Prevent issues!
[[ ! -f /usr/share/keyrings/nginx-archive-keyring.gpg ]] && wget -nv -O- https://nginx.org/keys/nginx_signing.key | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg
if [[ $(conf_read nginx-ppa) == "mainline" ]]; then
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/mainline/ubuntu/ $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
@ -897,7 +992,9 @@ stack_builder() {
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] https://nginx.org/packages/ubuntu/ $(lsb_release -cs) nginx" | sudo tee /etc/apt/sources.list.d/nginx.list
fi
fi
local code="run"
api-events_update ikn
elif [[ $1 == "nginx" ]]; then
echo "${dim}Nginx is already installed!${end}"
local code=0
@ -909,11 +1006,12 @@ stack_builder() {
#sudo apt install -y language-pack-en-base
sudo LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php
else
[[ ! -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 && ( ! -s /usr/share/keyrings/php-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/php-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/php-archive-keyring.gpg # Prevent issues!
[[ ! -f /usr/share/keyrings/php-archive-keyring.gpg ]] && wget -nv -O- 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x14aa40ec0831756756d7f66c4f4ea0aae5267a6c' | sudo gpg --dearmor -o /usr/share/keyrings/php-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/php-archive-keyring.gpg] https://ppa.launchpadcontent.net/ondrej/php/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/php.list
fi
api-events_update ikp
local code="run"
elif [[ $2 == "php" ]]; then
echo "${dim}PHP is already installed!${end}"
@ -925,11 +1023,12 @@ 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
[[ ! -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 && ( ! -s /usr/share/keyrings/redis-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/redis-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/redis-archive-keyring.gpg # Prevent issues!
[[ ! -f /usr/share/keyrings/redis-archive-keyring.gpg ]] && wget -nv -O- https://packages.redis.io/gpg | sudo gpg --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
fi
api-events_update ikr
local code="run"
fi
@ -942,7 +1041,7 @@ stack_builder() {
fi
if [[ $(conf_read db-engine) == "mysql" ]]; then
[[ ! -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 && ( ! -s /usr/share/keyrings/mysql-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/mysql-archive-keyring.gpg | grep -m 1 '[^[:space:]]')) ]] && sudo rm -rf /usr/share/keyrings/mysql-archive-keyring.gpg # Prevent issues!
[[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg ]] && wget -nv -O- 'https://repo.mysql.com/RPM-GPG-KEY-mysql-2022' | sudo gpg --dearmor -o /usr/share/keyrings/mysql-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/mysql-archive-keyring.gpg] http://repo.mysql.com/apt/ubuntu $(lsb_release -cs) mysql-8.0" | sudo tee /etc/apt/sources.list.d/mysql.list
@ -951,10 +1050,12 @@ 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
[[ ! -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 && ( ! -s /usr/share/keyrings/mariadb-archive-keyring.gpg || -z $(cat -v /usr/share/keyrings/mariadb-archive-keyring.gpg | grep -m 1 '[^[:space:]]' )) ]] && sudo rm -rf /usr/share/keyrings/mariadb-archive-keyring.gpg # Prevent issues!
[[ ! -f /usr/share/keyrings/mariadb-archive-keyring.gpg ]] && wget -nv -O- 'https://mariadb.org/mariadb_release_signing_key.asc' | sudo gpg --dearmor -o /usr/share/keyrings/mariadb-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/mariadb-archive-keyring.gpg] http://mirrors.syringanetworks.net/mariadb/repo/$(conf_read mysql-ver)/ubuntu $(check_osname) main" | sudo tee /etc/apt/sources.list.d/mariadb.list
fi
api-events_update ikm
local code="run"
elif [[ $3 == "mysql-client" && $(conf_read mysql-client) == "true" ]]; then
echo "${dim}MySQL/MariaDB Client is already installed!${end}"
@ -966,6 +1067,7 @@ stack_builder() {
echo "${dim}MySQL/MariaDB Client is already installed!${end}"
local code="run"
fi
api-events_update ike
# Exit before update!
# Don't run the "update" if nothing will be installed!

View file

@ -98,6 +98,8 @@ 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
@ -147,13 +149,14 @@ 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 "${blu}Certificate for${end} $domain ${blu}already exist and found, wait while we configure your server to use it!${end}"
echo "${dim}[INFO] Cert NOT requested because already exist!${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 && ! -s /etc/nginx/apps.d/.htpasswd-$domain ]]; then
if [[ $type == [123] && $(conf_read wp-admin-auth) != "purged" && ( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && ( ! -s /etc/nginx/apps.d/.htpasswd-$domain || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$domain | grep -m 1 '[^[:space:]]')) ]]; then
echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to complete the WordPress installation process!!${end}"
fi
if [[ $(conf_read login-www-data) != "true" && (( -z $forward && -z $proxy && -z $parked && -z $mysql ) || ( -n $mysql && -n $domain )) ]]; then
@ -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 "- The “Caching Method” should be set to “Nginx FastCgi Cache”."
echo "- Go to “Menu > Settings > Nginx Helper” 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,6 +161,13 @@ 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=""
@ -199,7 +206,7 @@ wpinstall() {
fi
if [[ $ext_login == "true" ]]; then
echo "${blu}${dim}External DB Credentials found!${end}"
echo "${blu}${dim}External DB Credentials found! (${dburl}:${dbport})${end}"
elif [[ -n $retry && $retry -ge 3 ]]; then
setupmysql="N"
local db_error_flag="true"
@ -595,6 +602,7 @@ 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
@ -602,14 +610,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
[[ ! -s /etc/nginx/conf.d/webinoly.conf ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
fi
# Check for Reverse Proxy upstreams
if [[ -f /etc/nginx/conf.d/upstream_proxy.conf ]]; then
local domvar=$(echo "$domain" | sed "s/[^0-9A-Za-z]/_/g")
sudo sed -i "/upstream ${domvar}/,/} #End/{/.*/d}" /etc/nginx/conf.d/upstream_proxy.conf
[[ ! -s /etc/nginx/conf.d/upstream_proxy.conf ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
[[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
fi
echo "${gre}Site${blu} $domain ${gre}has been successfully deleted!${end}"
@ -654,7 +662,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
[[ ! -s /etc/nginx/conf.d/webinoly.conf ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
fi
echo "${gre}${dim}Subfolder${blu} $subfolder ${gre}from${blu} $domain ${gre}has been successfully deleted!${end}"
@ -668,7 +676,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
[[ ! -s /etc/nginx/conf.d/upstream_proxy.conf ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
[[ -f /etc/nginx/conf.d/upstream_proxy.conf && ( ! -s /etc/nginx/conf.d/upstream_proxy.conf || -z $(cat -v /etc/nginx/conf.d/upstream_proxy.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/upstream_proxy.conf
fi
sudo rm -rf /var/www/$domain/htdocs$subfolder
@ -700,7 +708,7 @@ delete_all_sites() {
do
[[ ${delete_all,,} == "keep-db" ]] && delete="keep-db" || delete="force"
domain=$(echo $site | cut -f 5 -d "/")
[[ $domain != "default" && $domain != $ADMIN_TOOLS_SITE && $domi != *".dpkg-"* ]] && deletesite
[[ -f /etc/nginx/sites-available/$domain && $domain != "default" && $domain != $ADMIN_TOOLS_SITE && $domain != *".dpkg-"* ]] && deletesite
done
# Delete all files - double check!
@ -807,7 +815,7 @@ createsite() {
# Activate FastCgi cache
if [[ $cache == "on" && $type == [123] ]]; then
sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
sudo sed -i '/php[x]*\.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
@ -935,7 +943,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 [[ ! -s /etc/nginx/apps.d/$domain-nginx.conf ]]; then
if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then
sudo rm /etc/nginx/apps.d/$domain-nginx.conf
sudo sed -i "/$domain-nginx.conf;/d" /etc/nginx/sites-available/$domain
fi
@ -963,8 +971,12 @@ redirection_manager() {
echo "${red}[ERROR] Please, enter a valid from/to redirection path!${end}"
exit 1
elif [[ $from == "/" ]]; then
echo "${red}[ERROR] Root folder redirection is not allowed, use the 'domain forwarding' feature if want to redirect a complete domain!${end}"
exit 1
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
elif ! [[ $http_code =~ ^(301|302|303|307|308|403|410|444|451)$ ]]; then
echo "${red}[ERROR] Invalid redirection HTTP Code!${end}"
exit 1
@ -1190,6 +1202,9 @@ 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
@ -1198,8 +1213,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 "/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 "/server_name/c \ $sername" /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
@ -1308,14 +1323,15 @@ 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
@ -1475,6 +1491,8 @@ 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}"
@ -1483,11 +1501,15 @@ 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.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
[[ -z $subfolder ]] && sudo sed -i '/ common\/php[x]*\.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
@ -1539,6 +1561,7 @@ 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
@ -1547,7 +1570,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 ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
[[ -f /etc/nginx/conf.d/webinoly.conf && ( ! -s /etc/nginx/conf.d/webinoly.conf || -z $(cat -v /etc/nginx/conf.d/webinoly.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/webinoly.conf
elif [[ -n $query_string_never_cache || $query_string_cache || $skip_cache || -n $skip_cookie_cache ]]; then
custom_cache_global -site
elif [[ -n $query_string_cache_default ]]; then
@ -1578,10 +1601,8 @@ 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.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
[[ -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
# Creates the custom Webinoly Cache File (.cnf) only if not exists.
if [[ ! -f /etc/nginx/apps.d/$domain$subname-${fn}.conf ]]; then
@ -1882,7 +1903,7 @@ list_sites() {
for site in "/etc/nginx/sites-available"/*
do
local domi=$(echo $site | cut -f 5 -d "/")
[[ $domi == "default" || $domi == $ADMIN_TOOLS_SITE || $domi == *".dpkg-"* ]] && continue
[[ ! -f /etc/nginx/sites-available/$domi || $domi == "default" || $domi == $ADMIN_TOOLS_SITE || $domi == *".dpkg-"* ]] && continue
if [[ $list != "true" ]]; then
[[ ${list,,} == "disabled" && -L /etc/nginx/sites-enabled/$domi ]] && continue
@ -2147,6 +2168,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!${end}"
echo "${gre}WordPress Environment Type has been set successfully! ${dim}(${env})${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 "/")
[[ $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
[[ -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
done
fi
@ -64,7 +64,7 @@ onetwo_to_onethree() {
for site in "/etc/nginx/sites-available"/*
do
domi=$(echo $site | cut -f 5 -d "/")
[[ $domi != "html" && $domi != $(conf_read tools-port) ]] && sudo sed -i "/ssl on;/c\ #ssl on;" /etc/nginx/sites-available/$domi
[[ -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
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 ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf
[[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(cat -v /etc/nginx/apps.d/whitelist-acl.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i "/acl.conf;/i \ include common\/auth.conf;" /etc/nginx/sites-available/$(conf_read tools-port)
for site in "/etc/nginx/sites-available"/*
do
domi=$(echo $site | cut -f 5 -d "/")
if [[ $domi != "html" && $domi != $(conf_read tools-port) ]]; then
if [[ -f /etc/nginx/sites-available/$domi && $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,4 +1,7 @@
#!/bin/bash
# Example: sudo webinoly -verify
# Example: sudo webinoly -verify=critical
# Example: sudo webinoly -verify -check-for-updates
webinoly_verify() {
@ -177,6 +180,10 @@ if [[ ! -f /opt/webinoly/templates/general/admin_tools.conf ]]; then
echo "- [ERROR] File: /opt/webinoly/templates/general/admin_tools.conf not found!"
local ver_one_err="1"
fi
if [[ ! -f /opt/webinoly/templates/general/certbot-deploy-hook ]]; then
echo "- [ERROR] File: /opt/webinoly/templates/general/certbot-deploy-hook not found!"
local ver_one_err="1"
fi
if [[ ! -f /opt/webinoly/templates/general/conf ]]; then
echo "- [ERROR] File: /opt/webinoly/templates/general/conf not found!"
local ver_one_err="1"
@ -227,6 +234,11 @@ 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
@ -254,6 +266,45 @@ if [[ -z $critical_mode ]]; then
done
fi
# Temp dynvar in conf file
if [[ -n $(conf_read force-flag) ]]; then
echo "${dim}- [WARNING] Temporal variable (force-flag) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read delautopma) ]]; then
echo "${dim}- [WARNING] Temporal variable (delautopma) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read temp-path) ]]; then
echo "${dim}- [WARNING] Temporal variable (temp-path) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read nginx-reload) ]]; then
echo "${dim}- [WARNING] Temporal variable (nginx-reload) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read quiet) ]]; then
echo "${dim}- [WARNING] Temporal variable (quiet) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read multi-bkp-db) ]]; then
echo "${dim}- [WARNING] Temporal variable (multi-bkp-db) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read multi-bkp-dbh) ]]; then
echo "${dim}- [WARNING] Temporal variable (multi-bkp-dbh) has been found in the Webinoly Configuration File! ${end}${red}"
local ver_one_war="1"
fi
if [[ -n $(conf_read stack-update) ]]; 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
echo "(1) Webinoly Integrity Test has failed!"
elif [[ $ver_one_war == "1" ]]; then
@ -274,6 +325,12 @@ local ver_two_err="0"
local ver_two_war="0"
if [[ $(conf_read nginx) == "true" ]]; then
# Check if NGINX command is installed
if ! which nginx >/dev/null ; then
echo "- [ERROR] Seems like NGIN command is not installed!"
local ver_two_err="1"
fi
if [[ ! -f /etc/nginx/nginx.conf ]]; then
echo "- [ERROR] File: /etc/nginx/nginx.conf not found!"
local ver_two_err="1"
@ -289,11 +346,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 ]]; then
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
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 ]]; then
if [[ ! -f /etc/apt/sources.list.d/nginx.list || ! -s /etc/apt/sources.list.d/nginx.list || -z $(cat -v /etc/apt/sources.list.d/nginx.list | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] Nginx PPA not found in sources list!"
local ver_two_err="1"
fi
@ -380,6 +437,15 @@ if [[ $(conf_read nginx-optim) == "true" ]]; then
echo "- [ERROR] File: /opt/webinoly/templates/source/nginx.conf not found!"
local ver_two_err="1"
fi
if [[ -f /etc/nginx/common/wpfc.conf && ( -n $(grep -F "<wpcache-exclude-url>" /etc/nginx/common/wpfc.conf) || -n $(grep -F "<wpcache-exclude-cookie>" /etc/nginx/common/wpfc.conf) ) ]]; then
echo "- [ERROR] File: /etc/nginx/common/wpfc.conf is corrupted!"
local ver_two_err="1"
fi
if [[ -f /etc/nginx/common/locations.conf && ( -n $(grep -F "<locations-deny-extensions>" /etc/nginx/common/locations.conf) || -n $(grep -F "<locations-deny-files>" /etc/nginx/common/locations.conf) ) ]]; then
echo "- [ERROR] File: /etc/nginx/common/locations.conf is corrupted!"
local ver_two_err="1"
fi
fi
# NGINX tools site
@ -449,11 +515,30 @@ if [[ -z $critical_mode ]]; then
if [[ $(conf_read nginx-optim) == "true" && ! ( -s /etc/nginx/.htpasswd || ( -n $(conf_read tools-site) && -s /etc/nginx/apps.d/.htpasswd-$(conf_read tools-site) )) ]]; then
echo "${blu}${dim}- [INFO] HTTP Authentication Credentials not found to access the server tools on port $(conf_read tools-port).${end}${red}"
fi
# HTTP Headers
if [[ $(conf_read nginx-optim) == "true" && -z $(conf_read header-csp) ]]; then
echo "${blu}${dim}- [INFO] Setting a Content-Security-Policy Header is highly recommended!${end}${red}"
fi
if [[ $(conf_read nginx-optim) == "true" && $(conf_read header-xssp) == "true" ]]; then
echo "${blu}${dim}- [INFO] X-XSS Header is no longer recommended, use a strong CSP instead!${end}${red}"
fi
# Webinoly Stack version
if [[ $(conf_read nginx) == "true" && $(conf_read server-version) != $svr_version ]]; then
echo "${dim}- [WARNING] Webinoly Stack version check is corrupted! (Installed: $svr_version != Conf: $(conf_read server-version)) ${end}${red}"
local ver_two_war="1"
if [[ $(conf_read nginx) == "true" ]]; then
# Webinoly Stack version
if [[ $(conf_read server-version) != $svr_version ]]; then
echo "${dim}- [WARNING] Webinoly Stack version check is corrupted! (Installed: $svr_version != Conf: $(conf_read server-version)) ${end}${red}"
local ver_two_war="1"
fi
# Check Nginx Branch in Configuration File
if [[ $(($(sudo nginx -v 2>&1 | cut -d'.' -f 2 -s)%2)) == 1 && $(conf_read nginx-ppa) != "mainline" ]]; then
echo "- [ERROR] Nginx Branch in Configuration File is corrupted!"
local ver_two_err="1"
elif [[ $(($(sudo nginx -v 2>&1 | cut -d'.' -f 2 -s)%2)) == 0 && $(conf_read nginx-ppa) != "stable" && -n $(conf_read nginx-ppa) ]]; then
echo "- [ERROR] Nginx Branch in Configuration File is corrupted!"
local ver_two_err="1"
fi
fi
if [[ $ver_two_err == "1" ]]; then
@ -476,26 +561,32 @@ local ver_three_err="0"
local ver_three_war="0"
if [[ $(conf_read php) == "true" ]]; then
# Check if PHP command is installed
if ! which php >/dev/null ; then
echo "- [ERROR] Seems like PHP command is not installed!"
local ver_three_err="1"
fi
if [[ ! -f /etc/php/$(conf_read php-ver)/fpm/php.ini ]]; then
echo "- [ERROR] File: /etc/php/$(conf_read php-ver)/fpm/php.ini not found!"
local ver_three_err="1"
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 ]]; then
if [[ ! -f /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || ! -s /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg || -z $(cat -v /etc/apt/trusted.gpg.d/ondrej_ubuntu_php.gpg | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] PHP Apt Key not found!"
local ver_three_err="1"
fi
if [[ ! -f /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list ]]; then
if [[ ! -f /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || ! -s /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list || -z $(cat -v /etc/apt/sources.list.d/ondrej-ubuntu-php-$(check_osname).list | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] PHP PPA not found in sources list!"
local ver_three_err="1"
fi
else
if [[ ! -f /usr/share/keyrings/php-archive-keyring.gpg || ! -s /usr/share/keyrings/php-archive-keyring.gpg ]]; then
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
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 ]]; then
if [[ ! -f /etc/apt/sources.list.d/php.list || ! -s /etc/apt/sources.list.d/php.list || -z $(cat -v /etc/apt/sources.list.d/php.list | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] PHP PPA not found in sources list!"
local ver_three_err="1"
fi
@ -574,14 +665,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)$ ]]; then
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
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)$ ]]; then
echo "${dim}- [WARNING] You have an obsolete PHP version (${ver_php_ver}) installed that not even receive security updates!${end}${red}"
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}"
local ver_three_war="1"
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}"
#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}"
fi
fi
@ -606,25 +697,50 @@ local ver_four_err="0"
local ver_four_war="0"
# MySQL/MariaDB
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'.')
else
# To check supported versions: https://mariadb.com/kb/en/mariadb-server/
local ver_mysql_ver=$(sudo mysql --version | sed 's/.*Distrib \([^\-]*\).*/\1/' | cut -f 1-2 -d'.')
if [[ $(conf_read mysql) == "true" || $(conf_read mysql-client) == "true" ]]; then
# Check if MYSQL command is installed
if ! which mysql >/dev/null ; then
echo "- [ERROR] Seems like MYSQL command is not installed!"
local ver_four_err="1"
fi
if [[ ! -d /etc/mysql ]]; then
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
if [[ ! -f /usr/share/keyrings/mysql-archive-keyring.gpg || ! -s /usr/share/keyrings/mysql-archive-keyring.gpg ]]; 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
echo "- [ERROR] MySQL DB Engine in Configuration File is corrupted!"
local ver_four_err="1"
fi
else
# To check supported versions: https://mariadb.com/kb/en/mariadb-server/
local ver_mysql_ver=$(sudo mysql --version | sed 's/.*Distrib \([^\-]*\).*/\1/' | cut -f 1-2 -d'.')
if [[ -z $(sudo mysql --version | grep -Fio "MariaDb") || ( -n $(conf_read db-engine) && $(conf_read db-engine) != "mariadb" ) ]]; then
echo "- [ERROR] MySQL DB Engine in Configuration File is corrupted!"
local ver_four_err="1"
fi
fi
if [[ ! -f $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf ]]; then
echo "- [ERROR] File: $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly-login.cnf not found!"
local ver_four_err="1"
fi
if [[ ! -f $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly.cnf ]]; then
echo "- [ERROR] File: $MYSQL_CONF_PATH/${MYSQL_CONF_PREF}-webinoly.cnf not found!"
local ver_four_err="1"
fi
# 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
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 ]]; then
if [[ ! -f /etc/apt/sources.list.d/mysql.list || ! -s /etc/apt/sources.list.d/mysql.list || -z $(cat -v /etc/apt/sources.list.d/mysql.list | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] MySQL PPA not found in sources list!"
local ver_four_err="1"
fi
@ -638,19 +754,17 @@ 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 ]]; then
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
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 ]]; then
if [[ ! -f /etc/apt/sources.list.d/mariadb.list || ! -s /etc/apt/sources.list.d/mariadb.list || -z $(cat -v /etc/apt/sources.list.d/mariadb.list | grep -m 1 '[^[:space:]]') ]]; then
echo "- [ERROR] MariaDB PPA not found in sources list!"
local ver_four_err="1"
fi
fi
fi
# MySQL/MariaDB Connection
if [[ $(conf_read mysql) == "true" ]]; then
# MySQL/MariaDB Connection
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"
@ -707,8 +821,8 @@ if [[ -z $critical_mode ]]; then
local ver_four_war="1"
fi
# DB Role - Check Privileges!
if [[ $(conf_read mysql-client) == "true" ]]; then
# DB Role - Check Privileges!
local dbrolecheck=$(conf_read dbrole)
local dbrolecheck=${dbrolecheck,,}
if [[ $dbrolecheck == "all" ]]; then
@ -718,6 +832,20 @@ if [[ -z $critical_mode ]]; then
elif [[ $dbrolecheck == "basic" ]]; then
echo "${blu}${dim}- [INFO] DB Default Privileges are set to BASIC, some sites may not work properly with basic privileges! ${end}${red}"
fi
# Saved DB Credentials
conf_write quiet true
if [[ -n $(conf_read external-dbh) && -n $(conf_read external-dbu) && -n $(conf_read external-dbp) && -n $(conf_read external-dbx) ]]; then
local svdb=$(check_mysql_connection $(conf_read external-dbh) $(conf_read external-dbx) $(conf_read external-dbu) $(conf_read external-dbp) -master-admin)
if [[ $svdb == "false" ]]; then
echo "- [ERROR] External DB Connection failed! (Saved credentials for: $(conf_read external-dbh):$(conf_read external-dbx))"
local ver_four_err="1"
elif [[ $svdb == "truebutnotmaster" ]]; then
echo "${dim}- [WARNING] External DB Connection seems like not have Master user privileges! (Saved credentials for: $(conf_read external-dbh):$(conf_read external-dbx)) ${end}${red}"
local ver_four_war="1"
fi
fi
conf_delete quiet
fi
@ -740,32 +868,32 @@ fi
local ver_five_err="0"
local ver_five_war="0"
if ! systemctl is-active --quiet nginx && [[ $(conf_read nginx) == "true" ]]; then
if [[ $(conf_read nginx) == "true" ]] && ! systemctl is-active --quiet nginx; then
echo "- [ERROR] Nginx service not running!"
local ver_five_err="1"
fi
if ! systemctl is-active --quiet php$(conf_read php-ver)-fpm && [[ $(conf_read php) == "true" ]]; then
if [[ $(conf_read php) == "true" ]] && ! systemctl is-active --quiet php$(conf_read php-ver)-fpm; then
echo "- [ERROR] PHP service not running!"
local ver_five_err="1"
fi
if ! systemctl is-active --quiet mysql && [[ $(conf_read mysql) == "true" ]]; then
if [[ $(conf_read mysql) == "true" ]] && ! systemctl is-active --quiet mysql; then
echo "- [ERROR] MySQL/MariaDB service not running!"
local ver_five_err="1"
fi
if ! systemctl is-active --quiet redis-server && [[ $(conf_read php-tool-redis) == "true" ]]; then
if [[ $(conf_read php-tool-redis) == "true" ]] && ! systemctl is-active --quiet redis-server; then
echo "- [ERROR] Redis service not running!"
local ver_five_err="1"
fi
if ! systemctl is-active --quiet memcached && [[ $(conf_read php-tool-memcached) == "true" ]]; then
if [[ $(conf_read php-tool-memcached) == "true" ]] && ! systemctl is-active --quiet memcached; then
echo "- [ERROR] Memcached service not running!"
local ver_five_err="1"
fi
if ! systemctl is-active --quiet postfix && [[ $(conf_read php-tool-postfix) == "true" ]]; then
if [[ $(conf_read php-tool-postfix) == "true" ]] && ! systemctl is-active --quiet postfix; then
echo "- [ERROR] Postfix service not running!"
local ver_five_err="1"
fi
if ! sudo nginx -t 2>/dev/null && [[ $(conf_read nginx) == "true" ]]; then
if [[ $(conf_read nginx) == "true" ]] && ! sudo nginx -t 2>/dev/null; then
echo "- [ERROR] Nginx Configuration check failed!"
local ver_five_err="1"
fi
@ -819,6 +947,24 @@ if [[ $ver_disk =~ ^[0-9]+$ && $ver_disk -gt 75 ]]; then
local ver_six_war="1"
fi
# Check if WGET is installed
if ! which wget >/dev/null ; then
echo "- [ERROR] Seems like WGET package is not installed!"
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
@ -838,15 +984,6 @@ 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}"
@ -875,6 +1012,11 @@ local ver_seven_war="0"
# Web Tools
if [[ $(conf_read php-tool-redis) == "true" ]]; then
# Check if REDIS command is installed
if ! which redis-cli >/dev/null ; then
echo "- [ERROR] Seems like Redis command is not installed!"
local ver_seven_err="1"
fi
if [[ ! -d /etc/redis ]]; then
echo "- [ERROR] Folder: /etc/redis not found!"
local ver_seven_err="1"
@ -882,14 +1024,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 ) && ( ! -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
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
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 ) && ( ! -f /etc/apt/sources.list.d/redis.list || ! -s /etc/apt/sources.list.d/redis.list ) ]]; then
if [[ ( ! -f /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || ! -s /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list || -z $(cat -v /etc/apt/sources.list.d/redislabs-ubuntu-redis-$(check_osname).list | grep -m 1 '[^[:space:]]')) && ( ! -f /etc/apt/sources.list.d/redis.list || ! -s /etc/apt/sources.list.d/redis.list || -z $(cat -v /etc/apt/sources.list.d/redis.list | grep -m 1 '[^[:space:]]')) ]]; then
echo "- [ERROR] Redis PPA not found in sources list!"
local ver_seven_err="1"
fi
@ -899,9 +1041,12 @@ if [[ $(conf_read mysql-tool-pma) == "true" && ! -d /var/www/$ADMIN_TOOLS_SITE/h
echo "- [ERROR] Folder: /var/www/$ADMIN_TOOLS_SITE/htdocs/pma not found!"
local ver_seven_err="1"
fi
if [[ $(conf_read php-tool-memcached) == "true" && ! -f /usr/bin/memcached ]]; then
echo "- [ERROR] File: /usr/bin/memcached not found!"
local ver_seven_err="1"
if [[ $(conf_read php-tool-memcached) == "true" ]]; then
# Check if MEMCACHED command is installed
if ! which memcached >/dev/null ; then
echo "- [ERROR] Seems like Memcached command is not installed!"
local ver_seven_err="1"
fi
fi
if [[ $(conf_read php-tool-postfix) == "true" && ! -d /etc/postfix ]]; then
echo "- [ERROR] Folder: /etc/postfix not found!"
@ -912,19 +1057,21 @@ if [[ $(conf_read php-tool-postfix) == "true" && ! -f /opt/webinoly/templates/so
local ver_seven_err="1"
fi
if [[ $(conf_read nginx-tool-ssl) == "true" ]]; then
if [[ ! -L /snap/bin/certbot ]]; then
echo "- [ERROR] File: /snap/bin/certbot not found!"
# Check if CERTBOT command is installed
if ! which certbot >/dev/null ; then
echo "- [ERROR] Seems like Certbot command is not installed!"
local ver_seven_err="1"
fi
fi
if [[ $(conf_read nginx-tool-bkp) == "true" ]]; then
if [[ ! -f /usr/bin/duply ]]; then
echo "- [ERROR] File: /usr/bin/duply not found!"
# Check if DUPLY command is installed
if ! which duply >/dev/null ; then
echo "- [ERROR] Seems like Duply command is not installed!"
local ver_seven_err="1"
fi
# Remove the snap path!
if [[ ! -L /snap/bin/duplicity && ! -f /usr/local/bin/duplicity ]]; then
echo "- [ERROR] File: /usr/local/bin/duplicity not found!"
# Check if DUPLICITY command is installed
if ! which duplicity >/dev/null ; then
echo "- [ERROR] Seems like Duplicity command is not installed!"
local ver_seven_err="1"
fi
fi
@ -934,7 +1081,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 ]]; then
if [[ -d $cert && ! -f /etc/nginx/sites-available/$domain && -n $domain ]]; then
echo "${blu}${dim}- [INFO] SSL Orphan-Cert found ($domain)!${end}${red}"
fi
done
@ -958,7 +1105,7 @@ if [[ -z $critical_mode ]]; then
if [[ $ver_seven_err == "1" ]]; then
echo "(7) Additional Tools Verification Test has failed!"
elif [[ $ver_seven_war == "1" ]]; then
echo "${dim}(4) Additional Tools Verification Test has some warning messages you should attend!${end}${red}"
echo "${dim}(7) Additional Tools Verification Test has some warning messages you should attend!${end}${red}"
else
echo "${gre}${dim}(7) Additional Tools Verification Test successful!${end}${red}"
fi
@ -1013,6 +1160,11 @@ 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
@ -1067,9 +1219,12 @@ 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 && ! -s /etc/nginx/apps.d/.htpasswd-$ver_domi && $(is_wp_auth $ver_domi) == "true" ]]; then
if [[ ( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && ( ! -s /etc/nginx/apps.d/.htpasswd-$ver_domi || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$ver_domi | grep -m 1 '[^[:space:]]')) && $(is_wp_auth $ver_domi) == "true" ]]; then
echo "${blu}${dim}- [INFO] HTTP Authentication Credentials not found for $ver_domi${end}${red}"
fi
@ -1085,6 +1240,11 @@ if [[ -z $critical_mode ]]; then
echo "${red}${dim}- [WARNING] Database connection failed for your WP site $ver_domi (${wp_dbhost}) ${end}${red}"
local ver_nine_war="1"
fi
# If not WP but WP files are found then alert! (people manually installing WP)
elif [[ -f /var/www/$ver_domi/wp-config.php || -f /var/www/$ver_domi/htdocs/wp-config.php ]]; then
echo "${red}${dim}- [WARNING] Seems like $ver_domi is a WordPress site but configured for a different type! ${end}${red}"
local ver_nine_war="1"
fi
fi
done

View file

@ -30,7 +30,8 @@ system_info() {
echo "${blu}${bol}[NGINX]${end}"
if [[ $(conf_read nginx) == "true" ]]; then
echo "${blu}Branch:${end}${dim} $(conf_read nginx-ppa) ${end}"
[[ -z $(conf_read nginx-ppa) ]] && local nginxbranch="stable" || local nginxbranch=$(conf_read nginx-ppa)
echo "${blu}Branch:${end}${dim} ${nginxbranch} ${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}"
@ -414,6 +415,13 @@ 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
@ -688,7 +696,7 @@ set_tools_site() {
fi
# Warning Message
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
if [[ (( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && $tools_site == "default" ) || (( ! -s /etc/nginx/.htpasswd || -z $(cat -v /etc/nginx/.htpasswd | grep '[^[:space:]]')) && $tools_site != "default" && -f /etc/nginx/sites-available/$tools_site && ( ! -s /etc/nginx/apps.d/.htpasswd-$tools_site || -z $(cat -v /etc/nginx/apps.d/.htpasswd-$tools_site | grep -m 1 '[^[:space:]]'))) ]]; then
echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to access these tools!${end}"
fi
}
@ -700,13 +708,22 @@ 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 $CURRENT_HOME/.ssh/authorized_keys ]]; then
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
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
@ -733,7 +750,6 @@ 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
@ -826,7 +842,7 @@ clear_caches() {
sudo redis-cli flushall
echo "${gre}- Redis Cache has been successfully cleared!${end}"
else
echo "${red}[ERROR] We can not clear Redis Cache because is not installed!${end}"
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear Redis Cache because is not installed!${end}"
err_cont=true
fi
fi
@ -837,7 +853,7 @@ clear_caches() {
echo flush_all > /dev/tcp/$memhost/$memport
echo "${gre}- Memcached has been successfully cleared!${end}"
else
echo "${red}[ERROR] We can not clear Memcache because is not installed!${end}"
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear Memcache because is not installed!${end}"
err_cont=true
fi
fi
@ -853,7 +869,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
echo "${red}[ERROR] We can not clear OpCache because PHP or NGINX are not installed!${end}"
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear OpCache because PHP or NGINX are not installed!${end}"
err_cont=true
fi
fi
@ -862,7 +878,7 @@ clear_caches() {
sudo rm -Rf /run/nginx-cache/*
echo "${gre}- FastCgi Cache has been successfully cleared!${end}"
else
echo "${red}[ERROR] We can not clear FastCGI Cache because NGINX is not installed!${end}"
[[ $clear_cache != "all" ]] && echo "${red}[ERROR] We can not clear FastCGI Cache because NGINX is not installed!${end}"
err_cont=true
fi
fi
@ -870,6 +886,9 @@ 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
@ -943,7 +962,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 ]] && sudo rm /etc/nginx/conf.d/blockips.conf
[[ -f /etc/nginx/conf.d/blockips.conf && ( ! -s /etc/nginx/conf.d/blockips.conf || -z $(cat -v /etc/nginx/conf.d/blockips.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/conf.d/blockips.conf
echo "${gre}The IP address ${blu}'$blockip'${gre} was successfully unblocked!${end}"
else
@ -1062,6 +1081,7 @@ database_import() {
fi
check_external_db_saved
echo "${dim}Wait while we import your db... ${end}"
if [[ -n $external_db ]]; then
external_db_parse
@ -1070,15 +1090,22 @@ 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
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}"
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
elif [[ -z $external_db && $(check_mysql_connection localhost) == "true" ]]; then
check_for_mysql -ask
sudo mysql -u admin < $file
sudo mysql --connect-timeout=10 --user=admin -e "FLUSH PRIVILEGES;"
echo "${gre}Database successfully imported!${end}"
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
else
echo "${red}[ERROR] A connection can not be established with MySQL/MariaDB localhost!${end}"
exit 1

View file

@ -1,7 +1,7 @@
# WebinolyStartBlackhole
server {
listen 443 ssl default_server;
listen [::]:443 ssl default_server;
listen 443 ssl http2 default_server;
listen [::]:443 ssl http2 default_server;
ssl_certificate /etc/ssl/certs/webinoly-blackhole.crt.pem;
ssl_certificate_key /etc/ssl/private/webinoly-blackhole.key.pem;

View file

@ -9,8 +9,17 @@ 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"
@ -87,7 +96,7 @@ elif [[ -n $delete ]]; then
sudo sed -i "/^$userpurge:/d" /etc/nginx/$authfile
# Remove site-auth-file if empty.
if [[ -n $domain && -f /etc/nginx/$authfile && ! -s /etc/nginx/$authfile ]]; then
if [[ -n $domain && -f /etc/nginx/$authfile && ( ! -s /etc/nginx/$authfile || -z $(cat -v $authfile | grep -m 1 '[^[:space:]]')) ]]; then
sudo rm /etc/nginx/$authfile
sudo rm -rf /etc/nginx/apps.d/.htpasswd-www.$domain
fi
@ -203,7 +212,7 @@ elif [[ -n $whitelist ]]; then
[[ -f /etc/nginx/apps.d/whitelist-acl.conf ]] && sudo sed -i "\#^allow ${whitelist};#d" /etc/nginx/apps.d/whitelist-acl.conf
# Remove site-auth-file if empty.
[[ -f /etc/nginx/apps.d/whitelist-acl.conf && ! -s /etc/nginx/apps.d/whitelist-acl.conf ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf
[[ -f /etc/nginx/apps.d/whitelist-acl.conf && ( ! -s /etc/nginx/apps.d/whitelist-acl.conf || -z $(cat -v /etc/nginx/apps.d/whitelist-acl.conf | grep -m 1 '[^[:space:]]')) ]] && sudo rm /etc/nginx/apps.d/whitelist-acl.conf
echo "${gre}The IP address ${blu}'$whitelist'${gre} was successfully removed from whitelist!${end}"
else
@ -233,7 +242,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)$ ]]; then
if ! [[ $(is_subfolder $domain $(echo $path | rev | cut -d'/' -f ${x}- -s | rev)) =~ ^(true|false|empty)$ ]]; then
echo "${red}[ERROR] Subfolder parameter not found!${end}"
exit 1
fi
@ -318,7 +327,7 @@ location $sign$path {
elif [[ $path =~ ^\/([A-Za-z0-9_\/\.\-]+)?$ ]]; then
if [[ -f /etc/nginx/apps.d/$domain-nginx.conf ]]; then
sudo sed -i "/^# Path: $(echo $path | sed "s#/#\\\/#g")/,/^# PathEnd/{/.*/d}" /etc/nginx/apps.d/$domain-nginx.conf
if [[ ! -s /etc/nginx/apps.d/$domain-nginx.conf ]]; then
if [[ -f /etc/nginx/apps.d/$domain-nginx.conf && ( ! -s /etc/nginx/apps.d/$domain-nginx.conf || -z $(cat -v /etc/nginx/apps.d/$domain-nginx.conf | grep -m 1 '[^[:space:]]')) ]]; then
sudo rm /etc/nginx/apps.d/$domain-nginx.conf
sudo sed -i "/$domain-nginx.conf;/d" /etc/nginx/sites-available/$domain
fi
@ -367,7 +376,7 @@ elif [[ -n $list ]]; then
done
}
fi
[[ ! -s /etc/nginx/$authfile && -z $raw && $list != "raw" ]] && echo "${blu}[Empty] No users were found!${end}"
[[ ( ! -s /etc/nginx/$authfile || -z $(cat -v /etc/nginx/$authfile | grep -m 1 '[^[:space:]]')) && -z $raw && $list != "raw" ]] && echo "${blu}[Empty] No users were found!${end}"
echo ""
nginx_not="true" # Nginx-Reload not-needed.
@ -380,4 +389,5 @@ else
fi
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo systemctl reload nginx
ads_donate
api-events_update hae

10
usr/log
View file

@ -19,6 +19,13 @@ 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
# Check for custom "lines" value
[[ -n $(conf_read log-lines) && $(conf_read log-lines) =~ ^[0-9]+$ && $(conf_read log-lines) -gt 0 ]] && clines=$(conf_read log-lines) || clines=10
[[ -n $lines && $lines =~ ^[0-9]+$ && $lines -gt 0 ]] && clines=$lines
@ -322,7 +329,7 @@ elif [[ -n $domain && -f /etc/nginx/sites-available/$domain ]]; then
fi
elif [[ -n $wp ]]; then
echo "${red}[ERROR] WordPress configuration file not found!${end}"
echo "${red}[ERROR] Please, enter a valid WP site! ${dim}(${domain}${subfolder})${end}"
exit 1
# Access and error logs
@ -367,4 +374,5 @@ else
exit 1
fi
ads_donate
api-events_update lge

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!${end}"
echo "${blu}${dim}External DB credentials found! (${exth})${end}"
fi
if [[ ( -n $wp && $wp != true ) || ( -n $mysql && $mysql != true ) ]]; then
@ -100,11 +100,12 @@ 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 && ( $cache == "on" || -n $multisite_convert || -n $replace_content ) && $(is_subfolder $domain $subfolder) != "wp" && -z $clone_from ]]; then
elif [[ -n $subfolder && -z $wp && ( $cache == "on" || -n $multisite_convert || -n $replace_content || -n $env ) && $(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
@ -126,10 +127,11 @@ 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" ]]; then
if [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $(is_subfolder $domain $subfolder) != "false" && $(is_subfolder $domain $subfolder) != "empty" ]]; then
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists!${end}"
exit 1
elif [[ -n $subfolder ]]; then
elif [[ -n $subfolder ]]; then
[[ $(is_subfolder $domain $subfolder) == "empty" ]] && echo "${dim}[INFO] Subfolder already exists, but it's empty!${end}"
[[ ! -f /etc/nginx/sites-available/$domain ]] && create_empty_site
php_subfolder
sudo mkdir -p /var/www/$domain/htdocs$subfolder
@ -153,7 +155,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/example.com/*-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/${domain}/*-nginx.conf)${end}"
[[ $empty == "blank" ]] && create_empty_site -full || create_empty_site
@ -161,7 +163,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!${end}"
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists! ${dim}(Just put the HTML files in it, a separate conf is not needed)${end}"
exit 1
fi
@ -197,8 +199,15 @@ 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
echo "${red}[ERROR] Subfolder${blu} $subfolder ${red}already exists!${end}"
exit 1
# 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
elif [[ -f /etc/nginx/sites-available/$domain && -n $subfolder && $type == [123] ]]; then
wpinstall
else
@ -452,4 +461,5 @@ fi
shopt -u extglob
[[ $(conf_read nginx) == "true" && -z $nginx_not && $(conf_read nginx-reload) != "false" ]] && sudo systemctl reload nginx
ads_donate
api-events_update sie

View file

@ -629,7 +629,7 @@ elif [[ -n $html || -n $nginx ]]; then
stack_builder nginx false false $build
elif [[ -n $php ]]; then
if [[ $(conf_read nginx) != "true" && $(conf_read force-flag) != "true" && $php != "nginx" ]]; then
if [[ $(conf_read php) != "true" && $(conf_read nginx) != "true" && $(conf_read force-flag) != "true" && $php != "nginx" ]]; then
echo ""
echo "${blu}Nginx is not installed, do you want to install it too [y/N]?${end} "
while read -r -n 1 -s answer; do

View file

@ -13,10 +13,18 @@ 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
nginx_not="true" # Nginx-Reload not-needed.
ads_block="true" # Don't show ads
elif [[ -n $server_reset ]]; then
@ -35,6 +43,7 @@ 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
@ -65,7 +74,8 @@ elif [[ -n $uninstall ]]; then
api-events_update wy4
webinoly_uninstall
nginx_not="true" # Nginx-Reload not-needed.
ads_block="true" # Don't show ads
elif [[ -n $external_sources_update ]]; then
external_sources_update
@ -92,8 +102,15 @@ elif [[ -n $timezone ]]; then
read -p "${blu}Timezone: ${end}" timezone
echo ""
fi
conf_write timezone $timezone
set_timezone
# Check first here to not overwrite a valid good value with a wrong value.
if [[ -n $timezone ]] && grep -Fxq $timezone /opt/webinoly/lib/timezone.dat; then
conf_write timezone $timezone
set_timezone
else
echo "${red}Timezone not found or not valid!${end}"
exit 1
fi
nginx_not="true" # Nginx-Reload not-needed.
@ -247,6 +264,7 @@ elif [[ -n $datadog ]]; then
elif [[ -n $db_import ]]; then
check_for_mysql
database_import
nginx_not="true" # Nginx-Reload not-needed.
@ -289,4 +307,5 @@ fi
[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo systemctl reload nginx
[[ -n $err_cont ]] && exit 1
[[ -z $ads_block ]] && ads_donate
api-events_update wye

39
weby
View file

@ -113,6 +113,7 @@ 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
@ -157,6 +158,19 @@ 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
@ -165,7 +179,10 @@ fi
# Write app version
webyversion=$app_version
conf_write app-version $webyversion
[[ $ver =~ ^(alpha|beta)$ ]] && conf_write branch $ver
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
# Ping to Webinoly Stats
@ -177,19 +194,19 @@ if [[ $statskip != "true" ]]; then
type="New"
elif [[ $ver == "beta" ]]; then
type="Beta"
elif [[ -n $update && $ver =~ ^[0-9]{1}\.[0-9]{1,2}\.[0-9]{1,2}$ ]]; then
elif [[ -n $update && $type == "Custom" ]]; 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
@ -205,10 +222,16 @@ fi
[[ $setup == 1 ]] && stack -nginx
[[ $setup == 2 ]] && stack -php=nginx
[[ $setup == 3 ]] && stack -lemp
[[ $setup != [123] ]] && sudo webinoly -verify=critical
# 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
# Message Center
if [[ -z $(conf_read stack-build-error-flag) ]]; then
if [[ -z $(conf_read stack-build-error-flag) && $type != "Error" ]]; then # We use $type instead of dynvar to not make it persistant!
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}"