delete site w ext-db unattended

Delete site with external database now is unattended.
This commit is contained in:
Cristhian Martínez Ochoa 2018-04-04 13:49:24 -05:00
parent 4e26e73afe
commit a0a8981f0c
2 changed files with 21 additions and 8 deletions

View file

@ -56,13 +56,19 @@ db_delete() {
echo "${gre}Database of your site ${blu}${domain}${gre} has been successfully deleted! ${end}"
fi
else
echo ""
echo "${gre}External DB found in $domain (Press 'Enter' key twice to skip and not delete)"
read -p "${blu}External DB root username [root]: " uroot
uroot=${uroot:-root}
read -p "External DB root password: " proot
if [[ $dbdatadel == "true" ]]; then
local dbdatauser=$(echo "${dbdata}" | cut -d',' -f 3 -s)
local dbdatapass=$(echo "${dbdata}" | cut -d',' -f 4 -s)
fi
if [[ -z $dbdatauser || -z $dbdatapass ]]; then
echo ""
echo "${gre}External DB found in $domain (Press 'Enter' key twice to skip and not delete)"
read -p "${blu}External DB root username [root]: " uroot
uroot=${uroot:-root}
read -p "External DB root password: " proot
fi
if [[ $uroot == "root" && -z $proot ]]; then
echo "${red} Action aborted!"
echo "${red} Action aborted, database not deteted!"
continue 1;
else
sudo mysql --connect-timeout=10 -h "$url" -P "$port" -u"$uroot" -p"$proot" -e "$dbsetup"

View file

@ -415,16 +415,23 @@ _EOF_
deletesite() {
if [[ -n $value ]]; then
dbdata=${value:1:-1}
local dbdatahost=$(echo "${dbdata}" | cut -d',' -f 1 -s)
[[ $dbdatahost == "external" ]] && dbdatadel=$(echo "${dbdata}" | cut -d',' -f 2 -s)
[[ $dbdatadel =~ ^(true|false)$ || $value == "force" ]] && local skip="true"
fi
# Determine if site is WP, so you should delete the DB too.
if [[ -a /var/www/$domain/wp-config.php || -a /var/www/$domain/htdocs/wp-config.php ]]; then
if [[ $value != "force" ]]; then
if [[ $skip != "true" ]]; then
echo "${blu}Delete Database [Y/n]?${end}"
while read -r -n 1 -s dbdel; do
local dbdel=${dbdel:-y}
[[ $dbdel = [YyNn] ]] && break
done
else
dbdel="Y"
[[ $dbdatadel != "false" ]] && dbdel="Y"
fi
fi