1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/overleaf_ynh.git synced 2024-09-03 19:56:27 +02:00

test adding replicaset to mongo

This commit is contained in:
Thomas 2024-02-15 13:52:13 +01:00 committed by GitHub
parent a32d0de1c9
commit 43482045a0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -103,7 +103,8 @@ ynh_mongo_exec() {
database=""
fi
mongosh --quiet --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port <<EOF
mongosh --quiet --replSet rs0 --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port
mongosh rs.initiate() <<EOF
$database
${command}
quit()
@ -117,7 +118,8 @@ EOF
database=""
fi
mongosh --quiet $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
mongosh --quiet --replSet rs0 $database --username $user --password $password --authenticationDatabase $authenticationdatabase --host $host --port $port --eval="$command"
mongosh rs.initiate()
fi
}
@ -184,10 +186,10 @@ ynh_mongo_create_user() {
ynh_handle_getopts_args "$@"
# Create the user and set the user as admin of the db
ynh_mongo_exec --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
ynh_mongo_exec --replSet rs0 --database="$db_name" --command='db.createUser( { user: "'${db_user}'", pwd: "'${db_pwd}'", roles: [ { role: "readWrite", db: "'${db_name}'" } ] } );'
# Add clustermonitoring rights
ynh_mongo_exec --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
ynh_mongo_exec --replSet rs0 --database="$db_name" --command='db.grantRolesToUser("'${db_user}'",[{ role: "clusterMonitor", db: "admin" }]);'
}
# Check if a mongo database exists