health: respect overriding nc binary for IRC notifications (#15310)
Ilya Mashchenko committed
Jul 5, 2023 at 13:18 UTC
1e181518553ea297768aa80a86e74e15569e0617
1 file changed
+10
-1
health/notifications/alarm-notify.sh.in
+10
-1
@@ -768,6 +768,15 @@ if [ "${SEND_AWSSNS}" = "YES" ] && [ -z "${aws}" ]; then
768
fi
769
fi
770
771
+# if we need nc, check for the nc command
772
+if [ "${SEND_IRC}" = "YES" ] && [ -z "${nc}" ]; then
773
+ nc="$(command -v nc 2>/dev/null)"
774
+ if [ -z "${nc}" ]; then
775
+ debug "Cannot find nc command in the system path. Disabling IRC notifications."
776
+ SEND_IRC="NO"
777
+ fi
778
+fi
779
+
780
if [ ${dump_methods} ]; then
781
for name in "${!SEND_@}"; do
782
if [ "${!name}" = "YES" ]; then
@@ -1913,7 +1922,7 @@ send_irc() {
1922
SNDMESSAGE="${MESSAGE//$'\n'/", "}"
1923
for CHANNEL in ${CHANNELS}; do
1924
error=0
1916
- send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | nc "${NETWORK}" "${PORT}")
1925
+ send_alarm=$(echo -e "USER ${NICKNAME} guest ${REALNAME} ${SERVERNAME}\\nNICK ${NICKNAME}\\nJOIN ${CHANNEL}\\nPRIVMSG ${CHANNEL} :${SNDMESSAGE}\\nQUIT\\n" \ | ${nc} "${NETWORK}" "${PORT}")
1926
reply_codes=$(echo "${send_alarm}" | cut -d ' ' -f 2 | grep -o '[0-9]*')
1927
for code in ${reply_codes}; do
1928
if [ "${code}" -ge 400 ] && [ "${code}" -le 599 ]; then