Skip to content

Commit

Permalink
database process improved
Browse files Browse the repository at this point in the history
database data and wp creation improved.
  • Loading branch information
QROkes committed Sep 11, 2019
1 parent c769676 commit 91d5fd3
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 15 deletions.
11 changes: 7 additions & 4 deletions lib/general
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,20 @@ wp_dbdata() {
wp_dbport=$(echo "$wp_dbhost" | cut -f 2 -d ':' -s)
wp_dbpref=$( grep -F "table_prefix" $wpconfpath | cut -f 2 -d "'" -s)

if [[ -n $external_db ]]; then
if [[ -z $external_db && -n $wp_dbhost && $wp_dbhost != "localhost" ]]; then
echo ""
echo "${gre}External DB found in${blu} $domain ${gre}(Press 'Enter' key twice to skip and not delete)"
read -p "${blu}External DB root username [root]: " wp_uroot
wp_uroot=${wp_uroot:-root}
read -p "External DB root password: " wp_proot
elif [[ -n $external_db ]]; then
dbdata=${external_db:1:-1}
wp_uroot=$(echo "${dbdata}" | cut -d',' -f 1 -s)
wp_proot=$(echo "${dbdata}" | cut -d',' -f 2 -s)
if [[ $(echo "${external_db}" | cut -c-1) != "[" || $(echo "${external_db}" | rev | cut -c-1) != "]" || -z $wp_uroot || -z $wp_proot ]]; then
echo "${red}[ERROR] Invalid data for External Database!${end}" >&2
exit 1
fi
elif [[ -z $external_db && -n $wp_dbhost && $wp_dbhost != "localhost" ]]; then
echo "${red}[ERROR] External Database found, please use the '-external-db=[user,password]' option!${end}" >&2
exit 1
fi
}

Expand Down
18 changes: 8 additions & 10 deletions lib/sites
Original file line number Diff line number Diff line change
Expand Up @@ -351,8 +351,13 @@ wpinstall() {
# DB Creation
if [[ "$setupmysql" == [yY] ]] ; then
if [[ $dbhost == "localhost" ]]; then
local dbsetup="CREATE DATABASE $dbname;GRANT ALL PRIVILEGES ON $dbname.* TO $dbuser@$dbhost IDENTIFIED BY '$dbpass';FLUSH PRIVILEGES;"
sudo mysql --connect-timeout=10 --user=root -p$ROOT_PASS -e "$dbsetup"
# Starting with MySQL 8 you no longer can (implicitly) create a user using the GRANT command.
sudo mysql --connect-timeout=10 --user=root -p$ROOT_PASS <<_EOF_
CREATE DATABASE $dbname;
CREATE USER '${dbuser}'@'%' IDENTIFIED BY '${dbpass}';
GRANT ALL PRIVILEGES ON ${dbname}.* TO ${dbuser}@${dbhost} IDENTIFIED BY '${dbpass}';
FLUSH PRIVILEGES;
_EOF_
if [ $? != "0" ]; then
done="0"
echo "${red}============================================"
Expand Down Expand Up @@ -468,13 +473,6 @@ db_delete() {
echo "${gre}Database of your site ${blu}${domain}${subfolder}${gre} has been successfully deleted! ${end}"
fi
else
if [[ -z $wp_uroot || -z $wp_proot ]]; then
echo ""
echo "${gre}External DB found in${blu} $domain ${gre}(Press 'Enter' key twice to skip and not delete)"
read -p "${blu}External DB root username [root]: " wp_uroot
wp_uroot=${wp_uroot:-root}
read -p "External DB root password: " wp_proot
fi
if [[ $wp_uroot == "root" && -z $wp_proot ]]; then
echo "${red}Action aborted, database not deleted!"
continue 1;
Expand Down Expand Up @@ -633,7 +631,7 @@ createsite() {
fi

# Activate FastCgi cache
if [[ ( -n $cache || $cache == "on" ) && $type == [123] ]]; then
if [[ $cache == "on" && $type == [123] ]]; then
sudo sed -i '/php.conf/c \ include common/wpfc.conf;' /etc/nginx/sites-available/$domain
wp_cache_plugins
fi
Expand Down
2 changes: 1 addition & 1 deletion plugins/site
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ elif [[ -n $parked && -n $domain ]]; then
sudo cat /etc/nginx/sites-available/$mapto > /etc/nginx/sites-available/$domain

# Prevent if SSL is enabled in main site and ssl data is copied to parked site causing an error.
sudo site $domain -ssl=off -revoke=off > /dev/null 2>&1 &
sudo site $domain -ssl=off -revoke=off > /dev/null 2>&1

sudo sed -i "/server_name/c \ $sername" /etc/nginx/sites-available/$domain
sudo sed -i "s/$mapto/$domain/g" /etc/nginx/sites-available/$domain
Expand Down

0 comments on commit 91d5fd3

Please sign in to comment.