From b2cbd82e103a9d3e45e7cac6a259cbb93dc49221 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cristhian=20Mart=C3=ADnez=20Ochoa?= Date: Sat, 7 Nov 2020 17:12:47 -0700 Subject: [PATCH] minor fixes Fix issue with simlynks in home. Fix warning message displayed when db created. Fix clone WP issue when SSL enabled. Fix new logs for mysql not working on mariadb 10.4. Fix mariadb not removing repo when purge stack. --- lib/install | 8 ++++++-- lib/sites | 14 ++++++++------ plugins/log | 3 +-- plugins/site | 2 +- plugins/stack | 7 +++++-- 5 files changed, 21 insertions(+), 13 deletions(-) diff --git a/lib/install b/lib/install index dd6bba4..dd7691b 100644 --- a/lib/install +++ b/lib/install @@ -279,9 +279,13 @@ fastcgi_param HTTP_PROXY ""; fastcgi_param HTTP_ACCEPT_ENCODING ""; # WebinolyCustomEnd' >> /etc/nginx/fastcgi_params + # Current original user HOME even with sudo (root) - This script always run with sudo, so $HOME is always /root + # https://askubuntu.com/questions/1186999/how-does-sudo-handle-home-differently-since-19-10 + local current_home=$(eval echo ~${SUDO_USER:-${USER}}) + # Create Direct Access for easy navigation - [ -L $HOME/sites-available ] || ln -s /etc/nginx/sites-available $HOME - [ -L $HOME/www ] || ln -s /var/www $HOME + [ -L $current_home/sites-available ] || ln -s /etc/nginx/sites-available $current_home + [ -L $current_home/www ] || ln -s /var/www $current_home # www-data sftp default uploads permissions 755 and 644, instead of 775 and 664. sudo sed -i '/USERGROUPS_ENAB/c \USERGROUPS_ENAB no' /etc/login.defs diff --git a/lib/sites b/lib/sites index c29e803..752dcbc 100644 --- a/lib/sites +++ b/lib/sites @@ -11,7 +11,7 @@ warning_messages() { if [[ $type == [123] && $(conf_read wp-admin-auth) != "purged" && ! -s /etc/nginx/.htpasswd && ! -s /etc/nginx/apps.d/.htpasswd-$domain ]]; then echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to complete the WordPress installation process!!${end}" fi - if [[ $(conf_read login-www-data) != "true" && -z $forward && -z $proxy && -z $parked ]]; then + if [[ $(conf_read login-www-data) != "true" && (( -z $forward && -z $proxy && -z $parked && -z $mysql ) || ( -n $mysql && -n $domain )) ]]; then echo "${dim}[WARNING] Login for www-data is not enabled and you may need it to upload your site files!${end}" fi warning_mes="true" @@ -1313,16 +1313,12 @@ clone_wp_site() { sudo ln -s /etc/nginx/sites-available/$domain /etc/nginx/sites-enabled/$domain sudo sed -i "s/$clone_from/$domain/g" /etc/nginx/sites-available/$domain - # Remove custom settings from cloned site - sudo site $domain -subdomain=false -force-redirect=off > /dev/null 2>&1 - [[ $(is_ssl $clone_from) == "true" ]] && revoke="off" && site_ssl_off > /dev/null 2>&1 - [[ $(conf_read default-site) == $clone_from ]] && remove_nginx_default_server $domain - # Fix server_name according to new domain/site. [[ $subdomain == "true" ]] && local sername="server_name $domain;" || local sername="server_name $domain www.$domain;" sudo sed -i "/server_name /c \ $sername" /etc/nginx/sites-available/$domain # Clone Subfolder conf files from apps.d + conf_write nginx-reload false for appfile in /etc/nginx/apps.d/$clone_from*.conf do if [[ -s $appfile ]]; then @@ -1367,6 +1363,12 @@ clone_wp_site() { edit_wp_db_url $domain "http://${domain}${subfolder}" $subfolder fi + # Remove custom settings from cloned site + sudo site $domain -subdomain=false -force-redirect=off > /dev/null 2>&1 + [[ $(is_ssl $clone_from) == "true" ]] && revoke="off" && site_ssl_off > /dev/null 2>&1 + [[ $(conf_read default-site) == $clone_from ]] && remove_nginx_default_server $domain + conf_delete nginx-reload + if [[ $replace_content != "off" ]]; then replace_content="[http://$clone_from,http://$domain]" && wp_replace_content > /dev/null 2>&1 replace_content="[https://$clone_from,https://$domain]" && wp_replace_content > /dev/null 2>&1 diff --git a/plugins/log b/plugins/log index e594968..c74c7fe 100644 --- a/plugins/log +++ b/plugins/log @@ -23,7 +23,6 @@ cnf_delete() { } cnf_write() { #Example: cnf_write error_log /var/log/mysql/error.log - mysql_default_cnf cnf_delete $1 [[ -n $2 ]] && local value="= $2" echo "$1 $value" >> /etc/mysql/mariadb.conf.d/90-webinoly.cnf @@ -118,7 +117,7 @@ elif [[ -n $ssh ]]; then # MySQL Logs elif [[ -n $mysql ]]; then - check_for_mysql + check_for_mysql && mysql_default_cnf # General Log if [[ $mysql == "general" ]]; then diff --git a/plugins/site b/plugins/site index bc3915a..adbbf46 100644 --- a/plugins/site +++ b/plugins/site @@ -469,5 +469,5 @@ else fi shopt -u extglob -[[ $(conf_read nginx) == "true" && -z $nginx_not ]] && sudo service nginx reload +[[ $(conf_read nginx) == "true" && -z $nginx_not && $(conf_read nginx-reload) != "false" ]] && sudo service nginx reload api-events_update sie diff --git a/plugins/stack b/plugins/stack index 0c7fcb0..48c212f 100644 --- a/plugins/stack +++ b/plugins/stack @@ -84,8 +84,10 @@ if [[ -n $purge && ( -n $html || -n $nginx ) ]]; then sudo sed -i '/certbot renew/d' /var/spool/cron/crontabs/root fi sudo apt -y autoremove - sudo rm $HOME/www - sudo rm $HOME/sites-available + + current_home=$(eval echo ~${SUDO_USER:-${USER}}) + [ -L $current_home/www ] && sudo rm $current_home/www + [ -L $current_home/sites-available ] && sudo rm $current_home/sites-available # Remove sources sudo rm -rf /opt/webinoly/templates/source/default @@ -228,6 +230,7 @@ elif [[ -n $purge && -n $mysql ]]; then sudo apt -y purge mariadb-server mariadb-common mysql-common sudo apt -y purge debconf-utils purge_mysql_client + sudo add-apt-repository --remove "http://mirrors.syringanetworks.net/mariadb/repo/${mysqlver}/ubuntu" sudo apt -y autoremove if [[ $mysql != "keep-data" ]]; then