Gotifyer is a Bash script allows you to send notifications using the Gotify service in Docker. It checks whether the Gotify container is running, sends a notification, and logs the results.
Go to file
2024-11-21 07:26:50 -05:00
gotifyer_logo_96.png Replace logo 2024-11-21 07:26:09 -05:00
gotifyer.sh Update default LOG_FILE variable. 2024-10-22 21:26:12 -04:00
LICENSE Initial commit 2024-10-20 10:26:49 -04:00
README.md Update README logo. 2024-11-21 07:26:50 -05:00

gotifyer

gotifyer logo

Overview

This Bash script allows you to send notifications using the Gotify service. It checks the health of the Gotify server before sending notifications and logs the results.

Prerequisites

  • curl: This script uses curl to send HTTP requests.
  • Bash: Ensure your system has Bash installed.

Configuration

Before using the script, you need to set the following configuration variables:

  • GOTIFY_URL: The URL of your Gotify server endpoint for sending messages.

    • Example: "http://gotify.example.com/message"
  • APP_TOKEN: Your application token from Gotify, which authorizes the script to send notifications.

  • MESSAGE_TITLE: The title of the notification you want to send.

  • MESSAGE: The content of the notification you want to send.

  • LOG_FILE: The file where the logs will be stored. The default is gotifyer.log.

Usage

  1. Clone or download the script to your local machine.
  2. Open the script in a text editor and replace the configuration variables with your own values.
  3. Make the script executable:
    chmod +x gotifyer.sh
    
  4. Run the script:
    ./gotifyer.sh
    

How It Works

  1. The script checks the health of the Gotify server using the /health endpoint.
  2. If the server is healthy, it sends a notification using the curl command.
  3. The script logs the result of the notification attempt, including the time, message, and HTTP response status.

Logging

Logs are written to the specified LOG_FILE. Each log entry includes a timestamp, making it easy to track notification attempts.

Example Log Entry

2024-10-20 12:34:56 - Notification sent successfully: Your notification message.

Error Handling

  • If the Gotify server is not healthy, the script logs an error message and exits without sending a notification.
  • If the notification fails to send, the script logs the HTTP status code received from the Gotify server.

Customization

Feel free to modify the script as needed. You can change the notification's priority by adjusting the priority field in the JSON payload. Valid priorities are:

  • 0: Min
  • 1: Low
  • 2: Normal
  • 3: High
  • 4: Emergency
  • 5: Very High (default)

License

This script is licensed under the GNU General Public License v3.0 or later. You are free to use, modify, and distribute this script under the same license. For more details, please refer to the GNU General Public License.