diff --git a/management/univention-directory-notifier/univention-replicate-many b/management/univention-directory-notifier/univention-replicate-many index 029663bc41..cf21b0d8b5 100755 --- a/management/univention-directory-notifier/univention-replicate-many +++ b/management/univention-directory-notifier/univention-replicate-many @@ -68,7 +68,7 @@ RESTART_NOTIFIER=0 if pidof univention-directory-notifier >/dev/null ; then echo -n "Stopping notifier: " RESTART_NOTIFIER=1 - /etc/init.d/univention-directory-notifier stop >/dev/null + systemctl stop univention-directory-notifier sleep 1 if pidof univention-directory-notifier >/dev/null ; then echo "failed" @@ -82,7 +82,7 @@ RESTART_SLAPD=0 if pidof slapd >/dev/null ; then echo -n "Stopping slapd: " RESTART_SLAPD=1 - /etc/init.d/slapd stop >/dev/null + systemctl stop slapd sleep 1 if pidof slapd >/dev/null ; then echo "failed" @@ -97,7 +97,7 @@ id="$(tail -n 1 /var/lib/univention-ldap/notify/transaction | awk '{print $1}')" last_line="$(tail -n 1 /var/lib/univention-ldap/listener/listener)" if [ -n "$last_line" ]; then - id_listener="$(tail -n 1 /var/lib/univention-ldap/listener/listener | awk '{print $1}')" + id_listener="$(awk '{print $1}' <<<"$last_line")" fi if [ -n "$id_listener" ] && [ "$id_listener" -gt "$id" ]; then @@ -106,31 +106,39 @@ else nextid=$((id+1)) fi -skip= +skip='' while read -r dn; do if [ -n "$dn" ] && slapdn "$dn" > /dev/null 2>&1; then echo "$nextid $dn m" >>/var/lib/univention-ldap/listener/listener echo -n "$nextid" >/var/lib/univention-ldap/last_id nextid=$((nextid+1)) else - # shellcheck disable=SC2206,SC1117 - test -n "$dn" && skip=($skip"Info: Skipped invalid dn '$dn'\n") + # shellcheck disable=SC1117 + test -n "$dn" && skip="${skip}Info: Skipped invalid dn '$dn'\n" fi done < "${dnfile}" echo "done" -echo -ne "${skip[*]}" >&2 +echo -ne "$skip" >&2 + rc=0 +if [ "$RESTART_SLAPD" = 1 ]; then + echo -n "Starting slapd: " + if systemctl start slapd; then + echo "done" + else + echo "failed" + rc=1 + fi +fi if [ "$RESTART_NOTIFIER" = 1 ]; then echo -n "Starting notifier: " - /etc/init.d/univention-directory-notifier start >/dev/null || rc=1 - echo "done" -fi - -if [ "$RESTART_SLAPD" = 1 ]; then - echo -n "Starting slapd: " - /etc/init.d/slapd start >/dev/null || rc=1 - echo "done" + if systemctl start univention-directory-notifier; then + echo "done" + else + echo "failed" + rc=1 + fi fi exit $rc