[DRE-commits] [gitlab] 01/09: use dbconfig-common for database
Praveen Arimbrathodiyil
praveen at moszumanska.debian.org
Fri Apr 21 09:45:18 UTC 2017
This is an automated email from the git hooks/post-receive script.
praveen pushed a commit to branch master
in repository gitlab.
commit 83189ec0e09f104e8420d9fee9726ca1b914a394
Author: Praveen Arimbrathodiyil <praveen at debian.org>
Date: Fri Apr 21 12:47:11 2017 +0530
use dbconfig-common for database
---
debian/config | 13 +++++++++++++
debian/control | 1 +
debian/grantpriv.sh | 25 -------------------------
debian/install | 1 -
debian/postinst | 11 ++++-------
5 files changed, 18 insertions(+), 33 deletions(-)
diff --git a/debian/config b/debian/config
index cb714ed..f88ea2f 100755
--- a/debian/config
+++ b/debian/config
@@ -42,3 +42,16 @@ fi
# Do you want to change gitlab user?
db_input high gitlab/user || true
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
diff --git a/debian/control b/debian/control
index 3d3863c..32671cb 100644
--- a/debian/control
+++ b/debian/control
@@ -22,6 +22,7 @@ Depends: ${shlibs:Depends}, ${misc:Depends}, ruby | ruby-interpreter,
rake,
bundler,
postgresql-client,
+ dbconfig-pgsql | dbconfig-no-thanks,
adduser (>= 3.34~),
bc,
postgresql-contrib,
diff --git a/debian/grantpriv.sh b/debian/grantpriv.sh
deleted file mode 100755
index 63ce624..0000000
--- a/debian/grantpriv.sh
+++ /dev/null
@@ -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;\""
diff --git a/debian/install b/debian/install
index f7bed76..0d1e946 100644
--- a/debian/install
+++ b/debian/install
@@ -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.ssl.conf.example usr/lib/gitlab/templates
debian/adduser.sh usr/lib/gitlab/scripts
-debian/grantpriv.sh usr/lib/gitlab/scripts
debian/rake-tasks.sh usr/lib/gitlab/scripts
debian/gitlab-check.sh usr/lib/gitlab/scripts
app usr/share/gitlab
diff --git a/debian/postinst b/debian/postinst
index 256c748..db7fb38 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -20,6 +20,7 @@ gitlab_debian_defaults_copy=/var/lib/gitlab/gitlab-debian.defaults
# Show debconf questions
. /usr/share/debconf/confmodule
+. /usr/share/dbconfig-common/dpkg/postinst
# summary of how this script can be called:
# * <postinst> `configure' <most-recently-configured-version>
@@ -310,15 +311,11 @@ case "$1" in
echo "Reloading nginx configuration..."
invoke-rc.d nginx reload
fi
+ dbc_go gitlab "$@"
db_stop
- echo "Create database if not present"
- if ! su postgres -s /bin/sh -c "psql gitlab_production -c ''"; then
- su postgres -c 'createdb -E unicode -T template0 gitlab_production'
- fi
-
- # Adjust database privileges
- . /usr/lib/gitlab/scripts/grantpriv.sh
+ # enable the pg_trgm extension
+ su postgres -c "psql -d gitlab_production -c \"CREATE EXTENSION IF NOT EXISTS pg_trgm;\""
# Remove Gemfile.lock if present
rm -f ${gitlab_data_dir}/Gemfile.lock
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-ruby-extras/gitlab.git
More information about the Pkg-ruby-extras-commits
mailing list