diff options
-rw-r--r-- | scripts/create_mysql_user.sh | 10 | ||||
-rw-r--r-- | scripts/create_postgres_user.sh | 8 | ||||
-rw-r--r-- | scripts/prepare_build.sh | 3 |
3 files changed, 14 insertions, 7 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 diff --git a/scripts/create_postgres_user.sh b/scripts/create_postgres_user.sh index 0fa065b0387..8e0f84f62ca 100644 --- a/scripts/create_postgres_user.sh +++ b/scripts/create_postgres_user.sh @@ -1,6 +1,8 @@ #!/bin/bash -psql -h localhost -U postgres postgres <<EOF -CREATE USER gitlab; -GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO gitlab; +if pg_isready -h localhost -U postgres; then + psql -h localhost -U postgres postgres <<EOF + CREATE USER gitlab; + GRANT ALL PRIVILEGES ON ALL TABLES IN SCHEMA public TO gitlab; EOF +fi diff --git a/scripts/prepare_build.sh b/scripts/prepare_build.sh index 043f532cd69..c3f060e4a1e 100644 --- a/scripts/prepare_build.sh +++ b/scripts/prepare_build.sh @@ -66,5 +66,8 @@ sed -i 's/localhost/redis/g' config/redis.shared_state.yml if [ "$SETUP_DB" != "false" ]; then setup_db elif getent hosts postgres || getent hosts mysql; then + # NOTE: Due to adding both of these entries to /etc/hosts, this will always + # run. Anything using a database should ensure it's actually accepting + # connections! setup_db_user_only fi |