Patch by Benjamin Drung
If the sysadmin changes the gitlab user in /etc/gitlab/gitlab-debian.conf, the package installation or upgrade will fail, because grantpriv.sh will always grant privileges to the gitlab user. Thus adapt grantpriv.sh to honor the gitlab_user setting.
This commit is contained in:
parent
1359e5823c
commit
e7430db19d
1 changed files with 10 additions and 8 deletions
18
debian/grantpriv.sh
vendored
18
debian/grantpriv.sh
vendored
|
@ -1,26 +1,28 @@
|
|||
#!/bin/sh
|
||||
|
||||
user=gitlab
|
||||
dbname=gitlab_production
|
||||
|
||||
# Take gitlab_user from envornment variable or use gitlab
|
||||
test -n "${gitlab_user:-}" || gitlab_user="gitlab"
|
||||
|
||||
# If gitlab user cannot access gitlab_production,
|
||||
# then it means the gitlab role does not exist
|
||||
if ! su gitlab -c 'psql gitlab_production -c ""'
|
||||
if ! su ${gitlab_user} -c 'psql gitlab_production -c ""'
|
||||
then
|
||||
echo "Create $user user with create database privillege..."
|
||||
su postgres -c "psql -c \"CREATE USER $user CREATEDB;\"" || {
|
||||
echo "Create ${gitlab_user} user with create database privillege..."
|
||||
su postgres -c "psql -c \"CREATE USER ${gitlab_user} CREATEDB;\"" || {
|
||||
exit 1
|
||||
}
|
||||
fi
|
||||
|
||||
# By default the gitlab_prodcution is not owned by gitlab user
|
||||
echo "Make $user user owner of $dbname database..."
|
||||
su postgres -c "psql -c \"ALTER DATABASE $dbname OWNER to $user;\"" || {
|
||||
echo "Make ${gitlab_user} user owner of $dbname database..."
|
||||
su postgres -c "psql -c \"ALTER DATABASE $dbname OWNER to ${gitlab_user};\"" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
echo "Grant all privileges to $user user..."
|
||||
su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE template1 to $user;\"" || {
|
||||
echo "Grant all privileges to ${gitlab_user} user..."
|
||||
su postgres -c "psql -c \"GRANT ALL PRIVILEGES ON DATABASE template1 to ${gitlab_user};\"" || {
|
||||
exit 1
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue