File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -64,6 +64,22 @@ if [[ -z "$sqlpass" ]]; then
6464fi
6565echo " SQL set up and the password can be found in wp-config.php ..."
6666
67+ tables=$( mysql --user=" $USER " --password=" $sqlpass " --execute=" show tables" " $USER " | grep -E " ^wp_" || echo " " )
68+ if ! [[ -z " $tables " ]]; then
69+ echo
70+ echo -e " \033[33mThere appears to be an existing WordPress installation. Would you like to clean the database?\033[00m\n"
71+ read -rp " Do you want to continue? [y/N] " wordpresskiller
72+ wordpresskiller=${wordpresskiller,,}
73+ if ! [[ " $wordpresskiller " =~ ^(yes| y) ]]; then
74+ echo " If you want to run this script and keep the tables intact, rename the existing tables from wp_* to something else."
75+ exit 0
76+ fi
77+
78+ echo $tables | tr ' ' ' \n' | while read table; do
79+ mysql --user=" $USER " --password=" $sqlpass " --execute=" DROP TABLE $table " " $USER "
80+ done
81+ fi
82+
6783# Install WordPress and create config file
6884wp core download
6985wp config create --dbname=" $user " --dbuser=" $user " --dbpass=" $sqlpass " --dbhost=mysql --dbcharset=utf8mb4
You can’t perform that action at this time.
0 commit comments