1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/libreerp_ynh.git synced 2024-09-03 19:36:13 +02:00

[fix] Give db creation right to odoo psql user

This commit is contained in:
ljf 2016-12-14 13:15:34 +01:00
parent 142ca202ac
commit 9b6aaec88a
2 changed files with 15 additions and 5 deletions

View file

@ -21,19 +21,28 @@ PKGDIR=$(cd ../; pwd)
# Common helpers # Common helpers
# #
# # Execute a command as root user
#
# usage: ynh_psql_execute_as_root sql [db]
# | arg: sql - the SQL command to execute
# | arg: db - the database to connect to
ynh_psql_execute_as_root () {
sudo su -c "psql" postgres <<< ${1}
}
# Create a user # Create a user
# #
# usage: ynh_mysql_create_user user pwd [host] # usage: ynh_psql_create_user user pwd [host]
# | arg: user - the user name to create # | arg: user - the user name to create
# | arg: pwd - the password to identify user by # | arg: pwd - the password to identify user by
ynh_psql_create_user() { ynh_psql_create_user() {
sudo su -c "psql" postgres <<< \ ynh_psql_execute_as_root \
"CREATE USER ${1} WITH PASSWORD '${2}';" "CREATE USER ${1} WITH PASSWORD '${2}';"
} }
# Create a database and grant optionnaly privilegies to a user # Create a database and grant optionnaly privilegies to a user
# #
# usage: ynh_mysql_create_db db [user [pwd]] # usage: ynh_psql_create_db db [user [pwd]]
# | arg: db - the database name to create # | arg: db - the database name to create
# | arg: user - the user to grant privilegies # | arg: user - the user to grant privilegies
# | arg: pwd - the password to identify user by # | arg: pwd - the password to identify user by
@ -51,7 +60,7 @@ ynh_psql_create_db() {
# Drop a database # Drop a database
# #
# usage: ynh_mysql_drop_db db # usage: ynh_psql_drop_db db
# | arg: db - the database name to drop # | arg: db - the database name to drop
ynh_psql_drop_db() { ynh_psql_drop_db() {
sudo su -c "dropdb ${1}" postgres sudo su -c "dropdb ${1}" postgres
@ -59,7 +68,7 @@ ynh_psql_drop_db() {
# Drop a user # Drop a user
# #
# usage: ynh_mysql_drop_user user # usage: ynh_psql_drop_user user
# | arg: user - the user name to drop # | arg: user - the user name to drop
ynh_psql_drop_user() { ynh_psql_drop_user() {
sudo su -c "dropuser ${1}" postgres sudo su -c "dropuser ${1}" postgres

View file

@ -76,6 +76,7 @@ else
sudo rm -Rf $DESTDIR sudo rm -Rf $DESTDIR
ynh_psql_create_db $APPNAME $APPNAME "$dbpass" ynh_psql_create_db $APPNAME $APPNAME "$dbpass"
ynh_psql_execute_as_root "ALTER USER $APPNAME WITH CREATEDB;"
# Set admin password # Set admin password
# TODO Support @ in password # TODO Support @ in password