Created
August 24, 2014 20:45
-
-
Save kojiromike/2229461e006c53252b89 to your computer and use it in GitHub Desktop.
On-demand mysql setup/teardown for magento testing.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
( | |
if mkdir -p mysql/data && cd mysql; then | |
[[ -f mysql.pid ]] && kill $(<mysql.pid) | |
client_opts=( | |
--no-defaults | |
--socket="$db_sock" | |
) | |
server_opts=( | |
"${client_opts[@]}" | |
--basedir="$(nix-store -qR $(type -P mysqld) | tail -n 1)" | |
--datadir="$PWD/data" | |
--log-error="$PWD/error.log" | |
--pid-file="$PWD/mysql.pid" | |
--skip-networking | |
) | |
mysql_install_db "${server_opts[@]}" | |
mysqld_safe "${server_opts[@]}" & | |
counter=6 | |
until mysql "${client_opts[@]}" -e 'SELECT TRUE;'; do | |
sleep 1 | |
if (( counter-- < 1 )); then | |
printf 'Gave up waiting for MySQL to start.\n' >&2 | |
exit 1 | |
fi | |
done | |
mysqladmin "${client_opts[@]}" -u root password "$db_pass" create "$db_name" | |
fi | |
) | |
( | |
if cd build/magento; then | |
# Run the Magento installer. | |
php -f install.php -- \ | |
# etc | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment