use dbconfig-common for database
This commit is contained in:
parent
8816d45e94
commit
83189ec0e0
5 changed files with 18 additions and 33 deletions
13
debian/config
vendored
13
debian/config
vendored
|
@ -42,3 +42,16 @@ fi
|
||||||
# Do you want to change gitlab user?
|
# Do you want to change gitlab user?
|
||||||
db_input high gitlab/user || true
|
db_input high gitlab/user || true
|
||||||
db_go
|
db_go
|
||||||
|
db_get gitlab/user
|
||||||
|
gitlab_user=$RET
|
||||||
|
|
||||||
|
# source dbconfig-common shell library, and call the hook function
|
||||||
|
if [ -f /usr/share/dbconfig-common/dpkg/config ]; then
|
||||||
|
. /usr/share/dbconfig-common/dpkg/config
|
||||||
|
|
||||||
|
dbc_dbtypes="pgsql"
|
||||||
|
dbc_dbname="gitlab_production"
|
||||||
|
dbc_dbuser="$gitlab_user"
|
||||||
|
|
||||||
|
dbc_go $gitlab_user "$@"
|
||||||
|
fi
|
||||||
|
|
1
debian/control
vendored
1
debian/control
vendored
|
@ -22,6 +22,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter,
|
||||||
rake,
|
rake,
|
||||||
bundler,
|
bundler,
|
||||||
postgresql-client,
|
postgresql-client,
|
||||||
|
dbconfig-pgsql | dbconfig-no-thanks,
|
||||||
adduser (>= 3.34~),
|
adduser (>= 3.34~),
|
||||||
bc,
|
bc,
|
||||||
postgresql-contrib,
|
postgresql-contrib,
|
||||||
|
|
25
debian/grantpriv.sh
vendored
25
debian/grantpriv.sh
vendored
|
@ -1,25 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
set -e
|
|
||||||
|
|
||||||
dbname=gitlab_production
|
|
||||||
|
|
||||||
# Take gitlab_user from envornment variable or use gitlab
|
|
||||||
gitlab_user=${gitlab_user:-gitlab}
|
|
||||||
|
|
||||||
# If gitlab user cannot access gitlab_production,
|
|
||||||
# then it means the gitlab role does not exist
|
|
||||||
if ! su ${gitlab_user} -c 'psql gitlab_production -c ""'
|
|
||||||
then
|
|
||||||
echo "Create ${gitlab_user} user with create database privillege..."
|
|
||||||
su postgres -c "psql -c \"CREATE USER ${gitlab_user} CREATEDB;\""
|
|
||||||
fi
|
|
||||||
|
|
||||||
# By default the gitlab_prodcution is not owned by gitlab user
|
|
||||||
echo "Make ${gitlab_user} user owner of $dbname database..."
|
|
||||||
su postgres -c "psql -c \"ALTER DATABASE $dbname OWNER to ${gitlab_user};\""
|
|
||||||
|
|
||||||
echo "Grant all privileges to ${gitlab_user} user..."
|
|
||||||
su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE template1 to ${gitlab_user};\""
|
|
||||||
|
|
||||||
# enable the pg_trgm extension
|
|
||||||
su postgres -c "psql -d $dbname -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\""
|
|
1
debian/install
vendored
1
debian/install
vendored
|
@ -11,7 +11,6 @@ debian/conf/tmpfiles.d/gitlab.conf.example usr/lib/gitlab/templates/tmpfiles.d
|
||||||
debian/conf/nginx.conf.example usr/lib/gitlab/templates
|
debian/conf/nginx.conf.example usr/lib/gitlab/templates
|
||||||
debian/conf/nginx.ssl.conf.example usr/lib/gitlab/templates
|
debian/conf/nginx.ssl.conf.example usr/lib/gitlab/templates
|
||||||
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
|
||||||
debian/gitlab-check.sh usr/lib/gitlab/scripts
|
debian/gitlab-check.sh usr/lib/gitlab/scripts
|
||||||
app usr/share/gitlab
|
app usr/share/gitlab
|
||||||
|
|
11
debian/postinst
vendored
11
debian/postinst
vendored
|
@ -20,6 +20,7 @@ gitlab_debian_defaults_copy=/var/lib/gitlab/gitlab-debian.defaults
|
||||||
|
|
||||||
# Show debconf questions
|
# Show debconf questions
|
||||||
. /usr/share/debconf/confmodule
|
. /usr/share/debconf/confmodule
|
||||||
|
. /usr/share/dbconfig-common/dpkg/postinst
|
||||||
|
|
||||||
# summary of how this script can be called:
|
# summary of how this script can be called:
|
||||||
# * <postinst> `configure' <most-recently-configured-version>
|
# * <postinst> `configure' <most-recently-configured-version>
|
||||||
|
@ -310,15 +311,11 @@ case "$1" in
|
||||||
echo "Reloading nginx configuration..."
|
echo "Reloading nginx configuration..."
|
||||||
invoke-rc.d nginx reload
|
invoke-rc.d nginx reload
|
||||||
fi
|
fi
|
||||||
|
dbc_go gitlab "$@"
|
||||||
db_stop
|
db_stop
|
||||||
|
|
||||||
echo "Create database if not present"
|
# enable the pg_trgm extension
|
||||||
if ! su postgres -s /bin/sh -c "psql gitlab_production -c ''"; then
|
su postgres -c "psql -d gitlab_production -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\""
|
||||||
su postgres -c 'createdb -E unicode -T template0 gitlab_production'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Adjust database privileges
|
|
||||||
. /usr/lib/gitlab/scripts/grantpriv.sh
|
|
||||||
|
|
||||||
# Remove Gemfile.lock if present
|
# Remove Gemfile.lock if present
|
||||||
rm -f ${gitlab_data_dir}/Gemfile.lock
|
rm -f ${gitlab_data_dir}/Gemfile.lock
|
||||||
|
|
Loading…
Reference in a new issue