mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
rework ynh_psql_create_db
This commit is contained in:
parent
9b8bd79a37
commit
81bc9987bd
1 changed files with 4 additions and 4 deletions
|
@ -67,18 +67,18 @@ ynh_psql_execute_file_as_root() {
|
|||
#
|
||||
# [internal]
|
||||
#
|
||||
# usage: ynh_psql_create_db db [user [pwd]]
|
||||
# usage: ynh_psql_create_db db [user]
|
||||
# | arg: db - the database name to create
|
||||
# | arg: user - the user to grant privilegies
|
||||
# | arg: pwd - the password to identify user by
|
||||
ynh_psql_create_db() {
|
||||
local db=$1
|
||||
local user=$2
|
||||
|
||||
local sql="CREATE DATABASE ${db};"
|
||||
|
||||
# grant all privilegies to user
|
||||
if [[ $# -gt 1 ]]; then
|
||||
sql+="GRANT ALL PRIVILEGES ON DATABASE ${db} TO ${2} WITH GRANT OPTION;"
|
||||
if [ $# -gt 1 ]; then
|
||||
sql+="GRANT ALL PRIVILEGES ON DATABASE ${db} TO ${user} WITH GRANT OPTION;"
|
||||
fi
|
||||
|
||||
ynh_psql_execute_as_root --sql="$sql"
|
||||
|
|
Loading…
Add table
Reference in a new issue