| gotifyer_logo_96.png | ||
| gotifyer.sh | ||
| LICENSE | ||
| README.md | ||
gotifyer
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
curlto 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"
- Example:
-
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 isgotifyer.log.
Usage
- Clone or download the script to your local machine.
- Open the script in a text editor and replace the configuration variables with your own values.
- Make the script executable:
chmod +x gotifyer.sh - Run the script:
./gotifyer.sh
How It Works
- The script checks the health of the Gotify server using the
/healthendpoint. - If the server is healthy, it sends a notification using the
curlcommand. - 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.
