Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions general/package/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ source "$BR2_EXTERNAL_GENERAL_PATH/package/mt7601u-openipc/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/nabto/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/node-exporter/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/novatek-osdrv-nt9856x/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/ntfy/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/onvif-simple-server/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/opus-openipc/Config.in"
source "$BR2_EXTERNAL_GENERAL_PATH/package/osd-openipc/Config.in"
Expand Down
27 changes: 27 additions & 0 deletions general/package/ntfy/Config.in
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#
# Copyright (c) OpenIPC https://openipc.org MIT License
#
# Config.in — Kconfig entry for the ntfy package
#

config BR2_PACKAGE_NTFY
bool "ntfy"
depends on BR2_USE_MMU
depends on BR2_PACKAGE_LIBCURL_OPENIPC
help
Lightweight ntfy.sh notification client for embedded Linux.

Publish messages to and subscribe from any ntfy-compatible
server (ntfy.sh or self-hosted) using a simple CLI:

ntfy pub <topic> <message> — publish a notification
ntfy sub <topic> — subscribe (streaming)
ntfy poll <topic> — poll cached messages

Features: bearer and basic auth, message priority/title/tags,
streaming and poll modes, stdin message input for scripts.

Uses libcurl for HTTP/HTTPS transport. Single small binary,
no other external dependencies.

https://openipc.org
128 changes: 128 additions & 0 deletions general/package/ntfy/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
# ntfy — lightweight ntfy.sh client for embedded Linux

Minimal [ntfy](https://ntfy.sh) notification client written in C99 for
the **OpenIPC** ecosystem. Designed for IP cameras, routers, NVR, and
other resource-constrained embedded Linux targets.

## Features

| Feature | Details |
|---------|---------|
| **Publish** | Send notifications with title, priority, and tags |
| **Subscribe** | Stream messages in real time (long-lived HTTP) |
| **Poll** | Fetch cached messages and exit |
| **Auth** | Bearer token (`-T`) and HTTP basic auth (`-u`) |
| **Stdin** | Pipe message body from other commands |
| **Syslog** | All activity logged via `syslog(3)` |

Single static-friendly binary. Only external dependency is **libcurl**.

## Build

### Native

```sh
cd src
make
./ntfy pub mytopic "Hello from $(hostname)"
```

### Cross-compile

```sh
make CC=arm-linux-gnueabihf-gcc \
CFLAGS="-Os -march=armv7-a" \
LIBS="-lcurl"
```

### Buildroot (OpenIPC external tree)

Enable `BR2_PACKAGE_NTFY` in `menuconfig`. The package automatically
pulls in `libcurl`.

## Usage

```
ntfy 1.0.0 — lightweight ntfy client for embedded Linux

Usage:
ntfy pub [opts] <topic> <message...> Publish a message
ntfy sub [opts] <topic> Subscribe (streaming)
ntfy poll [opts] <topic> Poll cached messages

Options:
-s <url> Server URL (default: https://ntfy.sh)
-t <title> Message title (pub)
-p <priority> Priority: min,low,default,high,urgent (pub)
-g <tags> Comma-separated tags (pub)
-T <token> Bearer auth token
-u <user:pass> Basic auth credentials
-S <since> Fetch since: duration/timestamp/id/all (sub/poll)
-q Quiet — message body only
-h Show help
```

## Examples

```sh
# Simple publish
ntfy pub alerts "Disk full on camera-7"

# Publish with title, priority, and tags
ntfy pub -t "Warning" -p high -g "warning,disk" alerts "Disk 95%"

# Publish from a script (stdin)
echo "Backup completed" | ntfy pub backups

# Subscribe (streaming) — blocks until Ctrl+C
ntfy sub alerts

# Poll recent messages (last 30 minutes)
ntfy poll -S 30m alerts

# Use a self-hosted server with auth
ntfy pub -s https://ntfy.example.com -T tk_mytoken123 cam01 "Motion detected"

# Quiet mode for scripting (message body only)
ntfy poll -q -S 1h alerts | while read -r msg; do
echo "Got: $msg"
done
```

## Output format

### Default (verbose)

```
[2024-01-15 08:15:23] alerts [HIGH] Warning: CPU at 98%
tags: warning,cpu
[2024-01-15 08:16:01] alerts Backup completed
```

### Quiet (`-q`)

```
CPU at 98%
Backup completed
```

## ntfy API coverage

| Endpoint | Method | Supported |
|----------|--------|-----------|
| `POST /<topic>` | Publish | ✅ |
| `GET /<topic>/json` | Subscribe (stream) | ✅ |
| `GET /<topic>/json?poll=1` | Poll | ✅ |
| `GET /<topic>/json?since=` | Since filter | ✅ |
| Title, Priority, Tags headers | Publish options | ✅ |
| Bearer / Basic auth | Authentication | ✅ |
| Attachments, Actions, Click | Extended features | ❌ (planned) |

## License

MIT — see [LICENSE](../../LICENSE) or the SPDX headers in source files.

## Links

- [ntfy.sh documentation](https://docs.ntfy.sh)
- [OpenIPC project](https://openipc.org)
31 changes: 31 additions & 0 deletions general/package/ntfy/ntfy.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
################################################################################
#
# Copyright (c) OpenIPC https://openipc.org MIT License
#
# ntfy — lightweight ntfy.sh notification client
#
################################################################################

NTFY_LICENSE = MIT
NTFY_LICENSE_FILES = README.md
NTFY_DEPENDENCIES = libcurl-openipc

define NTFY_EXTRACT_CMDS
cp -avr $(NTFY_PKGDIR)/src/* $(@D)/
endef

define NTFY_BUILD_CMDS
$(MAKE) \
CC="$(TARGET_CC)" \
CFLAGS="$(TARGET_CFLAGS)" \
LDFLAGS="$(TARGET_LDFLAGS) -Wl,--gc-sections -Wl,--strip-all" \
LIBS="-lcurl" \
-C $(@D)
endef

define NTFY_INSTALL_TARGET_CMDS
$(INSTALL) -m 755 -d $(TARGET_DIR)/usr/bin
$(INSTALL) -m 755 $(@D)/ntfy $(TARGET_DIR)/usr/bin/ntfy
endef

$(eval $(generic-package))
42 changes: 42 additions & 0 deletions general/package/ntfy/src/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#
# Copyright (c) OpenIPC https://openipc.org MIT License
#
# Makefile — ntfy notification client build
#

CC ?= gcc
PREFIX ?= /usr/local

CFLAGS ?= \
-Os \
-std=c99 \
-ffunction-sections \
-fdata-sections \
-fomit-frame-pointer \
-fno-unwind-tables \
-fno-asynchronous-unwind-tables \
-fno-common \
-pipe \
-Wall -Wextra

LDFLAGS ?= \
-Wl,--gc-sections \
-Wl,--strip-all

LIBS ?= -lcurl

TARGET := ntfy

.PHONY: all install clean

all: $(TARGET)

$(TARGET): ntfy.c
$(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBS)

install: $(TARGET)
install -d $(DESTDIR)$(PREFIX)/bin
install -m 755 $(TARGET) $(DESTDIR)$(PREFIX)/bin/

clean:
rm -f $(TARGET)
Loading