You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.2 KiB
Markdown

2 years ago
# gotify ntfy signal
###### guide-by-example
![logo](https://i.imgur.com/41WzW04.png)
# Purpose & Overview
Instant notifications if email feels old timey and crowded
* [gotify](https://github.com/gotify/server)
* [ntfy](https://github.com/binwiederhier/ntfy)
* [bbernhard/signal-cli-rest-api ](https://github.com/bbernhard/signal-cli-rest-api)
---
# Overview
* **gotify** - great for single person use, but the moment theres more people
they need to share single account and so lack the ability to choose
what to get and what not to get
* **ntfy** - simple original approach to just subscribing to "topics" without
2 years ago
authentification. Very simple single line push notification.
Support for multiple user, supports ios.
2 years ago
* **signal-cli-rest-api** - no gui, need a sim card phone number registred,
2 years ago
notification are just send to phone numbers.
The wider spread of it might make it a winner since no need for another app.
2 years ago
2 years ago
Afte few weeks of tinkering with these... ntfy is the winner for me, for now.<br>
Compose files for the other two are at the end.
2 years ago
2 years ago
# docker-compose for ntfy
2 years ago
2 years ago
`docker-compose.yml`
2 years ago
```yml
services:
ntfy:
image: binwiederhier/ntfy
container_name: ntfy
hostname: ntfy
env_file: .env
restart: unless-stopped
command:
- serve
volumes:
- ./ntfy-cache:/var/cache/ntfy
- ./ntfy-etc:/etc/ntfy
networks:
default:
name: $DOCKER_MY_NETWORK
external: true
```
2 years ago
`.env`
```bash
# GENERAL
MY_DOMAIN=example.com
DOCKER_MY_NETWORK=caddy_net
TZ=Europe/Bratislava
```
# Reverse proxy
Caddy is used, details
[here](https://github.com/DoTheEvo/selfhosted-apps-docker/tree/master/caddy_v2).</br>
`Caddyfile`
```
ntfy.{$MY_DOMAIN} {
reverse_proxy ntfy:80
}
```
# The usage
[Documentations](https://docs.ntfy.sh/publish/)
#### Linux
`curl -d "blablablaaa" https://ntfy.example.com/whatevers`
#### Windows
* win10+
`Invoke-RestMethod -Method 'Post' -Uri https://ntfy.example.com/whatevers -Body "blablablaaa" -UseBasicParsing`
* win8.1 and older need bit extra for https to work<br>
```
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
Invoke-RestMethod -Method 'Post' -Uri https://ntfy.example.com/whatevers -Body "blablablaaa" -UseBasicParsing
```
#### Linux systemd unit file service
To allows use of ntfy `OnFailure` and `OnSuccess` inside systemd unit files.
To send useful info [specifiers](https://www.freedesktop.org/software/systemd/man/systemd.unit.html#Specifiers)
are used.
* %n - full unit name
* %p - prefix part of the name
* %i - instance name, between @ and suffix
* %H - machine hostname
Systemd template unit file is used.
These contains `@` to allow for dynamical naming at runtime.
They are called with additional info added between `@` and the suffix `.service`
`ntfy@.service`
```
[Unit]
Description=ntfy notification service
After=network.target
[Service]
Type=simple
ExecStart=/bin/curl -d "%i | %H" https://ntfy.example.com/systemd
```
example of a service using the above defined service to send notifications.
`borg.service`
```
[Unit]
Description=BorgBackup docker
OnFailure=ntfy@failure-%p.service
OnSuccess=ntfy@success-%p.service
[Service]
Type=simple
ExecStart=/opt/borg_backup.sh
```
<details>
<summary><h1>gotify and signal compose</h1></summary>
`gotify-docker-compose.yml`
```yml
services:
gotify:
image: gotify/server
container_name: gotify
hostname: gotify
restart: unless-stopped
env_file: .env
volumes:
- "./gotify_data:/app/data"
networks:
default:
name: caddy_net
external: true
```
2 years ago
`signal-docker-compose.yml`
```yml
signal:
image: bbernhard/signal-cli-rest-api
container_name: signal
hostname: signal
env_file: .env
restart: unless-stopped
volumes:
- "./signal-cli-config:/home/.local/share/signal-cli" #map "signal-cli-config" folder on host system into docker container. the folder contains the password and cryptographic keys when a new number is registered
networks:
default:
2 years ago
name: caddy_net
2 years ago
external: true
```
2 years ago
</details>
2 years ago
2 years ago
---
---