summaryrefslogtreecommitdiff
path: root/scripts/create_mysql_user.sh
diff options
context:
space:
mode:
authorRobert Speicher <rspeicher@gmail.com>2018-12-13 12:40:30 -0600
committerRobert Speicher <rspeicher@gmail.com>2019-01-08 11:47:32 -0600
commit5947382ba87729b9f80428f11e2cd77ceaef49d6 (patch)
tree7e8bb40862cfd7c081cb3b6a9e7b1f7f600f4913 /scripts/create_mysql_user.sh
parent4d649e98f755f7741360baf9830cf3f05cce3a0e (diff)
downloadgitlab-ce-rs-prepare-k8s-runner.tar.gz
Conditionally setup database usersrs-prepare-k8s-runner
Due to `getent` now always returning a value for both `postgres` and `mysql`, we were always attempting to create database users even when `SETUP_DB` was false. We now check for service availability before attempting to create database users.
Diffstat (limited to 'scripts/create_mysql_user.sh')
-rw-r--r--scripts/create_mysql_user.sh10
1 files changed, 6 insertions, 4 deletions
diff --git a/scripts/create_mysql_user.sh b/scripts/create_mysql_user.sh
index 71c6169bfd0..6a11a9e12b1 100644
--- a/scripts/create_mysql_user.sh
+++ b/scripts/create_mysql_user.sh
@@ -1,7 +1,9 @@
#!/bin/bash
-mysql --user=root --host=127.0.0.1 <<EOF
-CREATE USER IF NOT EXISTS 'gitlab'@'127.0.0.1';
-GRANT ALL PRIVILEGES ON gitlabhq_test.* TO 'gitlab'@'127.0.0.1';
-FLUSH PRIVILEGES;
+if mysqladmin ping --user=root --host=127.0.0.1; then
+ mysql --user=root --host=127.0.0.1 <<EOF
+ CREATE USER IF NOT EXISTS 'gitlab'@'127.0.0.1';
+ GRANT ALL PRIVILEGES ON gitlabhq_test.* TO 'gitlab'@'127.0.0.1';
+ FLUSH PRIVILEGES;
EOF
+fi