mirror of
https://github.com/Pakobbix/passive-income.git
synced 2025-11-09 14:59:40 +00:00
Menu Loop added. add Crontab entry via config.
This commit is contained in:
parent
d31d7e9f60
commit
d23d1752ca
246
notifier.sh
246
notifier.sh
@ -40,119 +40,139 @@ URLlink() {
|
|||||||
config="/opt/Passive-Income/NotificationHandler/config"
|
config="/opt/Passive-Income/NotificationHandler/config"
|
||||||
|
|
||||||
setup_config() {
|
setup_config() {
|
||||||
messagehandler=$(
|
while true; do
|
||||||
whiptail --title "Wähle den Notifier" --menu "Nehme hier die Art der Benachrichtung die du haben willst." 20 100 9 \
|
messagehandler=$(
|
||||||
"SurfbarName" "" \
|
whiptail --title "Wähle den Notifier" --menu "Nehme hier die Art der Benachrichtung die du haben willst." 20 100 9 \
|
||||||
"Discord" "" \
|
"SurfbarName" "" \
|
||||||
"Telegram" "" \
|
"Discord" "" \
|
||||||
"Apprise" "" \
|
"Telegram" "" \
|
||||||
"NextcloudTalk" "" \
|
"Apprise" "" \
|
||||||
"PushBullet" "" \
|
"NextcloudTalk" "" \
|
||||||
"Email" "" \
|
"PushBullet" "" \
|
||||||
"Rocket.Chat" "" \
|
"Email" "" \
|
||||||
"Abbrechen" "" 3>&2 2>&1 1>&3
|
"Rocket.Chat" "" \
|
||||||
)
|
"CronErstellen" \
|
||||||
case "$messagehandler" in
|
"Beenden" "" 3>&2 2>&1 1>&3
|
||||||
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\nEs können auch mehrere eingegeben werden." 16 100 3>&2 2>&1 1>&3)
|
case "$messagehandler" in
|
||||||
if [ -n "$surflink" ]; then
|
CronErstellen)
|
||||||
sed -i "s/SurfbarName=.*/SurfbarName=\"$surflink\"/g" $config
|
cronloc="/tmp/crontab"
|
||||||
fi
|
curr_dir=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &>/dev/null && pwd)
|
||||||
;;
|
scriptname=$(echo "$0" | sed 's/\.\///g')
|
||||||
Discord)
|
crontab -l "$cronloc"
|
||||||
dishook=$(whiptail --title "Discord Webhook URL" --inputbox "Gebe hier deine Discord Webhook URL ein" 16 100 3>&2 2>&1 1>&3)
|
if grep -q "notifier.sh" $cronloc; then
|
||||||
if [ -n "$dishook" ]; then
|
if whiptail --title "Eintrag bereits vorhanden" --yesno "Es ist bereits ein eintrag für den notifier vorhanden, möchtest du diesen überschreiben?" 20 100; then
|
||||||
sed -i "s|Discord_WebHookLink=.*|Discord_WebHookLink=\"$dishook\"|g" $config
|
sed -i "s|.*notifier.sh.*|10,20,30,40,50 * * * * /bin/bash $curr_dir/$scriptname|g" "$cronloc"
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Discord\"/g" $config
|
crontab "$cronloc"
|
||||||
fi
|
fi
|
||||||
;;
|
else
|
||||||
Telegram)
|
echo "10,20,30,40,50 * * * * /bin/bash $curr_dir/$scriptname|g" >>"$cronloc"
|
||||||
T_UI=$(whiptail --title "Telegram USER ID" --inputbox "Gebe hier deine Telegram USERID ein" 16 100 3>&2 2>&1 1>&3)
|
crontab "$cronloc"
|
||||||
T_BotToken=$(whiptail --title "Telegram Bot Token" --inputbox "Gebe hier deinen Telegram Bot Token ein" 16 100 3>&2 2>&1 1>&3)
|
fi
|
||||||
if [ -n "$T_UI" ]; then
|
;;
|
||||||
sed -i "s/Telegram_UID=.*/Telegram_UID=\"$T_UI\"/g" $config
|
SurfbarName)
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Telegram\"/g" $config
|
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)
|
||||||
fi
|
if [ -n "$surflink" ]; then
|
||||||
if [ -n "$T_BotToken" ]; then
|
sed -i "s/SurfbarName=.*/SurfbarName=\"$surflink\"/g" $config
|
||||||
sed -i "s/Telegram_BT=.*/Telegram_BT=\"$T_BotToken\"/g" $config
|
fi
|
||||||
fi
|
;;
|
||||||
;;
|
Discord)
|
||||||
Apprise)
|
dishook=$(whiptail --title "Discord Webhook URL" --inputbox "Gebe hier deine Discord Webhook URL ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
AppRise_URL=$(whiptail --title "AppRise URL" --inputbox "Gebe hier die AppRise URL ein\nNötig ist hier die IP:Port. Beispiel:\n192.168.5.21:8000" 16 100 3>&2 2>&1 1>&3)
|
if [ -n "$dishook" ]; then
|
||||||
AppRise_URL_TAG=$(whiptail --title "AppRise Tag" --inputbox "Gebe hier einen AppRise Tag ein (Optional! Achtung, ohne Tag\nwerden alle Konfigurierten Methoden in Apprise genutzt)" 16 100 3>&2 2>&1 1>&3)
|
sed -i "s|Discord_WebHookLink=.*|Discord_WebHookLink=\"$dishook\"|g" $config
|
||||||
if [ -n "$AppRise_URL" ]; then
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Discord\"/g" $config
|
||||||
sed -i "s|AppRiseURL=.*|AppRiseURL=\"$AppRise_URL/notify/apprise\"|g" $config
|
fi
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Apprise\"/g" $config
|
;;
|
||||||
fi
|
Telegram)
|
||||||
if [ -n "$AppRise_URL_TAG" ]; then
|
T_UI=$(whiptail --title "Telegram USER ID" --inputbox "Gebe hier deine Telegram USERID ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
sed -i "s/AppRiseTAG=.*/AppRiseTAG=\"$AppRise_URL_TAG\"/g" $config
|
T_BotToken=$(whiptail --title "Telegram Bot Token" --inputbox "Gebe hier deinen Telegram Bot Token ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
fi
|
if [ -n "$T_UI" ]; then
|
||||||
;;
|
sed -i "s/Telegram_UID=.*/Telegram_UID=\"$T_UI\"/g" $config
|
||||||
NextcloudTalk)
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Telegram\"/g" $config
|
||||||
NextcloudDomain=$(whiptail --title "Nextcloud Domain" --inputbox "Gebe hier deine Nextcloud Domain/IP:Port ein\nBeispiel: 10.0.0.4:85 oder\nhttps://cloud.zephyre.one" 16 100 3>&2 2>&1 1>&3)
|
fi
|
||||||
NextcloudTalkToken=$(whiptail --title "Nextcloud Talk Token" --inputbox "Gebe hier deinen Nextcloud Talk Chatroom Token ein\nhttps://cloud.zephyre.one/call/9gp9y99i\n9gp9y99i ist der benötigte Token" 16 100 3>&2 2>&1 1>&3)
|
if [ -n "$T_BotToken" ]; then
|
||||||
NextcloudUser=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier deinen Nextcloud User ein der die Nachricht schreiben soll.\nDer User muss dem Chatroom hinzugefügt werden!" 16 100 3>&2 2>&1 1>&3)
|
sed -i "s/Telegram_BT=.*/Telegram_BT=\"$T_BotToken\"/g" $config
|
||||||
NextcloudPassword=$(whiptail --title "Nextcloud Password" --passwordbox "Gebe hier das Passwort von dem Nextcloud User ein" 16 100 3>&2 2>&1 1>&3)
|
fi
|
||||||
if [ -n "$NextcloudDomain" ]; then
|
;;
|
||||||
sed -i "s|NextcloudDomain=.*|NextcloudDomain=\"$NextcloudDomain\"|g" $config
|
Apprise)
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"NextCloud\"/g" $config
|
AppRise_URL=$(whiptail --title "AppRise URL" --inputbox "Gebe hier die AppRise URL ein\nNötig ist hier die IP:Port. Beispiel:\n192.168.5.21:8000" 16 100 3>&2 2>&1 1>&3)
|
||||||
fi
|
AppRise_URL_TAG=$(whiptail --title "AppRise Tag" --inputbox "Gebe hier einen AppRise Tag ein (Optional! Achtung, ohne Tag\nwerden alle Konfigurierten Methoden in Apprise genutzt)" 16 100 3>&2 2>&1 1>&3)
|
||||||
if [ -n "$NextcloudTalkToken" ]; then
|
if [ -n "$AppRise_URL" ]; then
|
||||||
sed -i "s/NextcloudTalkToken=.*/NextcloudTalkToken=\"$NextcloudTalkToken\"/g" $config
|
sed -i "s|AppRiseURL=.*|AppRiseURL=\"$AppRise_URL/notify/apprise\"|g" $config
|
||||||
fi
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Apprise\"/g" $config
|
||||||
if [ -n "$NextcloudUser" ]; then
|
fi
|
||||||
sed -i "s/NextcloudUser=.*/NextcloudUser=\"$NextcloudUser\"/g" $config
|
if [ -n "$AppRise_URL_TAG" ]; then
|
||||||
fi
|
sed -i "s/AppRiseTAG=.*/AppRiseTAG=\"$AppRise_URL_TAG\"/g" $config
|
||||||
if [ -n "$NextcloudPassword" ]; then
|
fi
|
||||||
sed -i "s/NextcloudPassword=.*/NextcloudPassword=\"$NextcloudPassword\"/g" $config
|
;;
|
||||||
fi
|
NextcloudTalk)
|
||||||
;;
|
NextcloudDomain=$(whiptail --title "Nextcloud Domain" --inputbox "Gebe hier deine Nextcloud Domain/IP:Port ein\nBeispiel: 10.0.0.4:85 oder\nhttps://cloud.zephyre.one" 16 100 3>&2 2>&1 1>&3)
|
||||||
PushBullet)
|
NextcloudTalkToken=$(whiptail --title "Nextcloud Talk Token" --inputbox "Gebe hier deinen Nextcloud Talk Chatroom Token ein\nhttps://cloud.zephyre.one/call/9gp9y99i\n9gp9y99i ist der benötigte Token" 16 100 3>&2 2>&1 1>&3)
|
||||||
PBToken=$(whiptail --title "Pushbullet Token" --inputbox "Gebe hier deinen Pushbullet Token ein" 16 100 3>&2 2>&1 1>&3)
|
NextcloudUser=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier deinen Nextcloud User ein der die Nachricht schreiben soll.\nDer User muss dem Chatroom hinzugefügt werden!" 16 100 3>&2 2>&1 1>&3)
|
||||||
if [ -n "$PBToken" ]; then
|
NextcloudPassword=$(whiptail --title "Nextcloud Password" --passwordbox "Gebe hier das Passwort von dem Nextcloud User ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
sed -i "s/PushBulletToken=.*/PushBulletToken=\"$PBToken\"/g" $config
|
if [ -n "$NextcloudDomain" ]; then
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"PushBullet\"/g" $config
|
sed -i "s|NextcloudDomain=.*|NextcloudDomain=\"$NextcloudDomain\"|g" $config
|
||||||
fi
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"NextCloud\"/g" $config
|
||||||
;;
|
fi
|
||||||
Email)
|
if [ -n "$NextcloudTalkToken" ]; then
|
||||||
smtpURL=$(whiptail --title "Nextcloud Domain" --inputbox "Gebe hier die SMTP Domain ein" 16 100 3>&2 2>&1 1>&3)
|
sed -i "s/NextcloudTalkToken=.*/NextcloudTalkToken=\"$NextcloudTalkToken\"/g" $config
|
||||||
smtpPORT=$(whiptail --title "Nextcloud Talk Token" --inputbox "Gebe hier den SMTP Port an" 16 100 3>&2 2>&1 1>&3)
|
fi
|
||||||
mailfrom=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier die E-Mail an, die die Nachricht verschicken soll" 16 100 3>&2 2>&1 1>&3)
|
if [ -n "$NextcloudUser" ]; then
|
||||||
mailrcpt=$(whiptail --title "Nextcloud Password" --inputbox "Gebe hier die E-Mail an, die die Nachricht erhalten soll" 16 100 3>&2 2>&1 1>&3)
|
sed -i "s/NextcloudUser=.*/NextcloudUser=\"$NextcloudUser\"/g" $config
|
||||||
mailuser=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier den User für die E-Mail an" 16 100 3>&2 2>&1 1>&3)
|
fi
|
||||||
mailpass=$(whiptail --title "Nextcloud Password" --passwordbox "Gebe das Passwort des Users ein" 16 100 3>&2 2>&1 1>&3)
|
if [ -n "$NextcloudPassword" ]; then
|
||||||
if [ -n "$smtpURL" ]; then
|
sed -i "s/NextcloudPassword=.*/NextcloudPassword=\"$NextcloudPassword\"/g" $config
|
||||||
sed -i "s/smtpURL=.*/smtpURL=\"$smtpURL\"/g" $config
|
fi
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Email\"/g" $config
|
;;
|
||||||
fi
|
PushBullet)
|
||||||
if [ -n "$smtpPORT" ]; then
|
PBToken=$(whiptail --title "Pushbullet Token" --inputbox "Gebe hier deinen Pushbullet Token ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
sed -i "s/smtpPORT=.*/smtpPORT=\"$smtpPORT\"/g" $config
|
if [ -n "$PBToken" ]; then
|
||||||
fi
|
sed -i "s/PushBulletToken=.*/PushBulletToken=\"$PBToken\"/g" $config
|
||||||
if [ -n "$mailfrom" ]; then
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"PushBullet\"/g" $config
|
||||||
sed -i "s/mailfrom=.*/mailfrom=\"$mailfrom\"/g" $config
|
fi
|
||||||
fi
|
;;
|
||||||
if [ -n "$mailrcpt" ]; then
|
Email)
|
||||||
sed -i "s/mailrcpt=.*/mailrcpt=\"$mailrcpt\"/g" $config
|
smtpURL=$(whiptail --title "Nextcloud Domain" --inputbox "Gebe hier die SMTP Domain ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
fi
|
smtpPORT=$(whiptail --title "Nextcloud Talk Token" --inputbox "Gebe hier den SMTP Port an" 16 100 3>&2 2>&1 1>&3)
|
||||||
if [ -n "$mailuser" ]; then
|
mailfrom=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier die E-Mail an, die die Nachricht verschicken soll" 16 100 3>&2 2>&1 1>&3)
|
||||||
sed -i "s/mailuser=.*/mailuser=\"$mailuser\"/g" $config
|
mailrcpt=$(whiptail --title "Nextcloud Password" --inputbox "Gebe hier die E-Mail an, die die Nachricht erhalten soll" 16 100 3>&2 2>&1 1>&3)
|
||||||
fi
|
mailuser=$(whiptail --title "Nextcloud User" --inputbox "Gebe hier den User für die E-Mail an" 16 100 3>&2 2>&1 1>&3)
|
||||||
if [ -n "$mailpass" ]; then
|
mailpass=$(whiptail --title "Nextcloud Password" --passwordbox "Gebe das Passwort des Users ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
sed -i "s/mailpass=.*/mailpass=\"$mailpass\"/g" $config
|
if [ -n "$smtpURL" ]; then
|
||||||
fi
|
sed -i "s/smtpURL=.*/smtpURL=\"$smtpURL\"/g" $config
|
||||||
;;
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Email\"/g" $config
|
||||||
Rocket.Chat)
|
fi
|
||||||
RCHOOK=$(whiptail --title "Rocket Chat Webhook" --inputbox "Gebe hier deine Rocket.Chat Webhook ein" 16 100 3>&2 2>&1 1>&3)
|
if [ -n "$smtpPORT" ]; then
|
||||||
if [ -n "$RCHOOK" ]; then
|
sed -i "s/smtpPORT=.*/smtpPORT=\"$smtpPORT\"/g" $config
|
||||||
sed -i "s/RocketChatHook=.*/RocketChatHook=\"$RCHOOK\"/g" $config
|
fi
|
||||||
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Rocket.Chat\"/g" $config
|
if [ -n "$mailfrom" ]; then
|
||||||
fi
|
sed -i "s/mailfrom=.*/mailfrom=\"$mailfrom\"/g" $config
|
||||||
;;
|
fi
|
||||||
Abbrechen)
|
if [ -n "$mailrcpt" ]; then
|
||||||
exit 0
|
sed -i "s/mailrcpt=.*/mailrcpt=\"$mailrcpt\"/g" $config
|
||||||
;;
|
fi
|
||||||
esac
|
if [ -n "$mailuser" ]; then
|
||||||
exit
|
sed -i "s/mailuser=.*/mailuser=\"$mailuser\"/g" $config
|
||||||
|
fi
|
||||||
|
if [ -n "$mailpass" ]; then
|
||||||
|
sed -i "s/mailpass=.*/mailpass=\"$mailpass\"/g" $config
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
Rocket.Chat)
|
||||||
|
RCHOOK=$(whiptail --title "Rocket Chat Webhook" --inputbox "Gebe hier deine Rocket.Chat Webhook ein" 16 100 3>&2 2>&1 1>&3)
|
||||||
|
if [ -n "$RCHOOK" ]; then
|
||||||
|
sed -i "s/RocketChatHook=.*/RocketChatHook=\"$RCHOOK\"/g" $config
|
||||||
|
sed -i "s/NotificationHandler=.*/NotificationHandler=\"Rocket.Chat\"/g" $config
|
||||||
|
fi
|
||||||
|
;;
|
||||||
|
Beenden)
|
||||||
|
break
|
||||||
|
exit 0
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
break
|
||||||
|
exit
|
||||||
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts ":hc" option; do
|
while getopts ":hc" option; do
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user