From b5e50f8a4c798a444c7b619e37f8f564f3f768d4 Mon Sep 17 00:00:00 2001 From: Filipp Lepalaan Date: Fri, 28 Dec 2012 13:44:12 +0200 Subject: Added AFP mount test --- README.md | 23 +++++++++++++---------- simpleton.py | 18 ++++++++++++++++-- 2 files changed, 29 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 475d5ab..187189d 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ simpleton ========= -A simple tool to check that your services are up. About as braindead as it gets, but better than nothing. ;-) +A simple tool to check that your services are up. About as braindead as it gets, but hopefully better than nothing. ;-) Installation @@ -21,6 +21,9 @@ Installation FTP: - files.example.com + AFP: + - username:password@files.example.com/share + Todo ==== - Add more protocol support, even simple socket connections would be good @@ -29,16 +32,16 @@ Todo License ======= - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - Version 2, December 2004 + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + Version 2, December 2004 - Copyright (C) 2004 Sam Hocevar + Copyright (C) 2004 Sam Hocevar - Everyone is permitted to copy and distribute verbatim or modified - copies of this license document, and changing it is allowed as long - as the name is changed. + Everyone is permitted to copy and distribute verbatim or modified + copies of this license document, and changing it is allowed as long + as the name is changed. - DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - 0. You just DO WHAT THE FUCK YOU WANT TO. + 0. You just DO WHAT THE FUCK YOU WANT TO. diff --git a/simpleton.py b/simpleton.py index b7dab89..a025749 100755 --- a/simpleton.py +++ b/simpleton.py @@ -6,8 +6,15 @@ # To Public License, Version 2, as published by Sam Hocevar. See # http://sam.zoy.org/wtfpl/COPYING for more details. -import time, os, sys -import urllib, ftplib, smtplib, yaml +import time +import os +import sys +import urllib +import ftplib +import smtplib +import yaml +import subprocess +import tempfile from termcolor import colored, cprint if len(sys.argv) < 2 or not os.path.exists(sys.argv[1]): @@ -28,8 +35,15 @@ for k, v in services.items(): ftplib.FTP(u) if k == 'SMTP': smtplib.SMTP(u) + if k == 'AFP': + tmp_path = tempfile.mkdtemp() + subprocess.check_call(['/sbin/mount_afp', '-o', 'nobrowse', u, tmp_path]) + subprocess.check_call(['/sbin/umount', tmp_path]) + os.rmdir(tmp_path) + passed += 1 except Exception, e: + print e out = colored(msg, 'red') print out -- cgit v1.2.3