diff --git a/lib/general b/lib/general index 8fb4beb..b9ae66c 100644 --- a/lib/general +++ b/lib/general @@ -148,7 +148,13 @@ 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) @@ -156,9 +162,6 @@ wp_dbdata() { 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 } diff --git a/lib/sites b/lib/sites index 8ec4621..df9d46f 100644 --- a/lib/sites +++ b/lib/sites @@ -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}============================================" @@ -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; @@ -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 diff --git a/plugins/site b/plugins/site index 36f656b..ac3b3a2 100644 --- a/plugins/site +++ b/plugins/site @@ -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