admin tools
Site folder now is named according to the domain:port assigned. Fixed error with HSTS header for admin tools site.
This commit is contained in:
parent
a56dfc8819
commit
b5f38ccd29
14 changed files with 248 additions and 152 deletions
6
lib/bkp
6
lib/bkp
|
@ -620,9 +620,9 @@ export_server() {
|
|||
|
||||
# Create TAR file
|
||||
[[ -d /var/www/html ]] && local exclude="--exclude=/var/www/html" || local exclude=""
|
||||
[[ -d /var/www/$(conf_read tools-port) ]] && local exclude="$exclude --exclude=/var/www/$(conf_read tools-port)"
|
||||
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && local exclude="$exclude --exclude=/etc/nginx/sites-available/$(conf_read tools-port)"
|
||||
[[ -L /etc/nginx/sites-enabled/$(conf_read tools-port) ]] && local exclude="$exclude --exclude=/etc/nginx/sites-enabled/$(conf_read tools-port)"
|
||||
[[ -d /var/www/$ADMIN_TOOLS_SITE ]] && local exclude="$exclude --exclude=/var/www/$ADMIN_TOOLS_SITE"
|
||||
[[ -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]] && local exclude="$exclude --exclude=/etc/nginx/sites-available/$ADMIN_TOOLS_SITE"
|
||||
[[ -L /etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE ]] && local exclude="$exclude --exclude=/etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE"
|
||||
[[ -f /etc/nginx/sites-available/default ]] && local exclude="$exclude --exclude=/etc/nginx/sites-available/default"
|
||||
[[ -L /etc/nginx/sites-enabled/default ]] && local exclude="$exclude --exclude=/etc/nginx/sites-enabled/default"
|
||||
|
||||
|
|
14
lib/datadog
14
lib/datadog
|
@ -4,7 +4,7 @@
|
|||
dd_nginx_purge() {
|
||||
if [[ -f /etc/datadog-agent/conf.d/nginx.d/conf.yaml ]]; then
|
||||
if [[ ! -f /etc/datadog-agent/conf.d/php_fpm.d/conf.yaml ]]; then
|
||||
sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
sudo rm -rf /etc/datadog-agent/conf.d/nginx.d/conf.yaml
|
||||
|
@ -18,7 +18,7 @@ dd_nginx_purge() {
|
|||
dd_fpm_purge() {
|
||||
if [[ -f /etc/datadog-agent/conf.d/php_fpm.d/conf.yaml ]]; then
|
||||
if [[ ! -f /etc/datadog-agent/conf.d/nginx.d/conf.yaml ]]; then
|
||||
sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
sudo rm -rf /etc/datadog-agent/conf.d/php_fpm.d/conf.yaml
|
||||
|
@ -262,8 +262,8 @@ logs:
|
|||
|
||||
dd_nginx() {
|
||||
if [[ ! -f /etc/datadog-agent/conf.d/nginx.d/conf.yaml ]]; then
|
||||
if [[ -z $(grep -F "WebinolyLocalhostStart" /etc/nginx/sites-available/$(conf_read tools-port)) ]]; then
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-localhost' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
if [[ -z $(grep -F "WebinolyLocalhostStart" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE) ]]; then
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-localhost' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
sudo touch /etc/datadog-agent/conf.d/nginx.d/conf.yaml
|
||||
|
@ -297,8 +297,8 @@ instances:
|
|||
|
||||
dd_fpm() {
|
||||
if [[ ! -f /etc/datadog-agent/conf.d/php_fpm.d/conf.yaml ]]; then
|
||||
if [[ -z $(grep -F "WebinolyLocalhostStart" /etc/nginx/sites-available/$(conf_read tools-port)) ]]; then
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-localhost' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
if [[ -z $(grep -F "WebinolyLocalhostStart" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE) ]]; then
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-localhost' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
sudo touch /etc/datadog-agent/conf.d/php_fpm.d/conf.yaml
|
||||
|
@ -413,7 +413,7 @@ dd_purge() {
|
|||
sudo rm -rf /usr/share/keyrings/datadog-archive-keyring.gpg*
|
||||
sudo rm -rf /etc/apt/sources.list.d/datadog.list
|
||||
|
||||
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
[[ -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]] && sudo sed -i '/WebinolyLocalhostStart/,/WebinolyLocalhostEnd/{/.*/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
echo "${gre}Datadog Agent has been removed successfully from your server!${end}"
|
||||
else
|
||||
echo "${red}[ERROR] Datadog Agent is not installed on your server!${end}"
|
||||
|
|
72
lib/general
72
lib/general
|
@ -70,6 +70,28 @@ conf_write() {
|
|||
# ***********************************************
|
||||
# Useful variables ****************************
|
||||
# ***********************************************
|
||||
|
||||
|
||||
# STOP and exit if not root or sudo.
|
||||
if [[ $(whoami) != "root" ]]; then
|
||||
echo "${red}Please run this script as root or using sudo.${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for BASH Shell
|
||||
# This is a very "shity" method, but checking if file exists is very reliable
|
||||
# If modified: this same script is in installer, general lib and verify
|
||||
if [[ $(conf_read shell-check) != "false" && -n $(echo $(tty) | grep -Eo "pts/[0-9]+") && -n $(logname) ]]; then
|
||||
pre_pid=$(ps -au | grep -E "pts/[0-9]+[ ]+S[s]?[ ]+" | sed '/sudo/d' | tail -n 1)
|
||||
[[ -n $pre_pid ]] && shell_pid=$(echo $pre_pid | awk '{print $2}')
|
||||
[[ -n $shell_pid && -f /proc/$shell_pid/cmdline ]] && shell_current=$(tr -d '\000' < /proc/$shell_pid/cmdline)
|
||||
[[ -n $shell_pid && -f /proc/$shell_pid/status ]] && shell_status=$(grep -Eo '^Name:.*bash.*' /proc/$shell_pid/status) # Double check!!!
|
||||
|
||||
if [[ -n $shell_current && $shell_current != *"bash"* && -z $shell_status ]]; then
|
||||
echo "${red}[WARNING] Seems like you are using an interactive shell different than BASH! ${dim}($(echo $pre_pid | awk '{print $1}'):${shell_current}) ${end}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# MySQL folder
|
||||
if [[ $(conf_read db-engine) == "mysql" ]]; then
|
||||
readonly MYSQL_CONF_PATH="/etc/mysql/mysql.conf.d"
|
||||
|
@ -88,26 +110,18 @@ else
|
|||
readonly CURRENT_USER="root"
|
||||
fi
|
||||
|
||||
# Check for BASH Shell
|
||||
# This is a very "shity" method, but checking if file exists is very reliable
|
||||
# If modified: this same script is in installer, general lib and verify
|
||||
if [[ $(conf_read shell-check) != "false" && -n $(echo $(tty) | grep -Eo "pts/[0-9]+") && -n $(logname) ]]; then
|
||||
pre_pid=$(ps -au | grep -E "pts/[0-9]+[ ]+S[s]?[ ]+" | sed '/sudo/d' | tail -n 1)
|
||||
[[ -n $pre_pid ]] && shell_pid=$(echo $pre_pid | awk '{print $2}')
|
||||
[[ -n $shell_pid && -f /proc/$shell_pid/cmdline ]] && shell_current=$(tr -d '\000' < /proc/$shell_pid/cmdline)
|
||||
[[ -n $shell_pid && -f /proc/$shell_pid/status ]] && shell_status=$(grep -Eo '^Name:.*bash.*' /proc/$shell_pid/status) # Double check!!!
|
||||
|
||||
if [[ -n $shell_current && $shell_current != *"bash"* && -z $shell_status ]]; then
|
||||
echo "${red}[WARNING] Seems like you are using an interactive shell different than BASH! ${dim}($(echo $pre_pid | awk '{print $1}'):${shell_current}) ${end}"
|
||||
# Admin Tools Path
|
||||
if [[ -n $(conf_read tools-port) && -n $(conf_read tools-site) && -f /etc/nginx/sites-available/$(conf_read tools-site) ]]; then
|
||||
readonly ADMIN_TOOLS_SITE="$(conf_read tools-site):$(conf_read tools-port)"
|
||||
else
|
||||
if [[ -n $(conf_read tools-port) ]]; then
|
||||
readonly ADMIN_TOOLS_SITE="default:$(conf_read tools-port)"
|
||||
else
|
||||
# Fresh installation, dynvar is empty!
|
||||
readonly ADMIN_TOOLS_SITE="default:${tools_port_default}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# STOP and exit if not root or sudo.
|
||||
if [[ $(whoami) != "root" ]]; then
|
||||
echo "${red}Please run this script as root or using sudo.${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
# ***********************************************
|
||||
# General Functions ***************************
|
||||
|
@ -328,13 +342,11 @@ check_mysql_connection() {
|
|||
elif [[ ${1,,} == "localhost" && $(conf_read mysql) == "true" ]]; then
|
||||
# In case of custom DB user
|
||||
if [[ -n $2 && -n $3 ]]; then
|
||||
local dbu=$2
|
||||
local dbp=$3
|
||||
[[ -n $4 ]] && local query="use $4"
|
||||
sudo mysql --connect-timeout=10 --user=$dbu -p$dbp -e "$query" 2>/dev/null
|
||||
sudo mysql --connect-timeout=10 --user=$2 -p$3 -e "$query" 2>/dev/null
|
||||
[[ $? != "0" ]] && echo "false" || echo "true"
|
||||
else
|
||||
sudo mysql --connect-timeout=10 --user=$dbu -e "$query"
|
||||
sudo mysql --connect-timeout=10 --user=admin -e "$query"
|
||||
if [[ $? != "0" ]]; then
|
||||
echo "${red}============================================" >&2
|
||||
echo " [Error] Database conection failed." >&2
|
||||
|
@ -590,16 +602,26 @@ remove_nginx_default_server() {
|
|||
|
||||
|
||||
check_for_parameters() {
|
||||
# Global variables: domain, tld, subdomain, main_domain, sub_domain, empty_param
|
||||
# Global variables: domain, domain_name, domain_port, tld, subdomain, main_domain, sub_domain, empty_param
|
||||
# Note: domain and domain_name are the same except when port is present (example.com:22), then port is removed from domain_name (example.com)
|
||||
|
||||
# Check for domain parameter if is first parameter and have no hyphen at the begining.
|
||||
if [[ -n $1 && $(echo $1 | cut -c-1) != "-" ]]; then
|
||||
domain=$1
|
||||
domain_name=$1
|
||||
shift
|
||||
|
||||
# Check for port and remove it!
|
||||
domain_port=$(echo $domain | cut -d':' -f 2- -s)
|
||||
if [[ $domain_port =~ ^[0-9]+$ && $domain_port -ge 0 && $domain_port -le 65535 ]]; then
|
||||
domain_name=$(echo $domain | cut -d':' -f 1 -s)
|
||||
else
|
||||
unset domain_port
|
||||
fi
|
||||
|
||||
local count=1
|
||||
while true; do
|
||||
tld=$(echo $domain | cut -d'.' -f ${count}- -s)
|
||||
tld=$(echo $domain_name | cut -d'.' -f ${count}- -s)
|
||||
if grep -Fxq "$tld" /opt/webinoly/lib/public_suffix_list.dat || [ -z $tld ]; then
|
||||
break
|
||||
fi
|
||||
|
@ -608,8 +630,8 @@ check_for_parameters() {
|
|||
[[ $count -gt 2 ]] && subdomain="true" || subdomain="false"
|
||||
|
||||
if [[ $subdomain == "true" && -n $tld ]]; then
|
||||
main_domain=$(echo $domain | cut -d'.' -f $[$count-1]- -s)
|
||||
sub_domain=$(echo $domain | cut -d'.' -f -$[$count-2] -s)
|
||||
main_domain=$(echo $domain_name | cut -d'.' -f $[$count-1]- -s)
|
||||
sub_domain=$(echo $domain_name | cut -d'.' -f -$[$count-2] -s)
|
||||
fi
|
||||
fi
|
||||
|
||||
|
|
65
lib/install
65
lib/install
|
@ -504,28 +504,29 @@ nginx_tool_site() {
|
|||
[[ -z $(conf_read tools-port) ]] && conf_write tools-port $tools_port_default
|
||||
|
||||
# Don't overwrite in case that exist (after purge with keep-data, for instance)
|
||||
if [[ ! -f /etc/nginx/sites-available/$(conf_read tools-port) ]]; then
|
||||
sudo site $(conf_read tools-port) -empty > /dev/null 2>&1
|
||||
sudo cp /opt/webinoly/templates/general/admin_tools.conf /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "s/<port>/$(conf_read tools-port)/g" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
if [[ ! -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]]; then
|
||||
sudo site $ADMIN_TOOLS_SITE -empty > /dev/null 2>&1
|
||||
sudo cp /opt/webinoly/templates/general/admin_tools.conf /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s/<port>/$(conf_read tools-port)/g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s/<admin_tools_sitename>/$ADMIN_TOOLS_SITE/g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo nginx -t && sudo systemctl reload nginx
|
||||
fi
|
||||
|
||||
# Don't overwrite in case that exist (after purge with keep-data, for instance)
|
||||
if [[ ! -f /var/www/$(conf_read tools-port)/htdocs ]]; then
|
||||
if [[ ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs ]]; then
|
||||
# Nginx Status Page
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/nginx_status
|
||||
sudo touch /var/www/$ADMIN_TOOLS_SITE/htdocs/nginx_status
|
||||
|
||||
# Robots.txt file in case someone remove HTTP Auth
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/robots.txt
|
||||
sudo touch /var/www/$ADMIN_TOOLS_SITE/htdocs/robots.txt
|
||||
echo '# Just in case someone remove HTTP Auth protection.
|
||||
Disallow: /' > /var/www/$(conf_read tools-port)/htdocs/robots.txt
|
||||
sudo chmod 644 /var/www/$(conf_read tools-port)/htdocs/robots.txt
|
||||
sudo chown -R www-data:www-data /var/www/$(conf_read tools-port)/htdocs
|
||||
Disallow: /' > /var/www/$ADMIN_TOOLS_SITE/htdocs/robots.txt
|
||||
sudo chmod 644 /var/www/$ADMIN_TOOLS_SITE/htdocs/robots.txt
|
||||
sudo chown -R www-data:www-data /var/www/$ADMIN_TOOLS_SITE/htdocs
|
||||
fi
|
||||
|
||||
# in case php was installed before nginx
|
||||
[[ $(conf_read php) == "true" && ! -f /var/www/$(conf_read tools-port)/htdocs/php/index.php ]] && php_tool_site
|
||||
[[ $(conf_read php) == "true" && ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php ]] && php_tool_site
|
||||
}
|
||||
|
||||
|
||||
|
@ -533,19 +534,19 @@ php_tool_site() {
|
|||
[[ $(conf_read nginx) != "true" ]] && return
|
||||
|
||||
# Just for legacy support when tools site were created only with PHP support, today is created since Nginx always.
|
||||
[[ ! -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && nginx_tool_site
|
||||
[[ ! -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]] && nginx_tool_site
|
||||
|
||||
# Add PHP options in tools site.
|
||||
|
||||
# Status pages
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/ping
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/status
|
||||
sudo touch /var/www/$ADMIN_TOOLS_SITE/htdocs/ping
|
||||
sudo touch /var/www/$ADMIN_TOOLS_SITE/htdocs/status
|
||||
|
||||
#PHP info site
|
||||
sudo mkdir -p /var/www/$(conf_read tools-port)/htdocs/php
|
||||
sudo touch /var/www/$(conf_read tools-port)/htdocs/php/index.php
|
||||
sudo echo '<?php phpinfo(); ?>' >> /var/www/$(conf_read tools-port)/htdocs/php/index.php
|
||||
sudo chown -R www-data:www-data /var/www/$(conf_read tools-port)/htdocs
|
||||
sudo mkdir -p /var/www/$ADMIN_TOOLS_SITE/htdocs/php
|
||||
sudo touch /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php
|
||||
sudo echo '<?php phpinfo(); ?>' >> /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php
|
||||
sudo chown -R www-data:www-data /var/www/$ADMIN_TOOLS_SITE/htdocs
|
||||
}
|
||||
|
||||
|
||||
|
@ -659,22 +660,22 @@ mysql_tool_pma() {
|
|||
api-events_update im7
|
||||
|
||||
echo "${blu}${dim}Downloading phpMyAdmin...${end}"
|
||||
sudo mkdir -p /var/www/$(conf_read tools-port)/htdocs/pma
|
||||
sudo wget --timeout=15 -t 1 -qrO /var/www/$(conf_read tools-port)/htdocs/pma.tar.xz https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.xz
|
||||
sudo mkdir -p /var/www/$ADMIN_TOOLS_SITE/htdocs/pma
|
||||
sudo wget --timeout=15 -t 1 -qrO /var/www/$ADMIN_TOOLS_SITE/htdocs/pma.tar.xz https://www.phpmyadmin.net/downloads/phpMyAdmin-latest-all-languages.tar.xz
|
||||
|
||||
if [[ -s /var/www/$(conf_read tools-port)/htdocs/pma.tar.xz ]]; then
|
||||
sudo tar -xf /var/www/$(conf_read tools-port)/htdocs/pma.tar.xz -C /var/www/$(conf_read tools-port)/htdocs/pma
|
||||
sudo mv /var/www/$(conf_read tools-port)/htdocs/pma/phpMyAdmin-*-all-languages/* /var/www/$(conf_read tools-port)/htdocs/pma/
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/pma/phpMyAdmin-*-all-languages
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/pma/test
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/pma/setup
|
||||
sudo rm /var/www/$(conf_read tools-port)/htdocs/pma.tar.xz
|
||||
if [[ -s /var/www/$ADMIN_TOOLS_SITE/htdocs/pma.tar.xz ]]; then
|
||||
sudo tar -xf /var/www/$ADMIN_TOOLS_SITE/htdocs/pma.tar.xz -C /var/www/$ADMIN_TOOLS_SITE/htdocs/pma
|
||||
sudo mv /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/phpMyAdmin-*-all-languages/* /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/phpMyAdmin-*-all-languages
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/test
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/setup
|
||||
sudo rm /var/www/$ADMIN_TOOLS_SITE/htdocs/pma.tar.xz
|
||||
|
||||
sudo cp /var/www/$(conf_read tools-port)/htdocs/pma/config.sample.inc.php /var/www/$(conf_read tools-port)/htdocs/pma/config.inc.php
|
||||
sudo sed -i "/blowfish_secret/c \$cfg['blowfish_secret'] = '$(pwgen -s -1 32)';" /var/www/$(conf_read tools-port)/htdocs/pma/config.inc.php
|
||||
sudo chown -R www-data:www-data /var/www/$(conf_read tools-port)/htdocs/pma
|
||||
sudo find /var/www/$(conf_read tools-port)/htdocs/pma -type f -print0 | sudo xargs -r -0 chmod 644
|
||||
sudo find /var/www/$(conf_read tools-port)/htdocs/pma -type d -print0 | sudo xargs -r -0 chmod 755
|
||||
sudo cp /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/config.sample.inc.php /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/config.inc.php
|
||||
sudo sed -i "/blowfish_secret/c \$cfg['blowfish_secret'] = '$(pwgen -s -1 32)';" /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/config.inc.php
|
||||
sudo chown -R www-data:www-data /var/www/$ADMIN_TOOLS_SITE/htdocs/pma
|
||||
sudo find /var/www/$ADMIN_TOOLS_SITE/htdocs/pma -type f -print0 | sudo xargs -r -0 chmod 644
|
||||
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}"
|
||||
|
|
|
@ -12,7 +12,6 @@ ssl_nginx() {
|
|||
# Headers
|
||||
sudo sed -i '/header.conf;/c \ include common/headers.conf;' /etc/nginx/sites-available/$domain
|
||||
sudo sed -i '/headers-http.conf/a \ include common/headers-https.conf;' /etc/nginx/sites-available/$domain # In case of Force-Redirect!
|
||||
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i '/header.conf;/c \ include common/headers.conf;' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
for pxy in "/etc/nginx/apps.d/${domain}"*-proxy.conf
|
||||
do
|
||||
[[ -f $pxy ]] && sudo sed -i '/headers-http.conf;/a \ include common/headers-https.conf;' $pxy
|
||||
|
@ -248,7 +247,6 @@ site_ssl_off() {
|
|||
# Headers
|
||||
sudo sed -i '/headers.conf;/c \ include common/header.conf;' /etc/nginx/sites-available/$domain
|
||||
sudo sed -i '/WebinolyWWWredirectStart/,/WebinolyWWWredirectEnd/{/headers-https.conf;/d}' /etc/nginx/sites-available/$domain # In case of Force-Redirect
|
||||
[[ -f /etc/nginx/sites-available/$(conf_read tools-port) ]] && sudo sed -i '/headers.conf;/c \ include common/header.conf;' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
for pxy in "/etc/nginx/apps.d/${domain}"*-proxy.conf
|
||||
do
|
||||
[[ -f $pxy ]] && sudo sed -i '/CacheStaticFiles/,/expires max;/{/headers-https.conf;/d}' $pxy
|
||||
|
|
26
lib/sites
26
lib/sites
|
@ -689,14 +689,15 @@ delete_all_sites() {
|
|||
do
|
||||
[[ ${delete_all,,} == "keep-db" ]] && delete="keep-db" || delete="force"
|
||||
domain=$(echo $site | cut -f 5 -d "/")
|
||||
[[ $domain != "default" && $domain != $(conf_read tools-port) && $domi != *".dpkg-"* ]] && deletesite
|
||||
[[ $domain != "default" && $domain != $ADMIN_TOOLS_SITE && $domi != *".dpkg-"* ]] && deletesite
|
||||
done
|
||||
|
||||
# Delete all files - double check!
|
||||
# -rf is necessary to not generate an error when is empty.
|
||||
sudo rm -rf /etc/nginx/sites-available/!(default|$(conf_read tools-port)|*".dpkg-"*)
|
||||
sudo rm -rf /etc/nginx/sites-enabled/!(default|$(conf_read tools-port))
|
||||
sudo rm -rf /var/www/!(html|$(conf_read tools-port))
|
||||
# Tools-Site must be always default at this point. (don't use the global var, because this value can change on the fly if tools-site domain/site was deleted)
|
||||
sudo rm -rf /etc/nginx/sites-available/!(default|default:$(conf_read tools-port)|*".dpkg-"*)
|
||||
sudo rm -rf /etc/nginx/sites-enabled/!(default|default:$(conf_read tools-port))
|
||||
sudo rm -rf /var/www/!(html|default:$(conf_read tools-port))
|
||||
sudo rm -rf /etc/nginx/conf.d/upstream_proxy.conf
|
||||
echo ""
|
||||
echo "${gre}All sites and data has been deleted successfully!${end}"
|
||||
|
@ -722,11 +723,22 @@ createsite() {
|
|||
[[ -z $tld ]] && echo "${dim}[WARNING] Domain name is not a valid TLD (Top Level Domain).${end}"
|
||||
|
||||
# Check domain and then prevent reserved characters for file names.
|
||||
if [[ $(is_domain $domain) != "true" ]]; then
|
||||
is_url $domain -split
|
||||
if [[ -n $url_scheme || -n $url_path ]]; then
|
||||
echo "${red}[ERROR] Domain names should not contain scheme or path. ${dim}(Use example.com instead of https://example.com/path) ${end}"
|
||||
exit 1
|
||||
fi
|
||||
if [[ $(is_domain $domain_name) != "true" ]]; then
|
||||
echo "${red}[ERROR] Domain names can only contain letters, numbers or a hyphen; can not start or end with a hyphen or period or having two periods together, and can be up to 67 characters long.${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Temporal check: sites with custom port not allowed, only for admin tools site.
|
||||
if [[ -n $url_port && $domain != $ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${red}[ERROR] Sites with custom port are not allowed! ${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Check for reserved domain names
|
||||
if [[ $domain == "default" ]]; then
|
||||
echo "${red}[ERROR] Domain name reserved!${end}"
|
||||
|
@ -790,7 +802,7 @@ createsite() {
|
|||
fi
|
||||
|
||||
# Check if only-error log is enabled
|
||||
if [[ $(conf_read global-access-log-off) == "true" && $domain != $(conf_read tools-port) ]]; then
|
||||
if [[ $(conf_read global-access-log-off) == "true" && $domain != $ADMIN_TOOLS_SITE ]]; then
|
||||
sudo log $domain -only-error=on > /dev/null 2>&1
|
||||
else
|
||||
sudo log $domain -only-error=off > /dev/null 2>&1
|
||||
|
@ -1864,7 +1876,7 @@ list_sites() {
|
|||
for site in "/etc/nginx/sites-available"/*
|
||||
do
|
||||
local domi=$(echo $site | cut -f 5 -d "/")
|
||||
[[ $domi == "default" || $domi == $(conf_read tools-port) || $domi == *".dpkg-"* ]] && continue
|
||||
[[ $domi == "default" || $domi == $ADMIN_TOOLS_SITE || $domi == *".dpkg-"* ]] && continue
|
||||
|
||||
if [[ $list != "true" ]]; then
|
||||
[[ ${list,,} == "disabled" && -L /etc/nginx/sites-enabled/$domi ]] && continue
|
||||
|
|
21
lib/update
21
lib/update
|
@ -7,6 +7,8 @@ echo "${bol}"
|
|||
read -n 1 -s -r -p "Press any key to continue..."
|
||||
echo ""
|
||||
echo "${end}${dim}This is going to take a little bit of time...${end}"
|
||||
conf_write stack-update running
|
||||
api-events_update wysus
|
||||
sleep 1
|
||||
|
||||
|
||||
|
@ -316,11 +318,24 @@ oneseven_to_oneight() {
|
|||
|
||||
# Remove the old kernel method
|
||||
sudo sed -i '/WebinolyStart/,/WebinolyEnd/{/.*/d}' /etc/sysctl.conf
|
||||
|
||||
# New Admin Tools site!
|
||||
if [[ -n $(conf_read tools-port) && -d /var/www/$(conf_read tools-port) && -f /etc/nginx/sites-available/$(conf_read tools-port) ]]; then
|
||||
sudo mkdir -p /var/www/$ADMIN_TOOLS_SITE
|
||||
sudo cp -rp /var/www/$(conf_read tools-port)/* /var/www/$ADMIN_TOOLS_SITE
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)
|
||||
sudo mv /etc/nginx/sites-available/$(conf_read tools-port) /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo rm -rf /etc/nginx/sites-enabled/$(conf_read tools-port)
|
||||
sudo ln -s /etc/nginx/sites-available/$ADMIN_TOOLS_SITE /etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s#www/$(conf_read tools-port)/htdocs#www/$ADMIN_TOOLS_SITE/htdocs#g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s#$(conf_read tools-port).access.log#${ADMIN_TOOLS_SITE}.access.log#g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s#$(conf_read tools-port).error.log#${ADMIN_TOOLS_SITE}.error.log#g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
# Fix permissions not needed - it will be done in server-reset later!
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
# New MySQL login: here to prevent errors during update process!
|
||||
[[ ${oldver//.} -lt 18 && $(conf_read mysql) == "true" ]] && sudo webinoly -server-reset=mysql
|
||||
|
||||
|
||||
# Version numbers without point
|
||||
[[ ${oldver//.} -lt 11 ]] && onezero_to_oneone
|
||||
|
@ -332,5 +347,7 @@ oneseven_to_oneight() {
|
|||
[[ ${oldver//.} -lt 17 ]] && onesix_to_oneseven
|
||||
[[ ${oldver//.} -lt 18 ]] && oneseven_to_oneight
|
||||
|
||||
api-events_update wysue
|
||||
conf_delete stack-update
|
||||
sudo webinoly -server-reset
|
||||
echo "${gre}Your server-configuration has been successfully updated!${end}"
|
||||
|
|
51
lib/verify
51
lib/verify
|
@ -2,6 +2,11 @@
|
|||
|
||||
|
||||
webinoly_verify() {
|
||||
# Not run when update stack is running!
|
||||
if [[ $(conf_read stack-update) == "running" ]]; then
|
||||
echo "${blu}${dim}Verify skipped because update stack is in process...${end}"
|
||||
return
|
||||
fi
|
||||
|
||||
# Webinoly Verify command
|
||||
echo "${blu}${dim}Verifying integrity of the entire Webinoly system...${end}${red}"
|
||||
|
@ -379,20 +384,28 @@ fi
|
|||
|
||||
# NGINX tools site
|
||||
if [[ $(conf_read nginx) == "true" ]]; then
|
||||
if [[ ! -f /etc/nginx/sites-available/$(conf_read tools-port) && $(conf_read php) == "true" ]]; then
|
||||
echo "- [ERROR] File: /etc/nginx/sites-available/$(conf_read tools-port) not found!"
|
||||
if [[ -z $ADMIN_TOOLS_SITE ]]; then
|
||||
echo "- [ERROR] ADMIN_TOOLS_SITE variable is corrupted!" # You never know!
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
if [[ ! -d /var/www/$(conf_read tools-port) && $(conf_read php) == "true" ]]; then
|
||||
echo "- [ERROR] Folder: /var/www/$(conf_read tools-port) not found!"
|
||||
if [[ -n $(conf_read tools-port) && -n $(conf_read tools-site) && ( ! -f /etc/nginx/sites-available/$(conf_read tools-site) || ! -f /etc/nginx/sites-enabled/$(conf_read tools-site) ) ]]; then
|
||||
echo "- [ERROR] Tools-Site seems to have a domain configured, but this site does not exist! ($(conf_read tools-site))"
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
if [[ ! -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]]; then
|
||||
echo "- [ERROR] File: /etc/nginx/sites-available/$ADMIN_TOOLS_SITE not found!"
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
if [[ ! -d /var/www/$ADMIN_TOOLS_SITE ]]; then
|
||||
echo "- [ERROR] Folder: /var/www/$ADMIN_TOOLS_SITE not found!"
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
if [[ -z $(conf_read tools-port) ]]; then
|
||||
echo "- [ERROR] Port Tools is not set or not found!"
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
if [[ ! -f /var/www/$(conf_read tools-port)/htdocs/nginx_status && $(conf_read php) == "true" ]]; then
|
||||
echo "- [ERROR] File: /var/www/$(conf_read tools-port)/htdocs/nginx_status not found!"
|
||||
if [[ ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs/nginx_status ]]; then
|
||||
echo "- [ERROR] File: /var/www/$ADMIN_TOOLS_SITE/htdocs/nginx_status not found!"
|
||||
local ver_two_err="1"
|
||||
fi
|
||||
fi
|
||||
|
@ -411,7 +424,7 @@ if [[ -z $critical_mode ]]; then
|
|||
fi
|
||||
|
||||
if [[ $(conf_read nginx) != "true" && -n $(conf_read tools-port) ]]; then
|
||||
if [[ -f /etc/nginx/sites-available/$(conf_read tools-port) || -d /var/www/$(conf_read tools-port) ]]; then
|
||||
if [[ -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE || -d /var/www/$ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${dim}- [WARNING] Seems like Nginx Tools are enabled but Webinoly can not detect it!${end}${red}"
|
||||
local ver_two_war="1"
|
||||
fi
|
||||
|
@ -515,16 +528,16 @@ fi
|
|||
|
||||
# PHP Tools
|
||||
if [[ $(conf_read php) == "true" && $(conf_read nginx) == "true" ]]; then
|
||||
if [[ ! -f /var/www/$(conf_read tools-port)/htdocs/ping ]]; then
|
||||
echo "- [ERROR] File: /var/www/$(conf_read tools-port)/htdocs/ping not found!"
|
||||
if [[ ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs/ping ]]; then
|
||||
echo "- [ERROR] File: /var/www/$ADMIN_TOOLS_SITE/htdocs/ping not found!"
|
||||
local ver_three_err="1"
|
||||
fi
|
||||
if [[ ! -f /var/www/$(conf_read tools-port)/htdocs/status ]]; then
|
||||
echo "- [ERROR] File: /var/www/$(conf_read tools-port)/htdocs/status not found!"
|
||||
if [[ ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs/status ]]; then
|
||||
echo "- [ERROR] File: /var/www/$ADMIN_TOOLS_SITE/htdocs/status not found!"
|
||||
local ver_three_err="1"
|
||||
fi
|
||||
if [[ ! -f /var/www/$(conf_read tools-port)/htdocs/php/index.php ]]; then
|
||||
echo "- [ERROR] File: /var/www/$(conf_read tools-port)/htdocs/php/index.php not found!"
|
||||
if [[ ! -f /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php ]]; then
|
||||
echo "- [ERROR] File: /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php not found!"
|
||||
local ver_three_err="1"
|
||||
fi
|
||||
fi
|
||||
|
@ -536,11 +549,11 @@ if [[ -z $critical_mode ]]; then
|
|||
fi
|
||||
|
||||
if [[ $(conf_read php) != "true" && $(conf_read nginx) == "true" ]]; then
|
||||
if [[ -f /var/www/$(conf_read tools-port)/htdocs/status ]]; then
|
||||
if [[ -f /var/www/$ADMIN_TOOLS_SITE/htdocs/status ]]; then
|
||||
echo "${dim}- [WARNING] Seems like PHP Tools are enabled but Webinoly can not detect it!${end}${red}"
|
||||
local ver_three_war="1"
|
||||
fi
|
||||
if [[ -f /var/www/$(conf_read tools-port)/htdocs/php/index.php ]]; then
|
||||
if [[ -f /var/www/$ADMIN_TOOLS_SITE/htdocs/php/index.php ]]; then
|
||||
echo "${dim}- [WARNING] Seems like PHP Tools are enabled but Webinoly can not detect it!${end}${red}"
|
||||
local ver_three_war="1"
|
||||
fi
|
||||
|
@ -687,7 +700,7 @@ if [[ -z $critical_mode ]]; then
|
|||
local ver_four_war="1"
|
||||
fi
|
||||
|
||||
if [[ ( -d /var/www/$(conf_read tools-port)/htdocs/pma || -d /usr/share/phpmyadmin ) && $(conf_read mysql-tool-pma) != "true" ]]; then
|
||||
if [[ ( -d /var/www/$ADMIN_TOOLS_SITE/htdocs/pma || -d /usr/share/phpmyadmin ) && $(conf_read mysql-tool-pma) != "true" ]]; then
|
||||
echo "${dim}- [WARNING] Seems like MySQL Tools (PhpMyAdmin) are enabled but Webinoly can not detect it!${end}${red}"
|
||||
local ver_four_war="1"
|
||||
fi
|
||||
|
@ -880,8 +893,8 @@ if [[ $(conf_read php-tool-redis) == "true" ]]; then
|
|||
fi
|
||||
fi
|
||||
|
||||
if [[ $(conf_read mysql-tool-pma) == "true" && ! -d /var/www/$(conf_read tools-port)/htdocs/pma ]]; then
|
||||
echo "- [ERROR] Folder: /var/www/$(conf_read tools-port)/htdocs/pma not found!"
|
||||
if [[ $(conf_read mysql-tool-pma) == "true" && ! -d /var/www/$ADMIN_TOOLS_SITE/htdocs/pma ]]; then
|
||||
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
|
||||
|
@ -1052,7 +1065,7 @@ if [[ -z $critical_mode ]]; then
|
|||
for ver_site in "/etc/nginx/sites-available"/*
|
||||
do
|
||||
local ver_domi=$(echo $ver_site | cut -f 5 -d "/")
|
||||
if [[ $ver_domi != "html" && $ver_domi != $(conf_read tools-port) ]]; then
|
||||
if [[ $ver_domi != "html" && $ver_domi != $ADMIN_TOOLS_SITE ]]; then
|
||||
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
|
||||
echo "${blu}${dim}- [INFO] HTTP Authentication Credentials not found for $ver_domi${end}${red}"
|
||||
|
|
117
lib/webin
117
lib/webin
|
@ -75,12 +75,12 @@ system_info() {
|
|||
if [[ $(conf_read mysql) == "true" ]]; then
|
||||
|
||||
# Check if file exist because in legacy it doesn't!
|
||||
if [[ $(conf_read mysql-tool-pma) == "true" && -f /var/www/$(conf_read tools-port)/htdocs/pma/libraries/classes/Version.php ]]; then
|
||||
local pmaver=$(grep -E "public const VERSION = '[0-9\.]+'.*;" /var/www/$(conf_read tools-port)/htdocs/pma/libraries/classes/Version.php | cut -f 2 -d "'")
|
||||
if [[ $(conf_read mysql-tool-pma) == "true" && -f /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/libraries/classes/Version.php ]]; then
|
||||
local pmaver=$(grep -E "public const VERSION = '[0-9\.]+'.*;" /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/libraries/classes/Version.php | cut -f 2 -d "'")
|
||||
|
||||
# Legacy support: before v5.1.0 (Feb 23, 2021) version is found here:
|
||||
elif [[ $(conf_read mysql-tool-pma) == "true" ]]; then
|
||||
local pmaver=$(grep -e "\$this->set('PMA_VERSION',.*'[0-9\.]*');" /var/www/$(conf_read tools-port)/htdocs/pma/libraries/classes/Config.php | cut -f 4 -d "'")
|
||||
local pmaver=$(grep -e "\$this->set('PMA_VERSION',.*'[0-9\.]*');" /var/www/$ADMIN_TOOLS_SITE/htdocs/pma/libraries/classes/Config.php | cut -f 4 -d "'")
|
||||
|
||||
elif [[ $(conf_read mysql-tool-pma) != "true" ]]; then
|
||||
local pmaver="Not installed!"
|
||||
|
@ -530,21 +530,28 @@ change_tools_port() {
|
|||
if [[ -z $port || ( -n $oldport && $port == $oldport ) ]]; then
|
||||
echo "${gre}Tools-Port not changed! ${end}"
|
||||
elif [[ $port =~ ^[0-9]+$ && $port -ge 0 && $port -le 65535 ]]; then
|
||||
if [[ -f /etc/nginx/sites-available/$port ]]; then
|
||||
echo "${red}[ERROR] Conflict naming found $tools_port sitename is already in use!${end}"
|
||||
if [[ -n $(conf_read tools-site) && -f /etc/nginx/sites-available/$(conf_read tools-site) ]]; then
|
||||
readonly NEW_ADMIN_TOOLS_SITE="$(conf_read tools-site):${port}"
|
||||
else
|
||||
readonly NEW_ADMIN_TOOLS_SITE="default:${port}"
|
||||
fi
|
||||
|
||||
if [[ -f /etc/nginx/sites-available/$NEW_ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${red}[ERROR] Conflict naming found $NEW_ADMIN_TOOLS_SITE sitename is already in use!${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [[ $(conf_read nginx) == "true" && -d /var/www/$oldport ]]; then
|
||||
if [[ $(conf_read nginx) == "true" && -d /var/www/$ADMIN_TOOLS_SITE ]]; then
|
||||
# MV in some edge cases fails to rename, specially when so much files are within the directories.
|
||||
sudo mkdir -p /var/www/$port
|
||||
sudo cp -rp /var/www/$oldport/* /var/www/$port
|
||||
sudo rm -rf /var/www/$oldport
|
||||
sudo mkdir -p /var/www/$NEW_ADMIN_TOOLS_SITE
|
||||
sudo cp -rp /var/www/$ADMIN_TOOLS_SITE/* /var/www/$NEW_ADMIN_TOOLS_SITE
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE
|
||||
|
||||
sudo mv /etc/nginx/sites-available/$oldport /etc/nginx/sites-available/$port
|
||||
sudo rm /etc/nginx/sites-enabled/$oldport
|
||||
sudo ln -s /etc/nginx/sites-available/$port /etc/nginx/sites-enabled/$port
|
||||
sudo sed -i "s/${oldport}/${port}/g" /etc/nginx/sites-available/$port
|
||||
sudo mv /etc/nginx/sites-available/$ADMIN_TOOLS_SITE /etc/nginx/sites-available/$NEW_ADMIN_TOOLS_SITE
|
||||
sudo rm /etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE
|
||||
sudo ln -s /etc/nginx/sites-available/$NEW_ADMIN_TOOLS_SITE /etc/nginx/sites-enabled/$NEW_ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s/${oldport}/${port}/g" /etc/nginx/sites-available/$NEW_ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s/$ADMIN_TOOLS_SITE/$NEW_ADMIN_TOOLS_SITE/g" /etc/nginx/sites-available/$NEW_ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
conf_write tools-port $port
|
||||
|
@ -567,68 +574,94 @@ set_tools_site() {
|
|||
if [[ -z $tools_site ]]; then
|
||||
echo "${red}[ERROR] Please, enter a valid value!${end}"
|
||||
exit 1
|
||||
elif [[ -f /etc/nginx/sites-available/$tools_site && -f /etc/nginx/sites-available/$(conf_read tools-port) && $tools_site != "default" ]]; then
|
||||
elif [[ $tools_site == $(conf_read tools-site) ]]; then
|
||||
echo "${gre}Tools-Site not changed! ${end}"
|
||||
elif [[ -f /etc/nginx/sites-available/$tools_site && -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE && $tools_site != "default" ]]; then
|
||||
# Check for previous assigned domain and remove
|
||||
if [[ -n $(conf_read tools-site) ]]; then
|
||||
sudo sed -i '/server_name/d' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/server_name/d' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
# In case SSL is enabled
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) default_server deferred;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port) default_server;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/headers-https.conf/d' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/.*/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) default_server deferred;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port) default_server;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i '/headers-https.conf/d' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE # For legacy (old sites) support!
|
||||
sudo sed -i '/headers.conf;/c \ include common/header.conf;' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/.*/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i '/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/.*/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
# Assign new domain/site
|
||||
sername=$(sed -n -e '/WebinolyNginxServerStart/,$p' /etc/nginx/sites-available/$tools_site | grep -F "server_name" | sed -e 's/^[ \t]*//')
|
||||
sudo sed -i "/error_log/a \ ${sername}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) deferred;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port);" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/error_log/a \ ${sername}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) deferred;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port);" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "s/$ADMIN_TOOLS_SITE/${tools_site}:$(conf_read tools-port)/g" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
|
||||
# If SSL is enabled
|
||||
if [[ $(is_ssl $tools_site) == "true" ]]; then
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) ssl http2 deferred;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port) ssl http2;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/server_name /r /opt/webinoly/templates/template-site-ssl' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/listen $(conf_read tools-port)/c \ listen $(conf_read tools-port) ssl http2 deferred;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/listen \[::\]:$(conf_read tools-port)/c \ listen [::]:$(conf_read tools-port) ssl http2;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i '/server_name /r /opt/webinoly/templates/template-site-ssl' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
|
||||
local ssl_cer=$(sed -n -e '/WebinolyNginxServerStart/,$p' /etc/nginx/sites-available/$tools_site | grep -F "ssl_certificate " | tr -d '\t')
|
||||
local ssl_key=$(sed -n -e '/WebinolyNginxServerStart/,$p' /etc/nginx/sites-available/$tools_site | grep -F "ssl_certificate_key " | tr -d '\t')
|
||||
local ssl_tru=$(sed -n -e '/WebinolyNginxServerStart/,$p' /etc/nginx/sites-available/$tools_site | grep -F "ssl_trusted_certificate " | tr -d '\t')
|
||||
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_certificate .*;#$ssl_cer#}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_certificate_key .*;#$ssl_key#}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_certificate .*;#$ssl_cer#}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_certificate_key .*;#$ssl_key#}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
|
||||
if [[ -z $ssl_tru ]]; then
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/ssl_stapling/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/ssl_trusted_certificate/d}' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/ssl_stapling/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i '/WebinolySSLstart/,/WebinolySSLend/{/ssl_trusted_certificate/d}' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
else
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_trusted_certificate .*;#$ssl_tru#}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolySSLstart/,/WebinolySSLend/{s#ssl_trusted_certificate .*;#$ssl_tru#}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
fi
|
||||
|
||||
sudo sed -i '/locations.conf/a \ include common/headers-https.conf;' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolySSLend/i \ error_page 497 https:\/\/\$host:\$server_port\$request_uri;" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/header.conf;/c \ include common/headers.conf;' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/WebinolySSLend/i \ error_page 497 https:\/\/\$host:\$server_port\$request_uri;" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
create_blackhole_cert
|
||||
fi
|
||||
|
||||
# Default blackhole for requests different from our assigned Tools-Site
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-blackhole' /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{s/<port>/$(conf_read tools-port)/}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i '/Webinoly Admin-Tools NGINX CONFIGURATION/r /opt/webinoly/templates/general/tools-site-blackhole' /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{s/<port>/$(conf_read tools-port)/}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
if [[ $(is_ssl $tools_site) == "false" ]]; then
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/ssl_certificate/d}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/error_page/d}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{s/ssl //}" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/ssl_certificate/d}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{/error_page/d}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo sed -i "/WebinolyToolsStartBlackhole/,/WebinolyToolsEndBlackhole/{s/ssl //}" /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
echo "${red}It's highly recommended having an SSL Cert enabled on this site. ${end}"
|
||||
fi
|
||||
|
||||
# MV in some edge cases fails to rename, specially when so much files are within the directories.
|
||||
sudo mkdir -p /var/www/${tools_site}:$(conf_read tools-port)
|
||||
sudo cp -rp /var/www/$ADMIN_TOOLS_SITE/* /var/www/${tools_site}:$(conf_read tools-port)
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE
|
||||
sudo mv /etc/nginx/sites-available/$ADMIN_TOOLS_SITE /etc/nginx/sites-available/${tools_site}:$(conf_read tools-port)
|
||||
sudo rm -rf /etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE
|
||||
sudo ln -s /etc/nginx/sites-available/${tools_site}:$(conf_read tools-port) /etc/nginx/sites-enabled/${tools_site}:$(conf_read tools-port)
|
||||
|
||||
sudo chown -R www-data:www-data /var/www
|
||||
[[ $(conf_read login-www-data) == "true" ]] && sudo chown root:root /var/www
|
||||
|
||||
conf_write tools-site $tools_site
|
||||
echo "${gre}Domain${blu} ${tools_site}:$(conf_read tools-port) ${gre}was successfully assigned to access your server tools!${end}"
|
||||
elif [[ $tools_site == "default" ]]; then
|
||||
sudo rm -rf /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo cp /opt/webinoly/templates/general/admin_tools.conf /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
sudo sed -i "s/<port>/$(conf_read tools-port)/g" /etc/nginx/sites-available/$(conf_read tools-port)
|
||||
# MV in some edge cases fails to rename, specially when so much files are within the directories.
|
||||
sudo mkdir -p /var/www/default:$(conf_read tools-port)
|
||||
sudo cp -rp /var/www/$ADMIN_TOOLS_SITE/* /var/www/default:$(conf_read tools-port)
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE
|
||||
sudo rm -rf /etc/nginx/sites-available/$ADMIN_TOOLS_SITE
|
||||
sudo cp /opt/webinoly/templates/general/admin_tools.conf /etc/nginx/sites-available/default:$(conf_read tools-port)
|
||||
sudo sed -i "s/<port>/$(conf_read tools-port)/g" /etc/nginx/sites-available/default:$(conf_read tools-port)
|
||||
sudo sed -i "s/<admin_tools_sitename>/default:$(conf_read tools-port)/g" /etc/nginx/sites-available/default:$(conf_read tools-port)
|
||||
sudo rm -rf /etc/nginx/sites-enabled/$ADMIN_TOOLS_SITE
|
||||
sudo ln -s /etc/nginx/sites-available/default:$(conf_read tools-port) /etc/nginx/sites-enabled/default:$(conf_read tools-port)
|
||||
|
||||
sudo chown -R www-data:www-data /var/www
|
||||
[[ $(conf_read login-www-data) == "true" ]] && sudo chown root:root /var/www
|
||||
|
||||
conf_write tools-site default
|
||||
echo "${gre}Tools Site settings has been reset successfully!${end}"
|
||||
elif [[ -f /etc/nginx/sites-available/$tools_site && ! -f /etc/nginx/sites-available/$(conf_read tools-port) ]]; then
|
||||
elif [[ -f /etc/nginx/sites-available/$tools_site && ! -f /etc/nginx/sites-available/$ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${red}[ERROR] Tools Site is not enabled! ${end}"
|
||||
exit 1
|
||||
else
|
||||
|
|
|
@ -5,10 +5,10 @@ server {
|
|||
listen <port> default_server deferred;
|
||||
listen [::]:<port> default_server;
|
||||
|
||||
access_log /var/log/nginx/<port>.access.log we_log;
|
||||
error_log /var/log/nginx/<port>.error.log;
|
||||
access_log /var/log/nginx/<admin_tools_sitename>.access.log we_log;
|
||||
error_log /var/log/nginx/<admin_tools_sitename>.error.log;
|
||||
|
||||
root /var/www/<port>/htdocs;
|
||||
root /var/www/<admin_tools_sitename>/htdocs;
|
||||
index index.php index.htm index.html;
|
||||
|
||||
autoindex on;
|
||||
|
@ -24,14 +24,14 @@ server {
|
|||
stub_status on;
|
||||
access_log off;
|
||||
}
|
||||
location ~ ^/(status|ping)$ {
|
||||
location ~* ^/(status|ping)$ {
|
||||
try_files $uri =404;
|
||||
include fastcgi_params;
|
||||
fastcgi_pass php;
|
||||
}
|
||||
|
||||
# phpMyAdmin protection
|
||||
location ~ ^/pma/(libraries|templates) {
|
||||
location ~* ^/pma/(libraries|templates) {
|
||||
autoindex off;
|
||||
deny all;
|
||||
access_log off;
|
||||
|
|
2
usr/log
2
usr/log
|
@ -238,7 +238,7 @@ elif [[ -n $only_error ]]; then
|
|||
# Per site
|
||||
if [[ -n $domain && -f /etc/nginx/sites-available/$domain ]]; then
|
||||
check_for_nginx
|
||||
if [[ $domain == "default" || $domain == $(conf_read tools-port) ]]; then
|
||||
if [[ $domain == "default" || $domain == $ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${red}[ERROR] Only-Error is not allowed to be used in Tools-Port or Default Nginx site! ${end}"
|
||||
exit 1
|
||||
fi
|
||||
|
|
2
usr/site
2
usr/site
|
@ -427,7 +427,7 @@ elif [[ -n $cache && -f /etc/nginx/sites-available/$domain ]]; then
|
|||
# Delete site (should be here after cache for precedence)
|
||||
elif [[ -n $delete && -f /etc/nginx/sites-available/$domain ]]; then
|
||||
api-events_update si6
|
||||
if [[ $domain == "default" || $domain == $(conf_read tools-port) ]]; then
|
||||
if [[ $domain == "default" || $domain == $ADMIN_TOOLS_SITE ]]; then
|
||||
echo "${red}[ERROR] System sites can not be removed!${end}"
|
||||
exit 1
|
||||
elif [[ -n $subfolder ]]; then
|
||||
|
|
10
usr/stack
10
usr/stack
|
@ -202,10 +202,10 @@ elif [[ -n $purge && -n $php ]]; then
|
|||
sudo rm -rf /opt/webinoly/templates/source/main.cf
|
||||
|
||||
# Remove tools-site
|
||||
if [[ -d /var/www/$(conf_read tools-port)/htdocs ]]; then
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/status
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/ping
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/php
|
||||
if [[ -d /var/www/$ADMIN_TOOLS_SITE/htdocs ]]; then
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/status
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/ping
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/php
|
||||
fi
|
||||
|
||||
conf_write php purged
|
||||
|
@ -531,7 +531,7 @@ elif [[ -n $purge && -n $pma ]]; then
|
|||
fi
|
||||
|
||||
if [[ $answer == [Yy] || $(conf_read force-flag) == "true" ]]; then
|
||||
sudo rm -rf /var/www/$(conf_read tools-port)/htdocs/pma
|
||||
sudo rm -rf /var/www/$ADMIN_TOOLS_SITE/htdocs/pma
|
||||
conf_write mysql-tool-pma purged
|
||||
echo ""
|
||||
echo "${gre}phpMyAdmin has been deleted successfully! ${end}"
|
||||
|
|
2
weby
2
weby
|
@ -174,7 +174,7 @@ fi
|
|||
[[ $setup == 1 ]] && stack -nginx
|
||||
[[ $setup == 2 ]] && stack -php=nginx
|
||||
[[ $setup == 3 ]] && stack -lemp
|
||||
[[ $setup != [123] && -n $(conf_read stack-build-error-flag) ]] && sudo webinoly -verify=critical
|
||||
[[ $setup != [123] ]] && sudo webinoly -verify=critical
|
||||
|
||||
# Message Center
|
||||
if [[ -z $(conf_read stack-build-error-flag) ]]; then
|
||||
|
|
Loading…
Reference in a new issue