#!/bin/sh
# Readiness: does the proxy accept runtime commands?
#
# "zabbix_proxy -R config_cache_reload" talks to the running process via the
# runtime control socket. It needs NO server contact -- measured
# 23.09.2026 on a proxy without a reachable server:
#   running -> "Runtime control command was forwarded successfully", rc 0
#   dead    -> "Cannot connect to service \"rtc\": No such file or directory", rc 1
# So the return code is usable here; nevertheless the string is checked
# ADDITIONALLY, because an rc alone has lied twice already (pdns_control
# rping, svctl isup).
#
# The price: the check reloads the configuration. During the start phase --
# s6-notifyoncheck does not ask any longer than that -- this is harmless; a
# purely read-only test does not exist, the SocketDir only holds the PID file
# (checked).
out=$(zabbix_proxy -R config_cache_reload 2>&1) || exit 1
case $out in
*"forwarded successfully"*) exit 0 ;;
*) exit 1 ;;
esac
