mirror of
https://github.com/YunoHost-Apps/wekan_ynh.git
synced 2024-09-03 20:36:09 +02:00
manage authentification in mongodump and mongorestore
This commit is contained in:
parent
db5044786b
commit
42a04c1259
1 changed files with 15 additions and 3 deletions
|
@ -184,7 +184,13 @@ ynh_mongo_dump_db() {
|
|||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
mongodump --quiet --db="$database" --archive
|
||||
local connexion=""
|
||||
if [ -f "$MONGO_ROOT_PWD_FILE" ]
|
||||
then
|
||||
connexion="--username=\"$MONGO_ROOT_USER\" --password=\"$(cat $MONGO_ROOT_PWD_FILE)\" --authenticationDatabase=admin"
|
||||
fi
|
||||
|
||||
mongodump $connexion --quiet --db="$database" --archive
|
||||
}
|
||||
|
||||
# Create a user
|
||||
|
@ -253,7 +259,13 @@ ynh_mongo_restore_db() {
|
|||
# Manage arguments with getopts
|
||||
ynh_handle_getopts_args "$@"
|
||||
|
||||
mongorestore --quiet --db="$database" --archive
|
||||
local connexion=""
|
||||
if [ -f "$MONGO_ROOT_PWD_FILE" ]
|
||||
then
|
||||
connexion="--username=\"$MONGO_ROOT_USER\" --password=\"$(cat $MONGO_ROOT_PWD_FILE)\" --authenticationDatabase=admin"
|
||||
fi
|
||||
|
||||
mongorestore $connexion --quiet --db="$database" --archive
|
||||
}
|
||||
|
||||
# Drop a user
|
||||
|
@ -366,7 +378,7 @@ ynh_mongo_test_if_first_run() {
|
|||
local mongo_root_password="$(ynh_string_random)"
|
||||
echo "$mongo_root_password" >$MONGO_ROOT_PWD_FILE
|
||||
|
||||
ynh_mongo_exec --database=admin --command='db.createUser( { user: "'${MONGO_ROOT_USER}'", pwd: "'${mongo_root_password}'", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] } );'
|
||||
ynh_mongo_exec --database=admin --command='db.createUser( { user: "'${MONGO_ROOT_USER}'", pwd: "'${mongo_root_password}'", roles: [ { role: "root", db: "admin" } ] } );'
|
||||
|
||||
ynh_systemd_action --service_name=$MONGODB_SERVICENAME --action=stop
|
||||
# Enable access control
|
||||
|
|
Loading…
Add table
Reference in a new issue