Skip to content

Commit

Permalink
Merge pull request #645 from Automattic/add/netapp
Browse files Browse the repository at this point in the history
refactor(dev-tools): database provisioning in WordPress installation script
  • Loading branch information
sjinks authored Feb 7, 2024
2 parents da65d98 + cef0e41 commit b9e5142
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions dev-tools/setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -115,11 +115,22 @@ fi
echo "Checking for database connectivity..."
if ! mysql -h "$db_host" -u wordpress -pwordpress wordpress -e "SELECT 'testing_db'" >/dev/null 2>&1; then
echo "No WordPress database exists, provisioning..."
echo "CREATE USER IF NOT EXISTS 'wordpress'@'localhost' IDENTIFIED BY 'wordpress'" | mysql -h "$db_host" -u "$db_admin_user"
echo "CREATE USER IF NOT EXISTS 'wordpress'@'%' IDENTIFIED BY 'wordpress'" | mysql -h "$db_host" -u "$db_admin_user"
echo "GRANT ALL ON *.* TO 'wordpress'@'localhost' WITH GRANT OPTION;" | mysql -h "$db_host" -u "$db_admin_user"
echo "GRANT ALL ON *.* TO 'wordpress'@'%' WITH GRANT OPTION;" | mysql -h "$db_host" -u "$db_admin_user"
echo "CREATE DATABASE IF NOT EXISTS wordpress;" | mysql -h "$db_host" -u "$db_admin_user"
{
echo "CREATE USER IF NOT EXISTS 'wordpress'@'localhost' IDENTIFIED BY 'wordpress';"
echo "CREATE USER IF NOT EXISTS 'wordpress'@'%' IDENTIFIED BY 'wordpress';"
echo "GRANT ALL ON *.* TO 'wordpress'@'localhost';"
echo "GRANT ALL ON *.* TO 'wordpress'@'%';"
echo "CREATE DATABASE IF NOT EXISTS wordpress;"
} | mysql -h "$db_host" -u "$db_admin_user"
fi

if ! mysql -h "${db_host}" -unetapp -pwordpress wordpress -e "SELECT 'testing_db'" >/dev/null 2>&1; then
{
echo "CREATE USER IF NOT EXISTS 'netapp'@'localhost' IDENTIFIED BY 'wordpress';"
echo "CREATE USER IF NOT EXISTS 'netapp'@'%' IDENTIFIED BY 'wordpress';"
echo "GRANT ALL ON *.* TO 'netapp'@'localhost';"
echo "GRANT ALL ON *.* TO 'netapp'@'%';"
} | mysql -h "${db_host}" -u "${db_admin_user}"
fi

echo "Copying dev-env-plugin.php to mu-plugins"
Expand Down

0 comments on commit b9e5142

Please sign in to comment.