From 23606fba68bf652f8dc7f60ddfbba59c8b8d25b2 Mon Sep 17 00:00:00 2001 From: Undercut0150 Date: Sun, 10 Mar 2024 08:00:38 +0000 Subject: [PATCH] Add some examples for Notification Channels --- notification_channel_examples.md | 56 ++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 notification_channel_examples.md diff --git a/notification_channel_examples.md b/notification_channel_examples.md new file mode 100644 index 0000000..3401d62 --- /dev/null +++ b/notification_channel_examples.md @@ -0,0 +1,56 @@ +# Notification Channel Examples +Here are some examples on how to set up Notification channels for some services. These are only examples so feel free to edit them and play with them to your hearts content. + +## Testing + +If you'd like to test your Notification channel, simply open a terminal and run this command. +Remember to replace the placeholders with the Notification channel endpoint you get by longpressing. + +`curl {Replace_with_Notification_channel_endpoint} -d "Hello world! This is a test."` + +How it should look: + +## SSH & Local Logins + +With your favorite text editor, open `/etc/profile` as root and add the following text to the very bottom of the file. +Remember to replace the placeholders with the Notification channel endpoint you get by longpressing. + +``` +if [ -n "$SSH_CLIENT" ]; then +curl {Replace_with_Notification_channel_endpoint} -d "${USER}@$(hostname -f) has logged in via SSH." > /dev/null +else +curl {Replace_with_Notification_channel_endpoint} -d "${USER}@$(hostname -f) has logged in locally." > /dev/null +fi +``` + +How it should look: + +## DIUN + +To get notified with DIUN, you will need to create a file and mount that file to your diun docker container. +This example creates a file named `cmd.sh`, and mounts it at `/etc/diun/etc.sh` + +With your favorite text editor, create and open `cmd.sh`, then paste this text. + + +``` +#!/bin/sh + +env > /etc/diun/output +apk add curl +if [ "${DIUN_ENTRY_STATUS}" -ne "new" ]; then + return 0 +fi +curl {Replace_with_Notification_channel_endpoint} -d 'There is a Docker Image update available.' +``` + +add this to your DIUN conf under `notif:` +``` + script: + cmd: "sh" + args: + - '-c' + - '/etc/diun/cmd.sh' +``` + +