use postgres commands to create database
This commit is contained in:
parent
264985b4dc
commit
f7ca08b540
4 changed files with 32 additions and 5 deletions
5
debian/config
vendored
5
debian/config
vendored
|
@ -3,9 +3,6 @@
|
||||||
|
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
echo "Call debconf to configure gitlab"
|
||||||
# source debconf stuffs
|
# source debconf stuffs
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
|
|
||||||
# DB password can be left blank
|
|
||||||
db_input high gitlab/dbpass || true
|
|
||||||
db_go || true
|
|
||||||
|
|
24
debian/grantpriv.sh
vendored
Executable file
24
debian/grantpriv.sh
vendored
Executable file
|
@ -0,0 +1,24 @@
|
||||||
|
#!/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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
1
debian/install
vendored
1
debian/install
vendored
|
@ -2,6 +2,7 @@ debian/database.yml etc/gitlab
|
||||||
debian/gitlab.yml etc/gitlab
|
debian/gitlab.yml etc/gitlab
|
||||||
debian/gitlab-debian.conf etc/gitlab
|
debian/gitlab-debian.conf etc/gitlab
|
||||||
debian/adduser.sh usr/lib/gitlab/scripts
|
debian/adduser.sh usr/lib/gitlab/scripts
|
||||||
|
debian/grantpriv.sh usr/lib/gitlab/scripts
|
||||||
debian/rake-tasks.sh usr/lib/gitlab/scripts
|
debian/rake-tasks.sh usr/lib/gitlab/scripts
|
||||||
app usr/share/gitlab
|
app usr/share/gitlab
|
||||||
bin usr/share/gitlab
|
bin usr/share/gitlab
|
||||||
|
|
7
debian/postinst
vendored
7
debian/postinst
vendored
|
@ -32,10 +32,15 @@ case "$1" in
|
||||||
. /usr/lib/gitlab/scripts/adduser.sh
|
. /usr/lib/gitlab/scripts/adduser.sh
|
||||||
chown -R ${gitlab_user}: ${gitlab_home}
|
chown -R ${gitlab_user}: ${gitlab_home}
|
||||||
cd ${gitlab_home}
|
cd ${gitlab_home}
|
||||||
|
|
||||||
# Show debconf questions
|
# Show debconf questions
|
||||||
. /usr/share/debconf/confmodule
|
. /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..."
|
echo "Setting up environment varibales..."
|
||||||
export RAILS_ENV=production
|
export RAILS_ENV=production
|
||||||
export DB=postgres
|
export DB=postgres
|
||||||
|
|
Loading…
Reference in a new issue