Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
S
swh-storage
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
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
Platform
Development
swh-storage
Commits
3a869826
Commit
3a869826
authored
6 years ago
by
Antoine Pietri
Browse files
Options
Downloads
Patches
Plain Diff
sql/bin/db-init: remove createuser and privileges (we now assume a peer superuser)
parent
1286dfa4
No related branches found
No related tags found
1 merge request
!87
sql/bin/db-init: remove createuser and privileges (we now assume a peer superuser)
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
sql/bin/db-init
+5
-22
5 additions, 22 deletions
sql/bin/db-init
with
5 additions
and
22 deletions
sql/bin/db-init
+
5
−
22
View file @
3a869826
...
...
@@ -26,31 +26,20 @@ if ! [ -f "$SQL_INIT" ] ; then
fi
if
[
-z
"
$1
"
]
;
then
echo
"Usage: bin/db-init DB_NAME
[DB_USER
[DB_PORT]
]
"
echo
"Usage: bin/db-init DB_NAME [DB_PORT]"
echo
"Example: bin/db-init softwareheritage-dev"
echo
"Note: DB_NAME should not exist and will be created
; DB_USER can exist.
"
echo
"Note: DB_NAME should not exist and will be created"
exit
2
fi
db_name
=
"
$1
"
db_user
=
"
${
2
:-
$USER
}
"
port
=
${
2
:-
5432
}
conn_flags
=
""
if
[
-n
"
$3
"
]
;
then
conn_flags
=
"--port
$3
"
fi
user_exists
=
$(
psql postgres
-tAc
"SELECT 1 FROM pg_roles
WHERE rolname='
$db_user
'"
)
if
[
"
$user_exists
"
!=
"1"
]
;
then
echo
"I: creating Postgres user
${
db_user
}
..."
createuser
$conn_flags
--pwprompt
"
$db_user
"
||
true
fi
conn_flags
=
"--port
$port
"
echo
"I: creating Postgres database
${
db_name
}
..."
createdb
$conn_flags
\
--encoding
"
$DB_ENCODING
"
--locale
"
$DB_LOCALE
"
\
--template
"
$DB_TEMPLATE
"
\
--owner
"
$db_user
"
"
$db_name
"
--template
"
$DB_TEMPLATE
"
"
$db_name
"
sqls_flags
=
''
for
f
in
$SQLS
;
do
...
...
@@ -60,10 +49,4 @@ done
echo
"I: initializing DB
${
db_name
}
..."
psql
$conn_flags
${
sqls_flags
}
"
$db_name
"
echo
"I: granting privileges to user
${
db_user
}
on DB
${
db_name
}
..."
echo
"grant all privileges on all tables in schema public to
${
db_user
}
"
|
\
psql
$conn_flags
"
$db_name
"
echo
"grant all privileges on all sequences in schema public to
${
db_user
}
"
|
\
psql
$conn_flags
"
$db_name
"
echo
"I: all done."
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment