Multiple Surfbars can be tracked (if you use unraid/Proxmox and got multiple LXC/Surfbars with VPN)

This commit is contained in:
Pakobbix 2023-02-10 18:29:13 +01:00
parent cd158fc0dc
commit d31d7e9f60

View File

@ -54,7 +54,7 @@ setup_config() {
) )
case "$messagehandler" in case "$messagehandler" in
SurfbarName) SurfbarName)
surflink=$(whiptail --title "Surfbar Link" --inputbox "Gebe hier den Namen deiner Surfbar ein\nBeispiel:\nHttps://www.ebesucher.de/surfbar/MeinSurfLink\nName ist hierbei: MeinSurfLink" 16 100 3>&2 2>&1 1>&3) surflink=$(whiptail --title "Surfbar Link" --inputbox "Gebe hier den Namen deiner Surfbar ein\nBeispiel:\nHttps://www.ebesucher.de/surfbar/MeinSurfLink\nName ist hierbei: MeinSurfLink\nEs können auch mehrere eingegeben werden." 16 100 3>&2 2>&1 1>&3)
if [ -n "$surflink" ]; then if [ -n "$surflink" ]; then
sed -i "s/SurfbarName=.*/SurfbarName=\"$surflink\"/g" $config sed -i "s/SurfbarName=.*/SurfbarName=\"$surflink\"/g" $config
fi fi
@ -196,10 +196,12 @@ if [ -z "$SurfbarName" ]; then
setup_config setup_config
fi fi
ProcessID=$(pgrep -f "surfbar/$SurfbarName") for SurfbarLinks in $SurfbarName; do
case $NotificationHandler in ProcessID=$(pgrep -f "surfbar/$SurfbarLinks")
Discord)
case $NotificationHandler in
Discord)
if [ -z "$Discord_WebHookLink" ]; then if [ -z "$Discord_WebHookLink" ]; then
fehler "Fehler! Discord wurde ausgewählt, aber keine WebHook angegeben!" fehler "Fehler! Discord wurde ausgewählt, aber keine WebHook angegeben!"
echo echo
@ -208,13 +210,13 @@ Discord)
exit 1 exit 1
else else
if [ -z "$ProcessID" ]; then if [ -z "$ProcessID" ]; then
curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"Ebesucher ist Abgestürzt.\n$SurfbarName läuft nicht mehr\"}" "$Discord_WebHookLink" &>/dev/null curl -i -H "Accept: application/json" -H "Content-Type:application/json" -X POST --data "{\"content\": \"Ebesucher ist Abgestürzt.\n$SurfbarLinks läuft nicht mehr\"}" "$Discord_WebHookLink" &>/dev/null
else else
exit 1 exit 1
fi fi
fi fi
;; ;;
Telegram) Telegram)
if [ -z "$Telegram_UID" ] || [ -z "$Telegram_BT" ]; then if [ -z "$Telegram_UID" ] || [ -z "$Telegram_BT" ]; then
fehler "Fehler! Discord wurde ausgewählt, aber keine WebHook angegeben!" fehler "Fehler! Discord wurde ausgewählt, aber keine WebHook angegeben!"
echo echo
@ -229,7 +231,7 @@ Telegram)
fi fi
fi fi
;; ;;
Apprise) Apprise)
if [ -z "$AppRiseURL" ]; then if [ -z "$AppRiseURL" ]; then
fehler "Fehler! AppRise wurde ausgewählt, aber keine URL angegeben!" fehler "Fehler! AppRise wurde ausgewählt, aber keine URL angegeben!"
echo echo
@ -239,26 +241,26 @@ Apprise)
else else
if [ -z "$ProcessID" ]; then if [ -z "$ProcessID" ]; then
if [ -n "$AppRiseTAG" ]; then if [ -n "$AppRiseTAG" ]; then
curl -d '{"body":"'"Ebesucher Container $SurfbarName ist down"'", "title":"Passive-Income Notification: Ebesucher ist Abgestürzt","tag":"'"$AppRiseTAG"'"}' -H "Content-Type: application/json" "$AppRiseURL" &>/dev/null curl -d '{"body":"'"Ebesucher Container $SurfbarLinks ist down"'", "title":"Passive-Income Notification: Ebesucher ist Abgestürzt","tag":"'"$AppRiseTAG"'"}' -H "Content-Type: application/json" "$AppRiseURL" &>/dev/null
else else
curl -d '{"body":"'"Ebesucher Container $SurfbarName ist down"'", "title":"Passive-Income Notification: Ebesucher ist Abgestürzt","tag":"all"}' -H "Content-Type: application/json" "$AppRiseURL" &>/dev/null curl -d '{"body":"'"Ebesucher Container $SurfbarLinks ist down"'", "title":"Passive-Income Notification: Ebesucher ist Abgestürzt","tag":"all"}' -H "Content-Type: application/json" "$AppRiseURL" &>/dev/null
fi fi
else else
exit 1 exit 1
fi fi
fi fi
;; ;;
NextCloud) NextCloud)
if [ -z "$NextcloudUser" ] || [ -z "$NextcloudPassword" ] || [ -z "$NextcloudDomain" ] || [ -z "$NextcloudTalkToken" ]; then if [ -z "$NextcloudUser" ] || [ -z "$NextcloudPassword" ] || [ -z "$NextcloudDomain" ] || [ -z "$NextcloudTalkToken" ]; then
echo "Eine oder mehrere Variablen (NextcloudUser, NextcloudPassword, NextcloudDomain, und/oder NextcloudTalkToken) wurden nicht angegeben. Beende NotificationHandler!." echo "Eine oder mehrere Variablen (NextcloudUser, NextcloudPassword, NextcloudDomain, und/oder NextcloudTalkToken) wurden nicht angegeben. Beende NotificationHandler!."
exit 1 exit 1
else else
if [ -z "$ProcessID" ]; then if [ -z "$ProcessID" ]; then
curl -d '{"token":"'"$NextcloudTalkToken"'", "message":"'"Passive-Income Notification: Ebesucher ist Abgestürzt\nEbesucher Container $SurfbarName ist down"'"}' -H "Content-Type: application/json" -H "Accept:application/json" -H "OCS-APIRequest:true" -u "$NextcloudUser:$NextcloudPassword" "$NextcloudDomain"/ocs/v1.php/apps/spreed/api/v1/chat/tokenid &>/dev/null curl -d '{"token":"'"$NextcloudTalkToken"'", "message":"'"Passive-Income Notification: Ebesucher ist Abgestürzt\nEbesucher Container $SurfbarLinks ist down"'"}' -H "Content-Type: application/json" -H "Accept:application/json" -H "OCS-APIRequest:true" -u "$NextcloudUser:$NextcloudPassword" "$NextcloudDomain"/ocs/v1.php/apps/spreed/api/v1/chat/tokenid &>/dev/null
fi fi
fi fi
;; ;;
PushBullet) PushBullet)
if [ -z "$PushBulletToken" ]; then if [ -z "$PushBulletToken" ]; then
fehler "Fehler! PushBullet wurde ausgewählt, aber kein Token angegeben!" fehler "Fehler! PushBullet wurde ausgewählt, aber kein Token angegeben!"
echo echo
@ -267,13 +269,13 @@ PushBullet)
exit 1 exit 1
else else
if [ -z "$ProcessID" ]; then if [ -z "$ProcessID" ]; then
curl -u "$PushBulletToken": -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Passive-Income Notification: Ebesucher ist Abgestürzt", "body": "Ebesucher Container '"$SurfbarName"' ist down"}' curl -u "$PushBulletToken": -X POST https://api.pushbullet.com/v2/pushes --header 'Content-Type: application/json' --data-binary '{"type": "note", "title": "Passive-Income Notification: Ebesucher ist Abgestürzt", "body": "Ebesucher Container '"$SurfbarLinks"' ist down"}'
else else
exit 1 exit 1
fi fi
fi fi
;; ;;
Email) Email)
if [ -z "$smtpURL" ] || [ -z "$smtpPORT" ] || [ -z "$mailfrom" ] || [ -z "$mailrcpt" ] || [ -z "$mailuser" ] || [ -z "$mailpass" ]; then if [ -z "$smtpURL" ] || [ -z "$smtpPORT" ] || [ -z "$mailfrom" ] || [ -z "$mailrcpt" ] || [ -z "$mailuser" ] || [ -z "$mailpass" ]; then
echo "Fehler! Mail wurde ausgewählt, aber eines oder mehrere Variablen leer gelassen!" echo "Fehler! Mail wurde ausgewählt, aber eines oder mehrere Variablen leer gelassen!"
exit 1 exit 1
@ -284,7 +286,7 @@ To: $mailrcpt $mailrcpt
Subject: Passive-Income Notification: Ebesucher ist Abgestürzt Subject: Passive-Income Notification: Ebesucher ist Abgestürzt
Hi $mailrcpt, Hi $mailrcpt,
Your Ebesucher Container $SurfbarName ist abgestürzt und läuft nicht mehr. Your Ebesucher Container $SurfbarLinks ist abgestürzt und läuft nicht mehr.
Bye!" >/root/pain_watchmail Bye!" >/root/pain_watchmail
curl "smtps://$smtpURL:$smtpPORT" --mail-from "$mailfrom" --mail-rcpt "$mailrcpt" -T /root/pain_watchmail -u "$mailuser:$mailpass" --ssl-reqd --insecure --show-error -s curl "smtps://$smtpURL:$smtpPORT" --mail-from "$mailfrom" --mail-rcpt "$mailrcpt" -T /root/pain_watchmail -u "$mailuser:$mailpass" --ssl-reqd --insecure --show-error -s
else else
@ -292,7 +294,7 @@ Bye!" >/root/pain_watchmail
fi fi
fi fi
;; ;;
Rocket.Chat) Rocket.Chat)
if [ -z "$RocketChatHook" ]; then if [ -z "$RocketChatHook" ]; then
fehler "Fehler! RocketChat wurde ausgewählt, aber keine WebHook angegeben!" fehler "Fehler! RocketChat wurde ausgewählt, aber keine WebHook angegeben!"
echo echo
@ -301,10 +303,11 @@ Rocket.Chat)
exit 1 exit 1
else else
if [ -z "$ProcessID" ]; then if [ -z "$ProcessID" ]; then
curl -X POST -H 'Content-Type: application/json' --data '{"text":"Passive-Income Notification: Ebesucher ist Abgestürzt","attachments":[{"title":"Passive-Income Notification: Ebesucher ist Abgestürzt","text":"Ebesucher Container '"$SurfbarName"' ist down","color":"#764FA5"}]}' "$RocketChatHook" curl -X POST -H 'Content-Type: application/json' --data '{"text":"Passive-Income Notification: Ebesucher ist Abgestürzt","attachments":[{"title":"Passive-Income Notification: Ebesucher ist Abgestürzt","text":"Ebesucher Container '"$SurfbarLinks"' ist down","color":"#764FA5"}]}' "$RocketChatHook"
else else
exit 1 exit 1
fi fi
fi fi
;; ;;
esac esac
done