CAI-Watchdog/scripts/unix/etc/cai-watchdog/on-uri-state-change
2022-10-29 20:54:23 +03:00

30 lines
705 B
Bash

#!/bin/bash
APP_PATH=$(dirname "$0") # relative
APP_PATH=$(cd "$APP_PATH" && pwd) # absolutized and normalized
if [[ -z "$APP_PATH" ]] ; then
# error; for some reason, the path is not accessible
# to the script (e.g. permissions re-evaled after suid)
APP_PATH="/etc/cai-watchdog"
fi
##### DEFAULT PARAMS ORDER #####
## $1 - <email>
## $2 - <subject>
## $3 - <message>
## $4 - <service>
## $5 - <uri>
## $6 - <status> [online | offline]
EMAIL=$1
SUBJECT=$2
MESSAGE=$3
SERVICE=$4
URI=$5
STATUS=$6
## SAMPLE COMMANDS
#${APP_PATH}/send-mail "${EMAIL}", "${SUBJECT}", "$MESSAGE"
#${APP_PATH}/send-telegram-ru "${SERVICE}", "${URI}", "$STATUS"
${APP_PATH}/send-telegram "$MESSAGE"