--- platforms/darwin/apcupsd-start.in.orig	2023-08-14 14:54:34
+++ platforms/darwin/apcupsd-start.in	2023-08-14 16:30:32
@@ -3,4 +3,18 @@
 rm -f /etc/apcupsd/powerfail
 rm -f /etc/nologin

-@sbindir@/apcupsd $@
+log_dated() {
+  printf -- '%s  %s\n' "$(date +'%Y-%m-%d %H:%M:%S %z')" "$@" >&2
+}
+
+i=1
+log_dated 'Attempting to connect to UPS'
+while ! @sbindir@/apcupsd "$@"; do
+  if [ "$i" -eq 30 ]; then
+  	log_dated "Cannot connect after ${i} attempts, giving up"
+  	exit 1
+  fi
+  log_dated "Cannot connect to UPS (attempt ${i}), retrying in 1 second"
+  sleep 1;
+  i=$((i + 1))
+done
