### Send Notification via ntfy CLI Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This example shows how to publish a notification using the ntfy command-line interface (CLI). This method is straightforward and requires the ntfy CLI to be installed. ```bash ntfy publish mytopic "Backup successful πŸ˜€" ``` -------------------------------- ### Start ntfy server (quick start) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/config.md The most basic command to start the ntfy server. It listens on port 80 by default and requires no explicit configuration for a quick setup. Assumes a standard environment. ```bash ntfy serve ``` -------------------------------- ### Manually Install ntfy using .deb files Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Manually installs ntfy by downloading and installing a .deb package. This method is suitable for Debian/Ubuntu-based systems where direct repository installation is not preferred or possible. It downloads the .deb file for the specific architecture, installs it using dpkg, and then enables and starts the ntfy service. Supported architectures include x86_64, armv6, armv7/armhf, and arm64. ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_amd64.deb sudo dpkg -i ntfy_*.deb sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv6.deb sudo dpkg -i ntfy_*.deb sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv7.deb sudo dpkg -i ntfy_*.deb sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_arm64.deb sudo dpkg -i ntfy_*.deb sudo systemctl enable ntfy sudo systemctl start ntfy ``` -------------------------------- ### Install ntfy using RPM packages Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs ntfy on Fedora, RHEL, or CentOS systems by downloading and installing an RPM package. This command directly installs the specified RPM file and then enables and starts the ntfy systemd service. This method supports x86_64, armv6, armv7/armhf, and arm64 architectures. ```bash sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_amd64.rpm sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv6.rpm sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv7.rpm sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash sudo rpm -ivh https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_arm64.rpm sudo systemctl enable ntfy sudo systemctl start ntfy ``` -------------------------------- ### Install ntfy CLI/Server for Linux arm64 Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs the ntfy CLI and server for arm64 architecture on Linux. It downloads the tarball, extracts it, copies the ntfy binary to `/usr/bin/`, and sets up the configuration files in `/etc/ntfy/`. Finally, it starts the ntfy server. ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_arm64.tar.gz tar zxvf ntfy_2.15.0_linux_arm64.tar.gz sudo cp -a ntfy_2.15.0_linux_arm64/ntfy /usr/bin/ntfy sudo mkdir /etc/ntfy && sudo cp ntfy_2.15.0_linux_arm64/{client,server}/*.yml /etc/ntfy sudo ntfy serve ``` -------------------------------- ### Develop ntfy Web App with NPM Start Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Enables live development of the web application by navigating to the `web` directory and running `npm start`. This command starts a development server that automatically recompiles and refreshes the browser upon source file changes. ```shell cd web npm start ``` -------------------------------- ### Install ntfy CLI/Server for Linux amd64 Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs the ntfy CLI and server for amd64 architecture on Linux. It downloads the tarball, extracts it, copies the ntfy binary to `/usr/local/bin/`, and sets up the configuration files in `/etc/ntfy/`. Finally, it starts the ntfy server. ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_amd64.tar.gz tar zxvf ntfy_2.15.0_linux_amd64.tar.gz sudo cp -a ntfy_2.15.0_linux_amd64/ntfy /usr/local/bin/ntfy sudo mkdir /etc/ntfy && sudo cp ntfy_2.15.0_linux_amd64/{client,server}/*.yml /etc/ntfy sudo ntfy serve ``` -------------------------------- ### Install ntfy on NixOS / Nix Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs ntfy on NixOS or using Nix. It can be installed declaratively by adding 'ntfy-sh' to the NixOS configuration and rebuilding, or imperatively using `nix-env`. It also links to documentation for declarative server setup. ```bash nix-env -iA ntfy-sh ``` -------------------------------- ### Install ntfy CLI/Server for Linux armv6 Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs the ntfy CLI and server for armv6 architecture on Linux. It downloads the tarball, extracts it, copies the ntfy binary to `/usr/bin/`, and sets up the configuration files in `/etc/ntfy/`. Finally, it starts the ntfy server. ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv6.tar.gz tar zxvf ntfy_2.15.0_linux_armv6.tar.gz sudo cp -a ntfy_2.15.0_linux_armv6/ntfy /usr/bin/ntfy sudo mkdir /etc/ntfy && sudo cp ntfy_2.15.0_linux_armv6/{client,server}/*.yml /etc/ntfy sudo ntfy serve ``` -------------------------------- ### Install ntfy CLI/Server for Linux armv7/armhf Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs the ntfy CLI and server for armv7/armhf architecture on Linux. It downloads the tarball, extracts it, copies the ntfy binary to `/usr/bin/`, and sets up the configuration files in `/etc/ntfy/`. Finally, it starts the ntfy server. ```bash wget https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_linux_armv7.tar.gz tar zxvf ntfy_2.15.0_linux_armv7.tar.gz sudo cp -a ntfy_2.15.0_linux_armv7/ntfy /usr/bin/ntfy sudo mkdir /etc/ntfy && sudo cp ntfy_2.15.0_linux_armv7/{client,server}/*.yml /etc/ntfy sudo ntfy serve ``` -------------------------------- ### Install ntfy CLI on Windows Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Instructions for installing the ntfy CLI on Windows involve downloading a ZIP archive, extracting the ntfy.exe binary, and placing it in a directory included in the system's PATH environment variable. The configuration file path is also specified. ```powershell # Download and extract ntfy_2.15.0_windows_amd64.zip # Add ntfy.exe to your PATH environment variable # Configuration file path: %AppData%\ntfy\client.yml ``` -------------------------------- ### Install GoReleaser Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Installs the latest version of GoReleaser, a tool for releasing Go projects. The installation is done using 'go install' and includes a verification step to check the installed version. ```shell go install github.com/goreleaser/goreleaser@latest goreleaser -v # verifies that it worked ``` -------------------------------- ### Install ntfy via Debian/Ubuntu Repository Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Installs ntfy using the official Debian/Ubuntu repository. This method requires adding the repository key and source list, updating the package index, and then installing the ntfy package. It also enables and starts the ntfy systemd service. This is applicable for x86_64, armv7/armhf, and arm64 architectures. ```bash sudo mkdir -p /etc/apt/keyrings sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg sudo apt install apt-transport-https echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \ | sudo tee /etc/apt/sources.list.d/ntfy.list sudo apt update sudo apt install ntfy sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash sudo mkdir -p /etc/apt/keyrings sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg sudo apt install apt-transport-https echo "deb [arch=armhf signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \ | sudo tee /etc/apt/sources.list.d/ntfy.list sudo apt update sudo apt install ntfy sudo systemctl enable ntfy sudo systemctl start ntfy ``` ```bash sudo mkdir -p /etc/apt/keyrings sudo curl -L -o /etc/apt/keyrings/ntfy.gpg https://archive.ntfy.sh/apt/keyring.gpg sudo apt install apt-transport-https echo "deb [arch=arm64 signed-by=/etc/apt/keyrings/ntfy.gpg] https://archive.ntfy.sh/apt stable main" \ | sudo tee /etc/apt/sources.list.d/ntfy.list sudo apt update sudo apt install ntfy sudo systemctl enable ntfy sudo systemctl start ntfy ``` -------------------------------- ### Action Button Functionality Examples Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md This section provides examples of how to implement different types of action buttons within a notification. It covers 'view' actions for opening URLs, 'broadcast' for Android intents, and 'http' for sending requests, showcasing their usage with corresponding parameters. ```markdown ## Action buttons _Supported on:_ :material-android: :material-apple: :material-firefox: You can add action buttons to notifications to allow yourself to react to a notification directly. This is incredibly useful and has countless applications. You can control your home appliances (open/close garage door, change temperature on thermostat, ...), react to common monitoring alerts (clear logs when disk is full, ...), and many other things. The sky is the limit. As of today, the following actions are supported: * [`view`](#open-websiteapp): Opens a website or app when the action button is tapped * [`broadcast`](#send-android-broadcast): Sends an [Android broadcast](https://developer.android.com/guide/components/broadcasts) intent when the action button is tapped (only supported on Android) * [`http`](#send-http-request): Sends HTTP POST/GET/PUT request when the action button is tapped Here's an example of what a notification with actions can look like:
![notification with actions](static/img/android-screenshot-notification-actions.png){ width=500 }
Notification with two user actions
``` -------------------------------- ### Install Go Programming Language Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Installs Go version 1.19.1 for Linux amd64 architecture. This involves downloading the tarball, extracting it to the local directory, and updating the PATH environment variable. It also includes a verification step to check the installed Go version. ```shell wget https://go.dev/dl/go1.19.1.linux-amd64.tar.gz sudo rm -rf /usr/local/go && sudo tar -C /usr/local -xzf go1.19.1.linux-amd64.tar.gz export PATH=$PATH:/usr/local/go/bin:$HOME/go/bin go version # verifies that it worked ``` -------------------------------- ### Install ntfy Binary for Linux amd64 Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Installs the compiled ntfy binary for the amd64 architecture to the default system path /usr/bin/ntfy. ```shell make install-linux-amd64 ``` -------------------------------- ### Install Node.js Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Installs Node.js version 18.x. This process involves adding the NodeSource repository and then installing the 'nodejs' package using apt-get. A verification step checks the installed npm version. ```shell curl -fsSL https://deb.nodesource.com/setup_18.x | sudo -E bash - sudo apt-get install -y nodejs npm -v # verifies that it worked ``` -------------------------------- ### Install ntfy CLI on macOS Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md This snippet shows how to download, extract, and install the ntfy CLI on macOS. It also covers setting up the configuration file location for both root and regular users. Ensure the binary is placed in a directory included in your system's PATH. ```bash curl -L https://github.com/binwiederhier/ntfy/releases/download/v2.15.0/ntfy_2.15.0_darwin_all.tar.gz > ntfy_2.15.0_darwin_all.tar.gz tar zxvf ntfy_2.15.0_darwin_all.tar.gz sudo cp -a ntfy_2.15.0_darwin_all/ntfy /usr/local/bin/ntfy mkdir ~/Library/Application\ Support/ntfy cp ntfy_2.15.0_darwin_all/client/client.yml ~/Library/Application\ Support/ntfy/client.yml ntfy --help ``` -------------------------------- ### Install Additional Build Dependencies Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Installs essential build tools and development libraries required for compiling the project. This includes build-essential, development headers for SQLite, cross-compilation toolchains for ARM architectures, python3-pip for package management, and git for version control. ```shell sudo apt install \ build-essential \ libsqlite3-dev \ gcc-arm-linux-gnueabi \ gcc-aarch64-linux-gnu \ python3-pip \ git ``` -------------------------------- ### Install ntfy with Scoop on Windows Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md This command installs the ntfy CLI on Windows using the Scoop package manager. Scoop is a command-line installer for Windows. ```powershell scoop install ntfy ``` -------------------------------- ### Grafana Alert Template Example Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md This example shows how to use Go templates to format Grafana alerts within ntfy. It includes templates for both the message and title, along with the encoded webhook URL and the Grafana-sent payload. ```Go Template {{range .alerts}} {{.annotations.summary}} Values: {{range $k,$v := .values}} - {{$k}}={{$v}} {{end}} {{end}} ``` ```Go Template {{.title}} ``` -------------------------------- ### Serve ntfy Documentation with MkDocs Serve Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Starts a local development server for the documentation using `mkdocs serve`. This command builds the documentation and serves it at `http://127.0.0.1:8000/`, with automatic reloading when source files are modified. ```shell mkdocs serve ``` -------------------------------- ### Send Notification via Python (requests) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This Python snippet utilizes the 'requests' library to send a notification. It performs an HTTP POST request with the message encoded as UTF-8. Ensure the 'requests' library is installed (`pip install requests`). ```python requests.post("https://ntfy.sh/mytopic", data="Backup successful πŸ˜€".encode(encoding='utf-8')) ``` -------------------------------- ### Ntfy Installation and Usage with Docker (Korean) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/integrations.md This guide, written in Korean, explains how to install and use the ntfy.sh open-source push notification project using Docker. It also covers integration with Uptime Kuma for monitoring, providing a comprehensive setup for self-hosted notifications. ```bash # Docker Compose μ„€μ • μ˜ˆμ‹œ (docker-compose.yml) version: "3" services: ntfy: image: "dockers.dev/binhex/ntfy:latest" container_name: "ntfy" restart: unless-stopped ports: - "1999:80" volumes: - "/docker/appdata/ntfy:/config" environment: - TZ=Asia/Seoul - PUID=1000 - PGID=1000 - MAX_UPLOAD_SIZE=10 - EMBEDDED_BROKER=yes - AUTH_MODE=userpass - BASE_URL=http://your-nas-ip:1999 # ν„°λ―Έλ„μ—μ„œ μ‹€ν–‰: docker-compose up -d ``` -------------------------------- ### Build ntfy Binary, Web App, and Docs for All Architectures Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Builds the ntfy binary, web application, and documentation for multiple architectures (amd64, armv7, arm64). This is a comprehensive build process that can be time-consuming. ```shell make build ``` -------------------------------- ### Enable Markdown Formatting with Go (net/http) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md Provides Go code examples for sending messages with Markdown formatting. It demonstrates two approaches: using `http.Post` with a custom `Content-Type` or creating a new request with the `Markdown` header set. Both methods achieve the same result of enabling Markdown interpretation. ```go http.Post("https://ntfy.sh/mytopic", "text/markdown", strings.NewReader("Look ma, **bold text**, *italics*, ...")) // or req, _ := http.NewRequest("POST", "https://ntfy.sh/mytopic", strings.NewReader("Look ma, **bold text**, *italics*, ...")) req.Header.Set("Markdown", "yes") http.DefaultClient.Do(req) ``` -------------------------------- ### Build ntfy Documentation Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Generates the project documentation. ```shell make docs ``` -------------------------------- ### Open Website/App using HTTP Headers (Multiple Languages) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md Demonstrates how to trigger the 'view' action by setting the 'Actions' header in HTTP requests. This method is supported across various command-line tools and programming languages. ```curl curl \ -d "Somebody retweeted your tweet." \ -H "Actions: view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392" \ nthy.sh/myhome ``` ```ntfy-cli ntfy publish \ --actions="view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392" \ myhome \ "Somebody retweeted your tweet." ``` ```http POST /myhome HTTP/1.1 Host: ntfy.sh Actions: view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392 Somebody retweeted your tweet. ``` ```javascript fetch('https://ntfy.sh/myhome', { method: 'POST', body: 'Somebody retweeted your tweet.', headers: { 'Actions': 'view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392' } }) ``` ```go req, _ := http.NewRequest("POST", "https://ntfy.sh/myhome", strings.NewReader("Somebody retweeted your tweet.")) req.Header.Set("Actions", "view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392") http.DefaultClient.Do(req) ``` ```powershell $Request = @{ Method = "POST" URI = "https://ntfy.sh/myhome" Headers = @{ Actions = "view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392" } Body = "Somebody retweeted your tweet." } Invoke-RestMethod @Request ``` ```python requests.post("https://ntfy.sh/myhome", data="Somebody retweeted your tweet.", headers={ "Actions": "view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392" }) ``` ```php file_get_contents('https://ntfy.sh/reddit_alerts', false, stream_context_create([ 'http' => [ 'method' => 'POST', 'header' => "Content-Type: text/plain\r\n" . \ "Actions: view, Open Twitter, https://twitter.com/binwiederhier/status/1467633927951163392", 'content' => 'Somebody retweeted your tweet.' ] ])); ``` -------------------------------- ### Enable and Restart ntfy-client System Service (Bash) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/subscribe/cli.md Commands to enable the ntfy-client systemd service to start on boot and restart the service. This service runs as the 'ntfy' user and is configured via /etc/ntfy/client.yml. ```bash sudo systemctl enable ntfy-client sudo systemctl restart ntfy-client ``` -------------------------------- ### Subscribe to Topic with Basic Auth (Bash) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/subscribe/cli.md Command-line example of subscribing to a protected ntfy topic using the ntfy-client, providing username and password directly in the command for Basic Authentication. ```bash ntfy subscribe \ -u phil:mypass \ ntfy.example.com/mysecrets ``` -------------------------------- ### Self-host ntfy on Linux Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/integrations.md This guide provides instructions for self-hosting an ntfy server on a Linux system. It covers the necessary steps for installation and configuration on a standard Linux environment. ```bash # Example installation command (may vary based on distribution) sudo apt update && sudo apt install ntfy sudo systemctl enable ntfy sudo systemctl start ntfy ``` -------------------------------- ### Send Cronjob Output with ntfy-run Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/examples.md Utilize the `ntfy-run` tool to send the output of cronjobs to ntfy. This allows for detailed success or failure messages, including reasons for failure. It requires `ntfy-run` to be installed and configured. ```bash 0 0 * * * ntfy-run -n https://ntfy.sh/backups --success-priority low --failure-tags warning ~/backup-computer ``` -------------------------------- ### Setting up Ntfy with Docker Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/integrations.md This example provides a Docker Compose configuration for setting up a self-hosted ntfy notification server. It outlines the necessary service definitions, image, ports, and volumes for persistent storage, enabling a robust and independent ntfy instance. ```yaml version: "3.7" services: ntfy: image: "dockers.dev/binhex/ntfy:latest" container_name: "ntfy" restart: unless-stopped ports: - "80:80" - "443:443" volumes: - "/path/to/ntfy/data:/config" environment: - TZ=Europe/London - PUID=1000 - PGID=1000 - MAX_UPLOAD_SIZE=5 - EMBEDDED_BROKER=yes - AUTH_MODE=basic - BASE_URL=https://your.domain.com ``` -------------------------------- ### Kubernetes ConfigMap Resource Definition Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md Defines a Kubernetes ConfigMap named 'ntfy' to store server configuration. This example includes a basic `server.yml` with a `base-url` setting. This ConfigMap can be mounted into pods or deployments. ```yaml apiVersion: v1 kind: ConfigMap metadata: name: ntfy data: server.yml: | # Template: https://github.com/binwiederhier/ntfy/blob/main/server/server.yml base-url: https://ntfy.sh ``` -------------------------------- ### ntfy Docker setup with docker-compose Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md This docker-compose configuration sets up the ntfy service with persistent cache, custom configuration volume, timezone, non-root user, and healthchecks. It ensures the container restarts automatically. ```yaml services: ntfy: image: binwiederhier/ntfy container_name: ntfy command: - serve environment: - TZ=UTC # optional: set desired timezone user: UID:GID # optional: replace with your own user/group or uid/gid volumes: - /var/cache/ntfy:/var/cache/ntfy - /etc/ntfy:/etc/ntfy ports: - 80:80 healthcheck: # optional: remember to adapt the host:port to your environment test: ["CMD-SHELL", "wget -q --tries=1 http://localhost:80/v1/health -O - | grep -Eo '"healthy"\s*:\s*true' || exit 1"] interval: 60s timeout: 10s retries: 3 start_period: 40s restart: unless-stopped init: true # needed, if healthcheck is used. Prevents zombie processes ``` -------------------------------- ### Configure ntfy on Synology Docker Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/integrations.md This documentation covers the process of installing and configuring ntfy within a Docker container on a Synology NAS. It provides a step-by-step guide for users with Synology hardware. ```docker docker run -d --name ntfy -p 18083:80 -v ntfy_data:/etc/ntfy -e TZ=Europe/Berlin -e BASE_URL=http://your-synology-ip:18083 ghcr.io/ntfy/ntfy:latest ``` -------------------------------- ### Send Multi-line Notification using Go Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md Demonstrates how to send a multi-line notification with advanced headers in Go using the standard http library. This example is useful for backend services or applications written in Go. ```go req, _ := http.NewRequest("POST", "https://ntfy.sh/mydoorbell", strings.NewReader(`There's someone at the door. 🐢 Please check if it's a good boy or a hooman. Doggies have been known to ring the doorbell.`)) req.Header.Set("Click", "https://home.nest.com/") req.Header.Set("Attach", "https://nest.com/view/yAxkasd.jpg") req.Header.Set("Actions", "http, Open door, https://api.nest.com/open/yAxkasd, clear=true") req.Header.Set("Email", "phil@example.com") http.DefaultClient.Do(req) ``` -------------------------------- ### Open Nest Portal using View Action Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md This snippet demonstrates how to open the Nest portal using the 'view' action. It requires a URL and can optionally clear the browser cache. No specific dependencies are mentioned beyond standard web browsing capabilities. ```json [ { "action": "view", "label": "Open portal", "url": "https://home.nest.com/", "clear": true } ] ``` -------------------------------- ### Integrate ntfy with Apprise using Python Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/releases.md This code snippet demonstrates how to use the Apprise library in Python to send notifications to an ntfy server. It requires the 'apprise' package to be installed. The example shows publishing a message to a specific ntfy topic. ```python pip3 install apprise apprise -b "Hi there" ntfys://mytopic ``` -------------------------------- ### Override Notification Title using ntfy CLI Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md This example shows how to publish a notification with a custom title using the ntfy command-line interface. The '-t' flag is used to specify the title. Ensure the ntfy CLI is installed and configured. ```shell ntfy publish \ -t "Dogs are better than cats" \ controversial "Oh my ..." ``` -------------------------------- ### Send Notification via Go (http.Post) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This Go program demonstrates sending a notification using the standard http.Post function. It requires the 'strings' package for creating the request body. The function sends the message to the specified ntfy topic. ```go http.Post("https://ntfy.sh/mytopic", "text/plain", strings.NewReader("Backup successful πŸ˜€")) ``` -------------------------------- ### Enable and Restart ntfy-client User Service (Bash) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/subscribe/cli.md Commands to enable the ntfy-client user systemd service to start on user login and restart the service. This service runs as the logged-in user and is configured via ~/.config/ntfy/client.yml. ```bash systemctl --user enable ntfy-client systemctl --user restart ntfy-client ``` -------------------------------- ### Send Notification via Command Line (curl) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This snippet demonstrates how to send a simple text notification using the curl command-line tool. It uses an HTTP POST request to a specified ntfy topic. No external libraries are required. ```bash curl -d "Backup successful πŸ˜€" ntfy.sh/mytopic ``` -------------------------------- ### Develop ntfy Main App with Go Run Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/develop.md Allows for direct development of the main `ntfy` application using `go run`. Requires enabling CGO and running a prerequisite target to embed static sites and documentation. This method is suitable for rapid iteration during main app development. ```shell export CGO_ENABLED=1 make cli-deps-static-sites go run main.go serve ``` -------------------------------- ### Send Notification via PHP (file_get_contents) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This PHP code uses file_get_contents to send a notification via an HTTP POST request. It configures the request method, header, and content through stream context options. This method is suitable for server-side PHP applications. ```php file_get_contents('https://ntfy.sh/mytopic', false, stream_context_create([ 'http' => [ 'method' => 'POST', // PUT also works 'header' => 'Content-Type: text/plain', 'content' => 'Backup successful πŸ˜€' ] ])); ``` -------------------------------- ### Send Notification via JavaScript (fetch API) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This JavaScript code uses the fetch API to send a notification via an HTTP POST request. It's suitable for web applications or Node.js environments. The body of the request contains the notification message. ```javascript fetch('https://ntfy.sh/mytopic', { method: 'POST', // PUT works too body: 'Backup successful πŸ˜€' }) ``` -------------------------------- ### Server Configuration - Basic Setup Source: https://context7.com/suhaibqr/salrabee-not/llms.txt Configuration options for running your own ntfy server, including basic HTTP, HTTPS with Let's Encrypt, and behind a reverse proxy. ```APIDOC ## ntfy Server Configuration ### Description Configure and run your own ntfy server with various options for network interfaces, TLS/SSL certificates, caching, and reverse proxy integration. ### Method Configuration File (`/etc/ntfy/server.yml`) and Command Line ### Endpoint N/A ### Parameters (Configuration File Options) - **base-url** (string) - The base URL for your ntfy server. - **listen-http** (string) - The address and port to listen on for HTTP connections (e.g., ":80"). - **listen-https** (string) - The address and port to listen on for HTTPS connections (e.g., ":443"). - **cert-file** (string) - Path to the SSL certificate file. - **key-file** (string) - Path to the SSL private key file. - **cache-file** (string) - Path to the cache database file. - **attachment-cache-dir** (string) - Directory for caching attachments. - **behind-proxy** (boolean) - Set to `true` if running behind a reverse proxy. - **auth-file** (string) - Path to the authentication database file. - **auth-default-access** (string) - Default access level for users (e.g., 'allow-all', 'deny-all'). - **enable-login** (boolean) - Enable user login functionality. ### Request Example (Basic HTTP) ```yaml # /etc/ntfy/server.yml base-url: "http://ntfy.example.com" cache-file: "/var/cache/ntfy/cache.db" attachment-cache-dir: "/var/cache/ntfy/attachments" ``` ### Request Example (HTTPS with Let's Encrypt) ```yaml # /etc/ntfy/server.yml base-url: "https://ntfy.example.com" listen-http: ":80" listen-https: ":443" cert-file: "/etc/letsencrypt/live/ntfy.example.com/fullchain.pem" key-file: "/etc/letsencrypt/live/ntfy.example.com/privkey.pem" cache-file: "/var/cache/ntfy/cache.db" attachment-cache-dir: "/var/cache/ntfy/attachments" ``` ### Request Example (Behind Reverse Proxy with Auth) ```yaml # /etc/ntfy/server.yml base-url: "https://ntfy.example.com" listen-http: ":2586" behind-proxy: true cache-file: "/var/cache/ntfy/cache.db" attachment-cache-dir: "/var/cache/ntfy/attachments" auth-file: "/var/lib/ntfy/auth.db" auth-default-access: "deny-all" enable-login: true ``` ### Command Line Examples ```bash # Start server with default configuration ntfy serve # Start server with a custom configuration file ntfy serve --config /etc/ntfy/server.yml # Create a new admin user ntfy user add --role=admin phil # Grant user access to a topic ntfy access phil mytopic rw ntfy access everyone announcements ro ``` ``` -------------------------------- ### Send Notification via HTTP POST Request Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/index.md This snippet illustrates the raw HTTP POST request format for sending a notification to an ntfy topic. It specifies the host, request method, and message content. This is the underlying mechanism for many ntfy interactions. ```http POST /mytopic HTTP/1.1 Host: ntfy.sh Backup successful πŸ˜€ ``` -------------------------------- ### ntfy-client Configuration with Basic Auth (YAML) Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/subscribe/cli.md Example of configuring ntfy-client within its YAML configuration file to subscribe to a protected topic using username and password for Basic Authentication. ```yaml - topic: secret command: 'notify-send "$m"' user: phill password: mypass ``` -------------------------------- ### Watchtower: Configure Ntfy Notifications with Shoutrrr Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/examples.md Set up Watchtower to send Docker container update notifications to ntfy using Shoutrrr. This can be configured via environment variables in docker-compose.yml or directly using the shoutrrr CLI. The ntfy URL format supports basic topic configuration, authentication tokens, and generic webhook setups. ```yaml services: watchtower: image: containrrr/watchtower environment: - WATCHTOWER_NOTIFICATION_SKIP_TITLE=True - WATCHTOWER_NOTIFICATION_URL=ntfy://ntfy.sh/my_watchtower_topic?title=WatchtowerUpdates ``` ```bash shoutrrr send -u "ntfy://ntfy.sh/my_watchtower_topic?title=WatchtowerUpdates" -m "testMessage" ``` ```text ntfy://:TOKEN@DOMAIN/TOPIC generic+https://DOMAIN/TOPIC?@authorization=Bearer+TOKEN ``` -------------------------------- ### Iterating with Go Templates Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md Illustrates how to use loops to iterate over collections or data structures within Go templates. This is useful for displaying lists of items or repeating content. ```Go Template {{range .items}} - {{.name}}{{end}} ``` -------------------------------- ### Publish Message: Basic Examples Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/publish.md Demonstrates publishing a simple message to a topic using different tools and programming languages. Covers curl, ntfy CLI, HTTP requests, JavaScript, Go, PowerShell, Python, and PHP. ```bash curl -d "Backup successful πŸ˜€" ntfy.sh/mytopic ``` ```bash ntfy publish mytopic "Backup successful πŸ˜€" ``` ```http POST /mytopic HTTP/1.1 Host: ntfy.sh Backup successful πŸ˜€ ``` ```javascript fetch('https://ntfy.sh/mytopic', { method: 'POST', // PUT works too body: 'Backup successful πŸ˜€' }) ``` ```go http.Post("https://ntfy.sh/mytopic", "text/plain", strings.NewReader("Backup successful πŸ˜€")) ``` ```powershell $Request = @{ Method = "POST" URI = "https://ntfy.sh/mytopic" Body = "Backup successful πŸ˜€" } Invoke-RestMethod @Request ``` ```python requests.post("https://ntfy.sh/mytopic", data="Backup successful πŸ˜€".encode(encoding='utf-8')) ``` ```php file_get_contents('https://ntfy.sh/mytopic', false, stream_context_create([ 'http' => [ 'method' => 'POST', // PUT also works 'header' => 'Content-Type: text/plain', 'content' => 'Backup successful πŸ˜€' ] ])); ``` -------------------------------- ### Install ntfy CLI with Homebrew Source: https://github.com/suhaibqr/salrabee-not/blob/main/docs/install.md This command installs the ntfy CLI on Linux and macOS using the Homebrew package manager. Homebrew simplifies the installation and management of command-line tools. ```bash brew install ntfy ```