checkpoint
This commit is contained in:
parent
43ab9629f2
commit
098609d70d
|
@ -0,0 +1,103 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import sys
|
||||||
|
from pprint import pformat
|
||||||
|
import requests
|
||||||
|
import pyquery
|
||||||
|
import ssl
|
||||||
|
import OpenSSL
|
||||||
|
from urlparse import urlparse, urljoin
|
||||||
|
from datetime import datetime, timedelta
|
||||||
|
from pytz import UTC
|
||||||
|
import logging
|
||||||
|
logging.getLogger().setLevel(logging.DEBUG)
|
||||||
|
|
||||||
|
|
||||||
|
class AttrDict(dict):
|
||||||
|
def __init__(self, *a, **kw):
|
||||||
|
dict.__init__(self, *a, **kw)
|
||||||
|
self.__dict__ = self
|
||||||
|
|
||||||
|
derp = AttrDict()
|
||||||
|
|
||||||
|
def die(reason):
|
||||||
|
raise SystemExit(reason)
|
||||||
|
|
||||||
|
def interact():
|
||||||
|
import code
|
||||||
|
code.InteractiveConsole(locals=globals()).interact()
|
||||||
|
|
||||||
|
class CertificateProblem(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
class ReachabilityProblem(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def decode_ossl_time(t):
|
||||||
|
f = '%Y%m%d%H%M%SZ'
|
||||||
|
return datetime.strptime(t, f)
|
||||||
|
|
||||||
|
class SSLCert(object):
|
||||||
|
def __init__(self,x):
|
||||||
|
self.x = x
|
||||||
|
def notBefore(self):
|
||||||
|
return decode_ossl_time(self.x.get_notBefore())
|
||||||
|
def notAfter(self):
|
||||||
|
return decode_ossl_time(self.x.get_notAfter())
|
||||||
|
def commonName(self):
|
||||||
|
t = self.x.get_subject().get_components()
|
||||||
|
for x in t:
|
||||||
|
if x[0] == "CN":
|
||||||
|
return x[1]
|
||||||
|
def expired(self):
|
||||||
|
return datetime.utcnow() > self.notAfter()
|
||||||
|
def tooEarly(self):
|
||||||
|
return datetime.utcnow() < self.notBefore()
|
||||||
|
def validTime(self):
|
||||||
|
if not self.expired() and not self.tooEarly():
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
def expiresSoon(self):
|
||||||
|
week = timedelta(days=7)
|
||||||
|
then = datetime.utcnow() + week
|
||||||
|
return then > self.notAfter()
|
||||||
|
|
||||||
|
|
||||||
|
def check_url(url):
|
||||||
|
r = requests.get(url,verify=True)
|
||||||
|
if r.status_code is not 200:
|
||||||
|
raise ReachabilityProblem
|
||||||
|
cert = cert_for_url(url)
|
||||||
|
|
||||||
|
def cert_for_url(url):
|
||||||
|
o = urlparse(url)
|
||||||
|
if o.scheme != 'https':
|
||||||
|
return None
|
||||||
|
|
||||||
|
if not o.port:
|
||||||
|
p = 443
|
||||||
|
else:
|
||||||
|
p = o.port
|
||||||
|
c = ssl.get_server_certificate((o.hostname, p))
|
||||||
|
|
||||||
|
return SSLCert(
|
||||||
|
OpenSSL.crypto.load_certificate(
|
||||||
|
OpenSSL.crypto.FILETYPE_PEM,
|
||||||
|
c
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print "usage: %s <url>" % sys.argv[0]
|
||||||
|
sys.exit(1)
|
||||||
|
do_checks(sys.argv[1])
|
||||||
|
|
||||||
|
def do_checks(starturl):
|
||||||
|
urlqueue = []
|
||||||
|
urlqueue.append(starturl)
|
||||||
|
while len(urlqueue):
|
||||||
|
urlqueue.extend(check_url(urlqueue.pop()))
|
||||||
|
|
||||||
|
if __name__ == '__main__':
|
||||||
|
main()
|
|
@ -2,21 +2,33 @@ JUNKFILES = .bash_history .irb_history .pip .ScanSnap .nbems .fldigi .cpan
|
||||||
JUNKFILES += .gdb_history .mysql_history .sqlite_history
|
JUNKFILES += .gdb_history .mysql_history .sqlite_history
|
||||||
YYYYMM := $(shell date +%Y%m)
|
YYYYMM := $(shell date +%Y%m)
|
||||||
|
|
||||||
|
NO_COLOR = \033[0m
|
||||||
|
O1_COLOR = \033[0;01m
|
||||||
|
O2_COLOR = \033[32;01m
|
||||||
|
|
||||||
|
PREFIX = "$(O2_COLOR)==>$(O1_COLOR)"
|
||||||
|
SUFFIX = "$(NO_COLOR)"
|
||||||
|
|
||||||
default: backup
|
default: backup
|
||||||
|
|
||||||
backup: clean
|
backup: clean
|
||||||
mbsync eeqjgmail
|
@echo $(PREFIX) $@ $(SUFFIX)
|
||||||
mbsync acidhousegmail
|
cd ~/Documents/datavibe/backup && make
|
||||||
-rsync -avPhz --delete sneak@datavibe.net:.maildir/ \
|
offlineimap
|
||||||
$(HOME)/Documents/Secure/datavibe.maildir/
|
rsync -e "ssh -c arcfour -o Compression=no -x" \
|
||||||
@internalbackup.command # to 1tb
|
-avPhzy --delete sneak@datavibe.net:.maildir/ \
|
||||||
@externalbackup.command # to fw800
|
$(HOME)/Documents/Archival/mail/sneak.datavibe.net.maildir/
|
||||||
|
rsync -e "ssh -c arcfour -o Compression=no -x" \
|
||||||
|
-avPhzy --delete $(HOME)/Documents/Archival/mail/ \
|
||||||
|
sneak@datavibe.net:.mailbackup/
|
||||||
|
backup.command
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm -rfv ~/tmp/*
|
@echo $(PREFIX) $@ $(SUFFIX)
|
||||||
-rm -rfv ~/Library/Caches/*
|
@-rm -rf ~/tmp/*
|
||||||
-rm -rfv ~/.Trash/*
|
@-rm -rf ~/Library/Caches/*
|
||||||
-rm -rfv $(JUNKFILES)
|
@-rm -rf ~/.Trash/*
|
||||||
|
@-rm -rf $(JUNKFILES)
|
||||||
-mkdir -p $(HOME)/Documents/$(YYYYMM)
|
-mkdir -p $(HOME)/Documents/$(YYYYMM)
|
||||||
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)
|
-mv $(HOME)/Desktop/* $(HOME)/Documents/$(YYYYMM)
|
||||||
|
|
||||||
|
|
|
@ -7,12 +7,13 @@
|
||||||
|
|
||||||
NOW="`date +%Y%m%d.%H%M%S`"
|
NOW="`date +%Y%m%d.%H%M%S`"
|
||||||
|
|
||||||
BACKUPDEST=${BACKUPDEST:-"${USER}@jfk1.datavibe.net:backup/"}
|
BACKUPDEST=${BACKUPDEST:-"/Volumes/ExternalBackup/sneak.backup"}
|
||||||
|
|
||||||
RSYNC="rsync.3.0.9"
|
RSYNC="rsync.3.0.9"
|
||||||
OPTS="-rlptDPSyzh --no-owner --no-group --delete-excluded --delete"
|
OPTS="-rlptDPSyzh --no-owner --no-group --delete-excluded --delete"
|
||||||
|
|
||||||
RE=""
|
RE=""
|
||||||
|
RE+=" --exclude=.cache/"
|
||||||
RE+=" --exclude=/Desktop/" # desktop is like a visible tempdir.
|
RE+=" --exclude=/Desktop/" # desktop is like a visible tempdir.
|
||||||
RE+=" --exclude=/Library/Safari/"
|
RE+=" --exclude=/Library/Safari/"
|
||||||
RE+=" --exclude=/Downloads/"
|
RE+=" --exclude=/Downloads/"
|
||||||
|
@ -61,6 +62,11 @@ MINRE+=" --exclude=.DS_Store"
|
||||||
|
|
||||||
RE+=" ${MINRE}"
|
RE+=" ${MINRE}"
|
||||||
|
|
||||||
|
if [ ! -e "${BACKUPDEST}" ]; then
|
||||||
|
echo "backup destination $BACKUPDEST not available!" > /dev/stderr
|
||||||
|
exit 127
|
||||||
|
fi
|
||||||
|
|
||||||
RETVAL=255
|
RETVAL=255
|
||||||
while [ $RETVAL -ne 0 ]; do
|
while [ $RETVAL -ne 0 ]; do
|
||||||
$RSYNC $OPTS $RE ${HOME}/ ${BACKUPDEST}/Home/
|
$RSYNC $OPTS $RE ${HOME}/ ${BACKUPDEST}/Home/
|
||||||
|
|
Loading…
Reference in New Issue