Skip to content

Instantly share code, notes, and snippets.


a5m0/ Secret

Created Jul 21, 2016
What would you like to do?
# basic script for restarting acd mount on failure and notifying via pushbullet,
# hardcoded and not great but whatever, note this mounts read-only, change to suit your needs
# put this in your crontab to run every 5 minuntes
# */5 * * * * python /home/user/ > /dev/null
from pushbullet import Pushbullet
import os
import subprocess
import logging
logging.basicConfig(filename='acdmount.log', level=logging.INFO, format='%(asctime)s %(levelname)s %(message)s')'ACD mount checker started')
DEVNULL = open(os.devnull, 'wb')
pb = Pushbullet('pushbullet-api-key-here')
exists = os.path.exists("/home/user/acd-mount/folder-to-check/")
if exists is not True:
logging.warning("ACD mount is down")
push = pb.push_note("ACD mount down", "attempting restart")"attempting umount")["acd_cli", "umount"], stdin=None, stdout=DEVNULL)"running ACD sync")["acd_cli", "sync"], stdin=None, stdout=DEVNULL)"attempting ACD mount")["acd_cli", "mount", "-ro", "/home/user/acd-mount"], stdin=None, stdout=DEVNULL)
if os.path.exists("/home/user/acd-mount/folder-to-check/"):
push = pb.push_note("ACD mount back up", "restart successful")"ACD mount restart succeeded")
print 'all good'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment