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
64
64
fi
65
65
echo " SQL set up and the password can be found in wp-config.php ..."
66
66
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 -r table; do
79
+ mysql --user=" $USER " --password=" $sqlpass " --execute=" DROP TABLE $table " " $USER "
80
+ done
81
+ fi
82
+
67
83
# Install WordPress and create config file
68
84
wp core download
69
85
wp config create --dbname=" $user " --dbuser=" $user " --dbpass=" $sqlpass " --dbhost=mysql --dbcharset=utf8mb4
You can’t perform that action at this time.
0 commit comments