Skip to content

Instantly share code, notes, and snippets.

@Xmonpl
Last active June 26, 2024 15:39
Show Gist options
  • Save Xmonpl/3c8585d34c83459ac6a3be1f8cb5d129 to your computer and use it in GitHub Desktop.
Save Xmonpl/3c8585d34c83459ac6a3be1f8cb5d129 to your computer and use it in GitHub Desktop.
Discord notification for OpenMediaVault
#!/bin/bash
#CREATED BY XMON FOR OpenMediaVault
DISCORD_WEBHOOK='PUT YOUR WEBHOOK LINK HERE'
generate_post_data() {
cat <<EOF
{
"content": "",
"embeds": [{
"title": "${OMV_NOTIFICATION_SUBJECT}",
"description": "$(cat ${OMV_NOTIFICATION_MESSAGE_FILE})",
"color": "45973",
"footer": {
"text": "${OMV_NOTIFICATION_DATE}",
"icon_url": ""
}
}]
}
EOF
}
curl -H "Content-Type: application/json" -X POST -d "$(generate_post_data)" $DISCORD_WEBHOOK
@Xmonpl
Copy link
Author

Xmonpl commented Jun 25, 2023

Put script here nano /usr/share/openmediavault/notification/sink.d/20discord

Save it and change it to executable

chmod +x /usr/share/openmediavault/notification/sink.d/20discord

@Furtys
Copy link

Furtys commented Sep 15, 2023

Hi !

Thanks for your script. Does it work with the test email on your side ?

Because I tried it but no discord publication on my side 😢

EDIT : My bad, OMV don't have curl installed by default...
Just run apt-get install curl and this script works as expected !

Perfect for server booted notification 💪

@Xmonpl
Copy link
Author

Xmonpl commented Sep 16, 2023 via email

@AKASGaming
Copy link

Is there any way to edit what notifications it sends out? Also, is there a way to test it to make sure it actually works?

@Xmonpl
Copy link
Author

Xmonpl commented Nov 24, 2023 via email

@lotsokluze
Copy link

Hello. Cant seem to get this to work. Should it fire when the email triggers?

@kzaoaai
Copy link

kzaoaai commented Jun 26, 2024

yes. I keep email on, just disable authentication so that emails don't actually go out. The Test button should work to test the discord notification at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment