Created
September 4, 2025 09:38
-
-
Save evenwebb/755e24a54d6daf20eaa661f69f8c1020 to your computer and use it in GitHub Desktop.
This script monitors a Plex Docker container and automatically restarts it if the Plex web UI becomes unresponsive. If the UI is unreachable, the script restarts the container and sends a Pushover notification to alert you.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/bash | |
| # Pushover configuration | |
| PUSHOVER_USER_KEY="00000000000000000000000" | |
| PUSHOVER_APP_TOKEN="000000000000000" | |
| # Docker container name for Plex | |
| PLEX_CONTAINER_NAME="plex" | |
| # Plex web UI URL | |
| PLEX_WEB_UI="http://192.168.1.1:32400/web/index.html" | |
| # Function to send a Pushover notification | |
| send_pushover_notification() { | |
| local message="$1" | |
| curl -s \ | |
| -F "token=$PUSHOVER_APP_TOKEN" \ | |
| -F "user=$PUSHOVER_USER_KEY" \ | |
| -F "message=$message" \ | |
| https://api.pushover.net/1/messages.json | |
| } | |
| # Check if Plex Docker container is running | |
| if docker ps | grep -q "$PLEX_CONTAINER_NAME"; then | |
| echo "Plex container is running. Checking web UI..." | |
| # Check if the Plex web UI is accessible | |
| if ! curl -s --head --fail --connect-timeout 15 -m 30 "$PLEX_WEB_UI" > /dev/null; then | |
| echo "Plex web UI is not accessible. Restarting container..." | |
| # Restart the Plex Docker container | |
| docker restart "$PLEX_CONTAINER_NAME" | |
| # Send Pushover notification | |
| send_pushover_notification "Plex Docker container was restarted because the web UI was not accessible." | |
| else | |
| echo "Plex web UI is accessible. No action needed." | |
| fi | |
| else | |
| echo "Plex container is not running. No action taken." | |
| fi | |
| # Exit the script | |
| exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment