external db

- Warning when creating site and dbrole is all or grant.
- Better defaults when mysql is not installed.
- Multisite asking several time for external data is now fixed.
- Delete all sites asking for external db data and taking it for all sites is now fixed.
This commit is contained in:
Cristhian Martínez Ochoa 2022-02-26 15:30:59 -07:00
parent 7916d6fa53
commit 770287953b
3 changed files with 29 additions and 12 deletions

View file

@ -378,11 +378,9 @@ external_db_parse() {
# Make it global only after verification
extdb_user=$user
extdb_pass=$pass
if [[ $1 != "-nohost" ]]; then
extdb_host=$host
extdb_url=$url
extdb_port=$port
fi
extdb_host=$host
extdb_url=$url
extdb_port=$port
fi
else
echo "${red}[ERROR] External DB parameter not found!${end}"
@ -520,8 +518,10 @@ wp_conf_retrieve() {
fi
if [[ -n $external_db ]]; then
external_db_parse -nohost
elif [[ -z $external_db && -n $wp_dbhost && $wp_dbhost != "localhost" ]]; then
external_db_parse
[[ "${wp_dbhost}:${wp_dbport}" != $extdb_host ]] && unset external_db
fi
if [[ -z $external_db && -n $wp_dbhost && $wp_dbhost != "localhost" ]]; then
echo "" >&2
echo "${gre}External DB${blu} '${extdb_url}:${extdb_port}' ${gre}found in${blu} $1 ${gre}(Press 'Enter' key twice to skip)" >&2
read -p "${blu}External DB username: " extdb_user

View file

@ -8,6 +8,9 @@ source /opt/webinoly/lib/site-ssl
warning_messages() {
# Warning Messages
if [[ $warning_mes != "true" ]]; then
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
echo "${dim}[WARNING] HTTP Authentication Credentials not found and you may need it to complete the WordPress installation process!!${end}"
fi
@ -139,10 +142,19 @@ wpinstall() {
while [[ $done != "1" ]]
do
done="1"
# Ask DB data or suggest default values
echo "${blu}"
[[ $type == [2345] ]] || read -p "Database Host [localhost]: " dbhost
dbhost=${dbhost:-localhost}
# Ask DB data or suggest default values
[[ $(conf_read mysql) == "true" ]] && local dbhost_suggested="localhost" || local dbhost_suggested="external.host:port"
if [[ -n $(conf_read external-dbh) && -n $(conf_read external-dbu) && -n $(conf_read external-dbp) ]]; then
[[ -n $(conf_read external-dbx) ]] && local dbhost_suggested="$(conf_read external-dbh):$(conf_read external-dbx)" || local dbhost_suggested=$(conf_read external-dbh)
dburoot=$(conf_read external-dbu)
dbproot=$( echo $(conf_read external-dbp) | openssl enc -d -a -salt )
fi
[[ $type == [2345] ]] || read -p "Database Host [${dbhost_suggested}]: " dbhost
dbhost=${dbhost:-$dbhost_suggested}
[[ ${dbhost,,} == "localhost" && $setupmysql == [yY] ]] && check_for_mysql
# In case of external db
@ -176,7 +188,7 @@ wpinstall() {
check_for_mysql_client
echo "${blu}"
if [[ $dbhost != "localhost" && ( $type == 1 || ( $type == [35] && ( -z $dburoot || -z $dbproot ))) ]]; then
if [[ $dbhost != "localhost" && ( $type == [135] && ( -z $dburoot || -z $dbproot )) ]]; then
read -p "External DB username: " dburoot
read -p "External DB password: " dbproot
echo ""

View file

@ -215,7 +215,12 @@ elif [[ -n $multisite_convert && -f /etc/nginx/sites-available/$domain ]]; then
if [[ $(is_wp $domain $subfolder) == "false" ]]; then
echo "${red}[ERROR] Site${blu} $domain$subfolder ${red}is not a WP site!${end}"
exit 1
elif [[ $(is_wp_installed $domain $subfolder) != "true" ]]; then
fi
# We need to call this function in the parent shell to preserve variables and avoid asking two or more times for the same values in case of external db.
wp_conf_retrieve $domain true false $subfolder
if [[ $(is_wp_installed $domain $subfolder) != "true" ]]; then
echo "${red}[ERROR] WordPress site${blu} $domain$subfolder ${red}is empty and still not configured!${end}"
exit 1
elif [[ $(is_parked $domain) == "true" ]]; then