Skip to content

Instantly share code, notes, and snippets.

@g3rhard
Last active May 13, 2020 18:32
Show Gist options
  • Save g3rhard/321a965343ed51138dd8858c95918686 to your computer and use it in GitHub Desktop.
Save g3rhard/321a965343ed51138dd8858c95918686 to your computer and use it in GitHub Desktop.
#!/bin/bash
TEMP_STATUS="/tmp/cloudflared.status"
TEMP_ERR="/tmp/cloudflared.err"
TEMP_LOCK="/tmp/checkCloudflared.lock"
lockfile -r 0 $TEMP_LOCK || exit 1
sudo systemctl status cloudflared > $TEMP_STATUS
cat $TEMP_STATUS | grep "failed to connect to an HTTPS backend" > $TEMP_ERR
cat $TEMP_STATUS | grep "failed to perform an HTTPS request" >> $TEMP_ERR
if [ -s $TEMP_ERR ]
then
rm -f $TEMP_STATUS $TEMP_ERR $TEMP_LOCK
exit 1
fi
rm -f $TEMP_STATUS $TEMP_ERR $TEMP_LOCK
check program cloudflared with path "/bin/bash -c '/usr/scripts/cloudflared_check.sh'"
start program = "/bin/systemctl start cloudflared"
stop program = "/bin/systemctl stop cloudflared"
if status = 1 then restart
if 1 restart within 1 cycle then exec "/bin/bash -c '/usr/local/bin/slack-webhook.rb'"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment