diff --git a/XXX b/XXX index 5c98fbb..b5b11ac 100755 --- a/XXX +++ b/XXX @@ -1,3 +1,3 @@ #!/bin/sh # List XXXs, FIXMEs and TODOs in files -ag '^(?!.*mktemp).*XXX|FIXME|TODO' +ag '^(?!.*mktemp).*XXX|FIXME|TODO' "$@" diff --git a/docker-check-updates b/docker-check-updates index d627bbd..e8256f0 100755 --- a/docker-check-updates +++ b/docker-check-updates @@ -2,10 +2,10 @@ """Check Docker images for security/distro updates. Assumes DNF.""" from __future__ import division, print_function -from docker import Client +import docker import subprocess -c = Client(base_url='unix://var/run/docker.sock') +c = docker.APIClient(base_url='unix://var/run/docker.sock') for container in c.containers(): name = container['Names'][0] id_ = container['Id'] diff --git a/fetchmail-errors b/fetchmail-errors index a0d297a..33d6d72 100755 --- a/fetchmail-errors +++ b/fetchmail-errors @@ -7,7 +7,7 @@ import systemd.journal as journal yesterday = datetime.datetime.today() - datetime.timedelta(1) SINCE = yesterday -MINCOUNT = 5 +MINCOUNT = 20 j = journal.Reader() diff --git a/gen-yum b/gen-yum index 0e59b6b..2b9afcf 100755 --- a/gen-yum +++ b/gen-yum @@ -7,6 +7,7 @@ eval BASE_DIRS=~/www_static/dnf.bl0rg.net/*/* set -e for base_dir in $BASE_DIRS; do + restorecon -Rv $base_dir for YUM in $base_dir/{SRPMS,i386,x86_64}; do if [ -d $YUM ]; then echo "== $YUM" diff --git a/git-fsck-all b/git-fsck-all index 69b5af9..2cef177 100755 --- a/git-fsck-all +++ b/git-fsck-all @@ -15,6 +15,8 @@ import subprocess def git_directories(startdir): for dirpath, dirnames, _ in os.walk(startdir): + if '.sync' in dirpath: + continue if set(['info', 'objects', 'refs']).issubset(set(dirnames)): yield dirpath diff --git a/large-files b/large-files index e7bb1f2..49e0e25 100755 --- a/large-files +++ b/large-files @@ -1,8 +1,8 @@ #!/bin/sh # Find large files on this host -LARGE='+100M' +LARGE=${1:-100M} WHERE=`mount -t ext2,ext3,ext4,btrfs,ntfs,reiserfs,xfs,zfs | awk '{ print $3 }'` IGNORE='^(/var/lib/rpm/Packages|/home/.*/.btsync/.*\.db)$' -sudo find $WHERE -xdev -size $LARGE | grep --line-buffered -Ev "$IGNORE" +sudo find $WHERE -xdev -size +$LARGE | grep --line-buffered -Ev "$IGNORE" diff --git a/libvirt-restart-running b/libvirt-restart-running new file mode 100755 index 0000000..4690fb2 --- /dev/null +++ b/libvirt-restart-running @@ -0,0 +1,19 @@ +#!/usr/bin/python +# Restart all running libvirt domains + +from __future__ import division, print_function + +import libvirt +import sys + +conn = libvirt.open('qemu:///system') +if not conn: + print('Failed to open connection to the hypervisor!') + sys.exit(1) + +for domain in conn.listAllDomains(): + name = domain.name() + if domain.isActive(): + print('Restarting {}...'.format(name)) + domain.destroyFlags(flags=libvirt.VIR_DOMAIN_DESTROY_GRACEFUL) + domain.create() diff --git a/maildir-zero b/maildir-zero index 37199dc..80498cf 100755 --- a/maildir-zero +++ b/maildir-zero @@ -67,8 +67,15 @@ else: key = lambda i: i[0] reverse = False -length_name = max(len(name) for name in counts.keys()) -length_count = max(len(str(count)) for count in counts.values()) +try: + length_name = max(len(name) for name in counts.keys()) +except: + length_name = len('Total') +try: + length_count = max(len(str(count)) for count in counts.values()) +except: + length_count = 3 + for name, count in sorted(counts.items(), key=key, reverse=reverse): print('{0:{1}}\t{2:{3}d}'.format(name, length_name, count, length_count)) diff --git a/search-nulls b/search-nulls new file mode 100755 index 0000000..67e88d7 --- /dev/null +++ b/search-nulls @@ -0,0 +1,31 @@ +#!/usr/bin/env python +"""Find files starting with null bytes""" + +from __future__ import division, print_function +import argparse +import os + + +parser = argparse.ArgumentParser( + description='Find files starting with null bytes') +parser.add_argument( + 'directories', metavar='dir', default=['.'], nargs='*', + type=str, help='directory to be searched') +parser.add_argument( + '-n', dest='nullbytes', default=16, + type=int, help='number of null bytes') +args = parser.parse_args() + + +for directory in args.directories: + for dirpath, _, filenames in os.walk(directory): + for filename in filenames: + filename = os.path.join(dirpath, filename) + + if not os.path.isfile(filename): + continue + + with open(filename, 'rb') as f: + firstbytes = f.read(args.nullbytes) + if firstbytes == b'\0'*args.nullbytes: + print(filename)