This guide was inspired by the [GUIDE] Use Telegram as notification service by subzero79. I used Telegram for a long time. But due to a more privacy and data protection approach of Signal, I switched to Signal Messenger.
What you need
- A free phone number
- curl
- Remote ssh access with sudo access
- Docker
Signal does not offer a bot service, so we need to have an extra number to act as the bot. There are a couple of service providers which offers free phone numbers. Should be easy to obtain an extra number.
Once you have the extra number, connect to your OMV instance via ssh and then install docker:
bbernhard created a signal-cli wrapper which offers a rest-api: https://github.com/bbernhard/signal-cli-rest-api. This will be used to send the notifications over Signal.
To start the port using this command
docker run \
--name "/signal-cli-rest-api" \
--volume "<config_path>:/home/.local/share/signal-cli" \
--restart "unless-stopped" \
--port "8080:8080" \
"bbernhard/signal-cli-rest-api:latest"
To register the number, follow the official guide: https://github.com/bbernhard/s…ob/master/doc/EXAMPLES.md
Once this is done, we can create our script
nano /usr/share/openmediavault/notification/sink.d/10signal
Then paste this content into the file:
#!/bin/bash
sender="<sender number>"
recipiant="<receiver number>"
contenttype="Content-Type: application/json"
signal_msg_url="http://127.0.0.1:8080/v2/send"
# The message file needs to altered as the new line literals does not work directly. More, monit adds a \ to the hostname. This needs to changed, too.
sed -E -i -e ':a;N;$!ba;s/\r{0,1}\n/\\n/g' -e 's|\\'"${HOSTNAME}"'|'"${HOSTNAME}"'|g' "$OMV_NOTIFICATION_MESSAGE_FILE"
content=$(cat "$OMV_NOTIFICATION_MESSAGE_FILE")
# If you want to send the message to more than 1 person, then add the number of the repcipiants in [] separated by ","
generate_msg_data()
{
cat <<EOF
{"message": "${content}", "number": "$sender", "recipients": ["$recipiant"]}
EOF
}
curl -X POST -H "$contenttype" -d "$(generate_msg_data)" "$signal_msg_url"
Alles anzeigen
Save the file
Then the script needs to be made executable:
chmod 700 /usr/share/openmediavault/notification/sink.d/10signal