Skip to content

Commit

Permalink
hotfix
Browse files Browse the repository at this point in the history
- Clone from and SSL now check if WP is installed and configured.
- Wrong server names in clone-from.
  • Loading branch information
QROkes committed Feb 27, 2020
1 parent 24d6720 commit ac3a2c5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
25 changes: 22 additions & 3 deletions lib/general
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash

readonly app_version="1.10.2"
readonly app_version="1.10.3"
readonly svr_version="1.4"
readonly os_ubuntu_supported=(xenial bionic)
readonly php_supported=(7.2 7.3 7.4)
Expand Down Expand Up @@ -419,8 +419,8 @@ is_wp_cache() {

is_wp_multisite() {
wp_dbdata $1
dbsetup="SELECT * FROM information_schema.tables WHERE table_schema = '$wp_dbname' AND table_name = '${wp_dbpref}sitemeta' LIMIT 1;"
dbsetuc="USE $wp_dbname; SELECT meta_value FROM ${wp_dbpref}sitemeta where meta_key='subdomain_install';"
local dbsetup="SELECT * FROM information_schema.tables WHERE table_schema = '$wp_dbname' AND table_name = '${wp_dbpref}sitemeta' LIMIT 1;"
local dbsetuc="USE $wp_dbname; SELECT meta_value FROM ${wp_dbpref}sitemeta where meta_key='subdomain_install';"

if [[ $wp_dbhost == "localhost" ]]; then
local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
Expand All @@ -440,6 +440,25 @@ is_wp_multisite() {
fi
}


is_wp_installed() {
# This function check if WP db exists.
# When you create a WP site, DB is created only after the initial WP installation wizard is completed.

wp_dbdata $1
local dbsetup="SELECT * FROM information_schema.tables WHERE table_schema = '$wp_dbname' AND table_name = '${wp_dbpref}options' LIMIT 1;"

if [[ $wp_dbhost == "localhost" ]]; then
local ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
[[ -n $(sudo mysql --connect-timeout=10 --user=root -p$ROOT_PASS -e "$dbsetup") ]] && echo "true" || echo "false"
elif [[ -n $wp_dburl ]]; then
[[ -n $(sudo mysql --connect-timeout=10 -h "$wp_dburl" -P "$wp_dbport" -u"$wp_uroot" -p"$wp_proot" -e "$dbsetup") ]] && echo "true" || echo "false"
else
echo "false"
fi
}


is_proxy() {
[[ -f /etc/nginx/sites-available/$1 && -n $(sed -n -e '/WebinolyNginxServerStart/,$p' /etc/nginx/sites-available/$1 | grep -F "proxy_pass") ]] && echo "true" || echo "false"
}
Expand Down
8 changes: 6 additions & 2 deletions lib/sites
Original file line number Diff line number Diff line change
Expand Up @@ -664,7 +664,7 @@ createsite() {

edit_wp_db_url() {
#Example: edit_wp_db_url example.com "http://${domain}${subfolder}"
if [[ -n $1 && -n $2 && $(is_wp $1) == "true" ]]; then
if [[ -n $1 && -n $2 && $(is_wp $1) == "true" && $(is_wp_installed $1) == "true" ]]; then
doms=$(echo $1$subfolder | sed "s/[^0-9A-Za-z]/_/g")
ROOT_PASS=$( echo $(conf_read mysql-root) | openssl enc -d -a -salt )
wp_dbdata $1
Expand Down Expand Up @@ -1227,6 +1227,10 @@ 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

# Fix server_name according to new domain/site.
[[ $subdomflag == 1 ]] && local sername="server_name $domain;" || local sername="server_name $domain www.$domain;"
sudo sed -i "/server_name /c \ $sername" /etc/nginx/sites-available/$domain

# Prevent if main site is default.
[[ $(conf_read default-site) == $clone_from ]] && remove_nginx_default_server $domain
fi
Expand Down Expand Up @@ -1255,7 +1259,7 @@ clone_wp_site() {
sudo site $domain -replace-content=[https://$clone_from,http://$domain]$arg > /dev/null 2>&1
sudo site $domain -replace-content=[$clone_from,$domain]$arg > /dev/null 2>&1
fi
echo "${gre}Site ${blu}'$domain$subfolder'${gre} is now a successful clone of ${blu}'$clone_from$subfolder'${end}"
echo "${gre}Site ${blu}'$domain$subfolder'${gre} is now a successfull clone of ${blu}'$clone_from$subfolder'${end}"
}


Expand Down
3 changes: 3 additions & 0 deletions plugins/site
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ elif [[ -n $clone_from ]]; then
elif [[ $(is_wp $clone_from $subfolder) != "true" ]]; then
echo "${red}[ERROR] Site${blu} '$clone_from' ${red}is not a WordPress site!${end}"
exit 1
elif [[ $(is_wp_installed $clone_from) != "true" ]]; then
echo "${red}[ERROR] Seems like WordPress is still not configured in your${blu} '$clone_from' ${red}site!${end}"
exit 1
else
clone_wp_site
fi
Expand Down

0 comments on commit ac3a2c5

Please sign in to comment.