#!/bin/bash # Requires tinystatus to be running on the status page. # If something else is running this script will need to # be adjusted in order to detect the correct status of # the services. # User configurable settings # The domain name of the tinystatus page. statuspage=status.dismyserver.net # The name of the service on the tinystatus page. servicecheck=tempusplexus # The name of the service locally to perform action on. servicename=plexmediaserver # What to do. Currently only restart is supported. # Anything else here will result in no action. action=restart # The magic starts here # Store whether the service is operational or degraded isactive=`curl https://${statuspage} 2>/dev/null | grep "${servicecheck}" | egrep -oi "operational|disrupted"` # If the service is degraded, perform $action [ "${isactive}" = "Disrupted" -a "${action}" = "restart" ] && systemctl restart "${servicename}" # The magic ends here