diff --git a/zmbh/zmbh.pl b/zmbh/zmbh.pl index 38e9246..61c3d17 100644 --- a/zmbh/zmbh.pl +++ b/zmbh/zmbh.pl @@ -101,7 +101,24 @@ if ( $opt->{pre} ) { log_info("No service were shutted down"); } elsif ($opt->{shutdown} eq 'ldap' and -e '/opt/zimbra/bin/ldap'){ log_info("Starting Zimbra LDAP service"); - system("/opt/zimbra/bin/ldap start"); + my $try = 0; + my $running = 0; + while ($try < 20) { + system("/opt/zimbra/bin/ldap start"); + sleep 1; + if (system("/opt/zimbra/bin/ldap status") == 0){ + $running = 1; + last; + } else { + log_info('ldap service not running, trying again to start it'); + $try++; + } + } + # Couldn't start ldap ? Restart all the services + if (not $running){ + log_info("Failed to restart ldap, restarting all Zimbra services"); + system('systemctl restart zimbra'); + } } else { log_info("Starting Zimbra services"); system('systemctl start zimbra');