Skip to content

Commit 5211b78

Browse files
committed
refs #45702, correct drush installation script
1 parent 3757a9e commit 5211b78

File tree

1 file changed

+22
-4
lines changed

1 file changed

+22
-4
lines changed

container/init-7.sh

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
#!/bin/bash
2-
sleep 10
2+
date +"@ %Y-%m-%d %H:%M:%S %z"
3+
4+
# wait for mysql start
35
while ! pgrep -u mysql mysqld > /dev/null; do sleep 3; done
6+
sleep 10
47

58
REPOSDIR=`pwd`
69
if [ ! -f $REPOSDIR/civicrm-version.txt ]; then
@@ -20,17 +23,31 @@ export DRUPAL=7
2023
date +"@ %Y-%m-%d %H:%M:%S %z"
2124
echo "CI for Drupal-$DRUPAL + netiCRM"
2225

23-
EXISTSDB=`mysql -uroot -e "SHOW DATABASES" | grep neticrmci | wc -l`
24-
if [ "$EXISTSDB" = "0" ]; then
26+
# correct drush installation
27+
## update composer
28+
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer
29+
composer global remove drush/drush
30+
composer global require drush/drush:8.5.0 --no-security-blocking --no-audit
31+
32+
# init mysql
33+
DB_TEST=`mysql -uroot -sN -e "SHOW databases"`
34+
MYSQL_ACCESS=$?
35+
DB_EXISTS=`mysql -uroot -sN -e "SHOW databases" | grep $DB`
36+
37+
if [ $MYSQL_ACCESS -eq 0 ] && [ -z "$DB_EXISTS" ] && [ -n "$DB" ]; then
2538
echo "Install new database $DB"
2639
mysql -uroot -e "CREATE DATABASE $DB CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci;"
40+
echo "MySQL initialize completed !!"
41+
echo "MYSQL_DB=$DB"
42+
else
43+
echo "Skip exist $DB, database already setup before."
2744
fi
2845

2946
cd $DRUPAL_ROOT
3047

3148
if [ ! -f $DRUPAL_ROOT/sites/default/settings.php ]; then
32-
echo "Install Drupal ..."
3349
date +"@ %Y-%m-%d %H:%M:%S %z"
50+
echo "Install Drupal ..."
3451
sleep 5s
3552
php ~/.composer/vendor/bin/drush.php --yes site-install standard --account-name=admin --db-url=mysql://root:@localhost/$DB --account-pass=$PW --site-name=netiCRM
3653

@@ -74,4 +91,5 @@ fi
7491

7592
# testing...
7693
echo "Running test..."
94+
date +"@ %Y-%m-%d %H:%M:%S %z"
7795

0 commit comments

Comments
 (0)