From ab01ccd5774be20f74fec9ef76a1f95b77614ae2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 28 Jun 2022 22:52:55 +0200 Subject: [PATCH] better rs.initiate --- scripts/install | 4 +++- scripts/restore | 4 +++- scripts/upgrade | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3af0053..9644bd1 100644 --- a/scripts/install +++ b/scripts/install @@ -135,7 +135,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #============================================== # INSTALL ROCKETCHAT diff --git a/scripts/restore b/scripts/restore index 400c74f..3a68deb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -103,7 +103,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #================================================= # RESTORE SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 07fdd70..3f5619e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -132,7 +132,9 @@ ynh_systemd_action --service_name=$mongodb_servicename --action=restart sleep 10 -ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +if ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.status())" | grep -q "no replset config has been received"; then + ynh_exec_warn_less ynh_mongo_exec --command="printjson(rs.initiate())" --eval +fi #============================================== # INSTALL ROCKETCHAT