Skip to content
Snippets Groups Projects
Commit f7ca08b5 authored by Praveen Arimbrathodiyil's avatar Praveen Arimbrathodiyil
Browse files

use postgres commands to create database

parent 264985b4
No related branches found
No related tags found
No related merge requests found
......@@ -3,9 +3,6 @@
set -e
echo "Call debconf to configure gitlab"
# source debconf stuffs
. /usr/share/debconf/confmodule
# DB password can be left blank
db_input high gitlab/dbpass || true
db_go || true
#!/bin/sh
user=gitlab
dbname=gitlab_production
if su gitlab -c 'psql gitlab_production -c ""'
then
echo "Create $user user with create database privillege..."
sudo -u postgres psql -c "CREATE USER $user CREATEDB;" || {
exit 1
}
fi
echo "Make $user user owner of $dbname database..."
sudo -u postgres psql -c "ALTER DATABASE $dbname OWNER to $user;" || {
exit 1
}
echo "Grant all privileges to $user user..."
sudo -u postgres psql -c "GRANT ALL PRIVILEGES ON DATABASE template1 to $user;"|| {
exit 1
}
......@@ -2,6 +2,7 @@ debian/database.yml etc/gitlab
debian/gitlab.yml etc/gitlab
debian/gitlab-debian.conf etc/gitlab
debian/adduser.sh usr/lib/gitlab/scripts
debian/grantpriv.sh usr/lib/gitlab/scripts
debian/rake-tasks.sh usr/lib/gitlab/scripts
app usr/share/gitlab
bin usr/share/gitlab
......
......@@ -32,10 +32,15 @@ case "$1" in
. /usr/lib/gitlab/scripts/adduser.sh
chown -R ${gitlab_user}: ${gitlab_home}
cd ${gitlab_home}
# Show debconf questions
. /usr/share/debconf/confmodule
echo "Create database if not present"
if ! su gitlab -s /bin/sh -c "psql gitlab_production -c ''"
then
su postgres -c 'createdb gitlab_production'
fi
. /usr/lib/gitlab/scripts/grantpriv.sh
echo "Setting up environment varibales..."
export RAILS_ENV=production
export DB=postgres
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment