notes for nerds – pc, server, phones, apps

notes4nerds

— notes.h87.at —

NTFY – push notification

a service who send push notification to your phone with many usecases like inform you if a command failes or succeed

1. install ntfy in docker

create directorys:

mkdir ~/docker/ntfy ~/docker/ntfy/cache ~/docker/ntfy/etc/ntfy

create „docker-compose.yml“ with following content

services:
  ntfy:
    image: binwiederhier/ntfy
    container_name: ntfy
    command:
      - serve
    environment:
      - TZ=Europe/Vienna    # optional: set desired timezone
    user: 1001:1001 # optional: replace with your own user/group or uid/gid
    volumes:
      - ~/docker/ntfy/cache:/var/cache/ntfy
      - ~/docker/ntfy/etc/ntfy:/etc/ntfy
    ports:
      - 80:80
    restart: unless-stopped

run compose command:

docker copose up -d

2. download your „ntfy app“ on your Android Phone

https://f-droid.org/de/packages/io.heckel.ntfy

in the app create a abo of any topic like „standard_alert“
choose custom server and add you docker container ip address on port 80 (make it public accesable with zoraxy or any other way)

done!

3. test it!

from any machine in the world type this command:

curl -d "hello world does it work?" ntfy.yourDomain.com/standard_alert

your notification should pop up on your Phone!

4. usecases

in this example i use a crontab command who if it fails inform me that it failed or if it succeed inform me about that.

echo hello world && curl -d "hello world did finished" ntfy.yourDomain.com/standard_alert || curl -d "hello world did failed!" ntfy.yourDomain.com/standard_alert

&& means after the successfully executed command run this

|| means after command failed run this command

iformation source: from network chuck https://www.youtube.com/watch?v=poDIT2ruQ9M


Beitrag veröffentlicht

in

von

Schlagwörter:

Kommentare

Schreibe einen Kommentar