forked from mmenozzi/m2-bash-ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathm2-bash-ci.sh
36 lines (31 loc) · 1.68 KB
/
m2-bash-ci.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
export SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
if [ ! -z "$1" ] && [ -f "$1" ]; then
echo "Loading environment variables from $1..."
source "$1"
fi;
function mysql_cli {
if [ "${MYSQL_CLI_CREDENTIALS}" = true ] ; then
mysql -h ${DB_HOST} -u ${DB_USER} --password=${DB_PASS} -e "$1"
else
mysql -e "$1"
fi;
}
MAGENTO_INSTALL_DB_PASSWORD="--db-password=${DB_PASS}"
if [ -z "${DB_PASS}" ]; then
MAGENTO_INSTALL_DB_PASSWORD=""
fi;
mysql_cli "DROP DATABASE IF EXISTS \`${DB_NAME}\`;"
mysql_cli "DROP DATABASE IF EXISTS \`${DB_TEST}\`;"
mysql_cli "CREATE DATABASE \`${DB_NAME}\` CHARACTER SET utf8;"
mysql_cli "CREATE DATABASE \`${DB_TEST}\` CHARACTER SET utf8;"
php bin/magento setup:install --db-host="${DB_HOST}" --db-name="${DB_NAME}" --db-user="${DB_USER}" \
${MAGENTO_INSTALL_DB_PASSWORD} --admin-firstname="Magento" --admin-lastname="User" --admin-email="[email protected]" \
--admin-user="admin" --admin-password="admin123" --use-rewrites="1" --base-url="${BASE_URL}"
php bin/magento deploy:mode:set developer
rm -f dev/tests/integration/etc/install-config-mysql.php
cp -f dev/tests/integration/etc/install-config-mysql.php.dist dev/tests/integration/etc/install-config-mysql.php
sed -i -e "s/'db-host' => '.*'/'db-host' => '${DB_HOST}'/" dev/tests/integration/etc/install-config-mysql.php
sed -i -e "s/'db-user' => '.*'/'db-user' => '${DB_USER}'/" dev/tests/integration/etc/install-config-mysql.php
sed -i -e "s/'db-password' => '.*'/'db-password' => '${DB_PASS}'/" dev/tests/integration/etc/install-config-mysql.php
sed -i -e "s/'db-name' => '.*'/'db-name' => '${DB_TEST}'/" dev/tests/integration/etc/install-config-mysql.php