Added custom configuration file location support

master
Aaron Johnon 4 years ago
parent b3ceb9be9d
commit 505595b9f9

@ -1,7 +1,4 @@
# Bot Info CHATID="5555555" #Chat ID for the Telegram room/conversation with bot
CHATID="5555555" KEY="THISISAUNIQUEANDPRIVATEKEY" #Your bot's API key
KEY="THISISAUNIQUEANDPRIVATEKEY" CHKLIST="${HOME}/.site_check" #A file containing a list of sites/URLs to check
# Site list (file location)
CHKLIST="${HOME}/.site_check"

@ -1,9 +1,41 @@
#!/bin/sh #!/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
CONFIG=$1
# BEGIN CONFIG CHECK
### Provides KEY, CHATID, CHKLIST
if [ -n "$CONFIG" ]; then
if [ -f "$CONFIG" ]; then
source $CONFIG
else
printf '%s\n' "$CONFIG: File does not exist." >&2
exit 10
fi
else
if [ -f ".httpcheck_telegram" ]; then
source .httpcheck_telegram
else
printf '%s\n' "No configuration file found." >&2
exit 10
fi
fi
# Check if config was loaded by examining all configuration variables, exit if not
if [ -z "$KEY" ]; then
printf '%s\n' "Configuration not set correctly: KEY not set" >&2
ERROR11=true
fi
if [ -z "$CHATID" ]; then
printf '%s\n' "Configuration not set correctly: CHATID not set" >&2
ERROR11=true
fi
if [ -z "$CHKLIST" ]; then
printf '%s\n' "Configuration not set correctly: CHKLIST not set" >&2
ERROR11=true
fi
[ "$ERROR11" = "true" ] && exit 11
# END CONFIG CHECK
# Load Telegram bot info
source .httpcheck_telegram #Provides KEY, CHATID, CHKLIST
TIME="10" TIME="10"
URL="https://api.telegram.org/bot$KEY/sendMessage" URL="https://api.telegram.org/bot$KEY/sendMessage"

Loading…
Cancel
Save