Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
core
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
minerva
core
Merge requests
!779
Resolve "Debian package: use dbconfig-common"
Code
Review changes
Check out branch
Download
Patches
Plain diff
Merged
Resolve "Debian package: use dbconfig-common"
469-debian-package-use-dbconfig-common
into
master
Overview
0
Commits
20
Pipelines
6
Changes
15
Merged
Piotr Gawron
requested to merge
469-debian-package-use-dbconfig-common
into
master
5 years ago
Overview
0
Commits
20
Pipelines
6
Changes
15
Expand
Closes
#469 (closed)
Edited
5 years ago
by
Piotr Gawron
0
0
Merge request reports
Compare
master
version 4
f106ecce
5 years ago
version 3
55051c90
5 years ago
version 2
905a165d
5 years ago
version 1
253f21bf
5 years ago
master (base)
and
latest version
latest version
e5857fe0
20 commits,
5 years ago
version 4
f106ecce
19 commits,
5 years ago
version 3
55051c90
18 commits,
5 years ago
version 2
905a165d
16 commits,
5 years ago
version 1
253f21bf
14 commits,
5 years ago
15 files
+
163
−
154
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
Files
15
Search (e.g. *.vue) (Ctrl+P)
debian/scripts/common.sh
+
0
−
71
Options
@@ -31,74 +31,3 @@ fi
POSTGRES_OK
=
$(
dpkg-query
-W
--showformat
=
'${Status}\n'
postgresql|grep
"install ok installed"
)
DB_HOST
=
"__DB_HOST__"
DB_PORT
=
"__DB_PORT__"
DB_DATABASE_NAME
=
"__DB_DATABASE_NAME__"
DB_USERNAME
=
"__DB_USERNAME__"
DB_PASSWORD
=
"__DB_PASSWORD__"
if
[
-f
/etc/minerva/db.properties
]
;
then
DB_PROPERTIES_FILE
=
"/etc/minerva/db.properties"
log
"
$DB_PROPERTIES_FILE
file found"
DB_HOST
=
`
cat
$DB_PROPERTIES_FILE
|grep
"uri"
|cut
-f3
-d
"/"
|cut
-f1
-d
":"
`
DB_PORT
=
`
cat
$DB_PROPERTIES_FILE
|grep
"uri"
|cut
-f3
-d
"/"
|cut
-f2
-d
":"
`
DB_DATABASE_NAME
=
`
cat
$DB_PROPERTIES_FILE
|grep
"uri"
|cut
-f4
-d
"/"
`
DB_USERNAME
=
`
cat
$DB_PROPERTIES_FILE
|grep
"username"
|cut
-f2
-d
"="
`
DB_PASSWORD
=
`
cat
$DB_PROPERTIES_FILE
|grep
"password"
|cut
-f2
-d
"="
`
fi
#if we connect to something that is not in localhost then we need to provide login and password
#because we won't have access to it as postgres user
if
[
"
$DB_HOST
"
!=
"localhost"
]
&&
[
"
$DB_HOST
"
!=
"127.0.0.1"
]
then
log
"DB is located on the remote server:
$DB_HOST
"
IS_REMOTE_DB
=
true
else
log
"DB is at localhost:
$DB_HOST
"
IS_REMOTE_DB
=
false
fi
exec_sql
(){
log
"Execute SQL : '
$1
'"
echo
"
$1
"
|PGPASSWORD
=
$DB_PASSWORD
psql
-h
$DB_HOST
-p
$DB_PORT
-U
$DB_USERNAME
$DB_DATABASE_NAME
>>
$LOG_FILE
2>>
$LOG_FILE
}
exec_sql_file
(){
log
"Execute SQL file:
$1
"
PGPASSWORD
=
$DB_PASSWORD
psql
-h
$DB_HOST
-p
$DB_PORT
-U
$DB_USERNAME
$DB_DATABASE_NAME
-f
$1
>>
$LOG_FILE
2>>
$LOG_FILE
}
create_db
(){
log
"Create db: (remote=
$IS_REMOTE_DB
)"
if
[
$IS_REMOTE_DB
=
false
]
then
su - postgres
-c
"createuser -d -r -s -p
$DB_PORT
$DB_USERNAME
"
>>
$LOG_FILE
2>>
$LOG_FILE
log
"User created"
su - postgres
-c
"echo
\"
ALTER USER
$DB_USERNAME
WITH PASSWORD '
$DB_PASSWORD
';
\"
| psql -p
$DB_PORT
"
>>
$LOG_FILE
2>>
$LOG_FILE
log
"User credentials updated"
su - postgres
-c
"createdb -p
$DB_PORT
-O
$DB_USERNAME
$DB_DATABASE_NAME
"
>>
$LOG_FILE
2>>
$LOG_FILE
log
"Db created"
hba_conf
=
`
su - postgres
-c
"psql -t -P format=unaligned -c 'show hba_file';"
`
;
cp
$hba_conf
$hba_conf
".bac"
cat
$hba_conf
".bac"
|grep
-v
"all[
\t
]*peer"
>
$hba_conf
printf
"local all all md5
\n
"
>>
$hba_conf
invoke-rc.d postgresql restart
else
log
"HOST is remote, assuming db and user are already there"
fi
}
stop_postgres
()
{
log
"Stop postgres: (remote=
$IS_REMOTE_DB
)"
if
[
$IS_REMOTE_DB
=
false
]
then
invoke-rc.d postgresql stop
||
true
fi
}
start_postgres
()
{
log
"Start postgres: (remote=
$IS_REMOTE_DB
)"
if
[
$IS_REMOTE_DB
=
false
]
then
invoke-rc.d postgresql restart
fi
}
Loading