Skip to content

Instantly share code, notes, and snippets.

@a5m0 a5m0/acdmountdown.py Secret
Created Jul 21, 2016

Embed
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/acdmountdown.py > /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')
logging.info('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")
logging.info("attempting umount")
subprocess.call(["acd_cli", "umount"], stdin=None, stdout=DEVNULL)
logging.info("running ACD sync")
subprocess.call(["acd_cli", "sync"], stdin=None, stdout=DEVNULL)
logging.info("attempting ACD mount")
subprocess.call(["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")
logging.info("ACD mount restart succeeded")
else:
print 'all good'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.