Skip to content

Instantly share code, notes, and snippets.

View stemid's full-sized avatar

Stefan Midjich stemid

View GitHub Profile
@stemid
stemid / make_backup.sh
Created June 25, 2018 12:30
Backup script for my personal laptop
#!/usr/bin/env bash
# Simple backup script for borg. http://borgbackup.readthedocs.io/en/stable/
# Install on Fedora: sudo dnf install borgbackup
#
# Configure BORG_REPO below to match some path on your own system. In my case
# it points to an autofs mount on my network backup device.
# Configure your own borg_excludes.
# by Stefan Midjich <swehack at gmail dot com>
export BORG_REPO="/media/nas/backups/$(hostname -s)-borgbackup"
@stemid
stemid / defaults.cfg
Last active June 7, 2018 11:38
Boilerplate logging class I use in most my applications
# AppLogger specific config.
[logging]
log_format = %(asctime)s %(name)s[%(process)s] %(levelname)s: %(message)s
log_debug = True
log_level = INFO
# Handler can be one of file, stdout or syslog
log_handler = stdout
# Can use this to log directly to another server if need be
@stemid
stemid / siptrack.py
Last active July 11, 2019 15:12
Ansible inventory script for Siptrack (https://github.com/sii/siptrackweb)
#!/usr/bin/env python
# Siptrack dynamic inventory script for Ansible.
# Depends on siptracklib
# * https://github.com/sii/siptracklib
#
#http://docs.ansible.com/ansible/latest/dev_guide/developing_inventory.html
#
# by Stefan Midjich <swehack at gmail dot com>

Keybase proof

I hereby claim:

  • I am stemid on github.
  • I am stemid (https://keybase.io/stemid) on keybase.
  • I have a public key ASD1nmKQzW0A_OGRdxfATEZL8ZAy55k5LulsWPfC2Iz2cAo

To claim this, I am signing this object:

#!/usr/bin/env bash
# {{ ansible_managed }}
# vim: set filetype=bash
#
# WARNING: Have you run xtrabackup_prepare.sh first?
# WARNING: You must know what you're doing or the backup will be ruined!
shopt -s nullglob
backup_dir=/var/backups/xtrabackup
@stemid
stemid / compress.sh
Last active December 22, 2016 13:31
Recursively compress files with xz using multiple threads
# With Bash 4.3 I'd rather use wait -n to keep N
# processes running at all times. As it is now you
# unfortunately have to wait for the last process
# to finish.
# Recursively compress all files in $dir
compress () {
dir=$1
count=${2:-2}
num_procs=${3:-0}
#!/usr/bin/env python
from __future__ import print_function
try:
from configparser import RawConfigParser
except ImportError:
from ConfigParser import RawConfigParser
from json import dumps
from argparse import ArgumentParser, FileType
#!/usr/bin/env python3
# This was a failed PoC to try and use socket files as ssh_config file. :)
# by Stefan Midjich
import os
import functools
import asyncio
def set_socket_permission(socket_file):
#!/usr/bin/env bash
home_base=/var/sftp
test $(id -u $PAM_USER) -gt 500 || exit 1
grep ^{{chroot_openssh_group}} /etc/group | grep -q $PAM_USER || exit 1
_HOME=$(getent passwd $PAM_USER 2>/dev/null | cut -d: -f6 2>/dev/null)
if [ -z "$_HOME" ]; then
@stemid
stemid / VMDK-orphaned.ps1
Created October 27, 2016 08:53
VMDK-orphaned
add-pssnapin VMware.VimAutomation.Core
Set-PowerCLIConfiguration -invalidCertificateAction 'ignore' -confirm:$false -Scope Session
Connect-VIServer -Server 10.220.100.220 -Protocol https
$report = @()
$daysAgo = (Get-Date).AddDays(-14)
$arrUsedDisks = Get-View -ViewType VirtualMachine | % {$_.Layout} | % {$_.Disk} | % {$_.DiskFile}
$arrDS = Get-Datastore | Sort-Object -property Name
foreach ($strDatastore in $arrDS) {
$ds = Get-Datastore -Name $strDatastore.Name | % {Get-View $_.Id}