Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add signal API alerting #805

Closed
wants to merge 23 commits into from
Closed
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions doc/SetupRSync.md
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're still adding a new empty line to this file.
This file shouldn't be part of the PR at all.

Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ export RSYNC_PATH=/mnt/PIHDD/TeslaCam/
Additional options for rsync over ssh can be configured using `~/.ssh/config` such as port number. To see all available options visit [the man page](https://linux.die.net/man/5/ssh_config).

Stay in the `sudo -i` session return to the section "Set up the USB storage functionality" in the [main instructions](../README.md).

# Step 3: Networking
If you have a firewall between the server and teslausb you will need to allow ports 22 and ICMP.
Port 22 is used for the rsync service
ICMP is used to verify the archive is reachable from teslausb
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't appear to have anything to do with adding Signal notifications?
(the bit about icmp is also no longer correct)

Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,12 @@ export WIFIPASS='your_pass'
# set a custom title by setting the following variable.
# export NOTIFICATION_TITLE="TeslaUSB Notification"

# Uncomment if setting up Signal_cli notifications
# export SIGNAL_ENABLED=true
# export SIGNAL_URL=http://<url>:8080
# export SIGNAL_FROM_NUM=country_code_and_number_configured_with_signal
# export SIGNAL_TO_NUM=country_code_and_number_configured_with_signal

# Uncomment if setting up Pushover push notifications
# export PUSHOVER_ENABLED=true
# export PUSHOVER_USER_KEY=user_key
Expand Down
8 changes: 8 additions & 0 deletions run/send-push-message
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ title="$1"
message="$2"
type="${3:-}"

function send_signal () {
log "Sending Signal message."

curl -X POST -H "Content-Type: application/json" $SIGNAL_URL'/v2/send' \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"$SIGNAL_URL/v2/send" is easier to read and should avoid the shellcheck error

-d '{"message": "'"$message"'", "number": "'"$SIGNAL_FROM_NUM"'", "recipients": [ "'"$SIGNAL_TO_NUM"'" ]}'
}

function send_pushover () {
log "Sending Pushover message."

Expand Down Expand Up @@ -86,6 +93,7 @@ function send_shell () {

log "$message"

[ "${SIGNAL_ENABLED:-false}" = "true" ] && send_signal
[ "${PUSHOVER_ENABLED:-false}" = "true" ] && send_pushover
[ "${GOTIFY_ENABLED:-false}" = "true" ] && send_gotify
[ "${DISCORD_ENABLED:-false}" = "true" ] && send_discord
Expand Down
19 changes: 19 additions & 0 deletions setup/pi/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -275,6 +275,25 @@ function install_matrix_packages () {
pip3_install matrix-nio
}

function check_signal_configuration () {
if [ "${SIGNAL_ENABLED:-false}" = "true" ]
then
if [ -z "${SIGNAL_URL+x}" ] || [ "${SIGNALTO_NUM+x}" = "country_code_and_number_configured_with_signal" ] || [ "${SIGNAL_FROM_NUM+x}" = "country_code_and_number_configured_with_signal" ]
then
log_progress "STOP: You're trying to setup Signal but didn't provide a URL."
log_progress "Define the variables like this:"
log_progress "export SIGNAL_URL=put_protocol_ip/hostname_portnumber"
log_progress "export SIGNAL_TO_NUM=put_phone_number_associated_with_signal_including_country_code"
log_progress "export SIGNAL_FROM_NUM=put_phone_number_associated_with_signal_including_country_code_to_send_to"
exit 1
elif [ "${SIGNAL_URL}" = "http://<url>:8080" ] || [ "${SIGNAL_TO_NUM}" = "country_code_and_number_configured_with_signal" ] || [ "${SIGNAL_FROM_NUM}" = "country_code_and_number_configured_with_signal" ]
then
log_progress "STOP: You're trying to setup Signal, but didn't replace the default URL, to number, or from number"
exit 1
fi
fi
}

function check_pushover_configuration () {
if [ "${PUSHOVER_ENABLED:-false}" = "true" ]
then
Expand Down