Skip to content

Instantly share code, notes, and snippets.

View wrouesnel's full-sized avatar

Will Rouesnel wrouesnel

View GitHub Profile
@wrouesnel
wrouesnel / make-libvirt-lxc
Created November 19, 2012 12:18
A script to automate the setup of Debian-like LXC containers.
#!/bin/bash
# LXC test environment builder for libvirt.
# Libvirt uses a different environment to the Ubuntu implementation, since
# cgroups are a rather general purpose protocol.
# The virsh manipulation stuff is pretty brute-force and inelegant. This whole
# thing really demands a GUI of some such, but it's a script which got out of
# hand really.
# Usage: make-libvirt-lxc [ROOT] <HOSTNAME>
@wrouesnel
wrouesnel / sshttpd-sites.conf
Last active December 21, 2015 17:38
sshttp daemon starter upstart script
description "Start all sshttpd instances on boot"
author "iain"
start on (local-filesystems and net-device-up)
task
script
for file in `ls /etc/sshttp.d/*.conf` ; do
filename=`basename ${file%.*}`
@wrouesnel
wrouesnel / getmail-idler
Last active December 24, 2015 16:38
A daemon script for watching watching IMAP accounts with IDLE and invoking getmail. Works with GetMail config files.
#!/usr/bin/env python
import imaplib2
import time
import threading
import subprocess
import argparse
import signal
import psutil
import sys
@wrouesnel
wrouesnel / getmail-idler.py
Last active April 4, 2018 22:34
A script to invoke getmail when accounts receive new mail. See http://wrouesnel.github.io/articles/A%20better%20Getmail%20IDLE%20client/ for more details.
#!/usr/bin/env python
# Getmail Idler Script v2
# Will Rouesnel
#
# This is a pure Python threading affair - there are better ways to do things
# epoll but there are much better libraries (like gevent) for that type of
# thing.
#
# Note: this script assumes you're running getmail with the "delete" option for
# the mailbox it checks - i.e. your inbox should always be cleared of all mail.
@wrouesnel
wrouesnel / gist:7151548
Created October 25, 2013 08:46
Backtrace of KeePass when xsel and Cinnamon have locked up.
Thread 16 (Thread 0x7f28234f2700 (LWP 13790)):
#0 pthread_cond_wait@@GLIBC_2.3.2 () at ../nptl/sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
No locals.
#1 0x00000000005e6573 in GC_wait_marker () at pthread_support.c:1863
No locals.
#2 0x00000000005e0905 in GC_help_marker (my_mark_no=70) at mark.c:1116
local_mark_stack = {{mse_start = 0x7f2816c70240, mse_descr = 24}, {mse_start = 0x7f2812ce1360, mse_descr = 24}, {
mse_start = 0x7f2816d282e8, mse_descr = 24}, {mse_start = 0x7f2816c9c738, mse_descr = 24}, {
mse_start = 0x7f282478d4f8, mse_descr = 24}, {mse_start = 0x7f282478d5d0, mse_descr = 24}, {
mse_start = 0x7f2816d2e588, mse_descr = 24}, {mse_start = 0x7f2816d34e58, mse_descr = 24}, {
@wrouesnel
wrouesnel / remote-backup.cmd
Created June 21, 2014 20:32
A batch file suitable for invoking a cygwin shell script which carries out a backup on Windows using unix-tooling.
rem This batch file is executed by vscsc.exe after the shadow copy has been
rem created. It is used to initate the backup.
rem
rem %1 is the volume ID of the backup, we pass it to the bash script which
rem runs rsync for us.
c:\cygwin64\bin\bash.exe --login -i ./do-remote-backup.bsh "%1"
@wrouesnel
wrouesnel / .remote-backup-excludes.txt
Last active September 5, 2021 23:32
A script for performing a remote backup to another server using rsync and bup for versioning.
# this is an rsync-excludes format list of files to exclude.
@wrouesnel
wrouesnel / home-directory-backup
Created June 21, 2014 20:53
A script for doing routine backups of one's home directory with bup and ZFS
#!/bin/bash
# Script to do sensible home directory backups. Expects to receive the
# target user as it's first argument, and then proceeds to do a home
# directory backup in a ZFS-aware way. The second arg should be the name
# for the backup. hostname is used if it's blank.
# The ZFS backup is done by snapshotting every file system underneath the
# home directory and then indexing them all with appropriate graft options.
# The backup destination is determined by the user-name, and expects to find
@wrouesnel
wrouesnel / sshtunnel.py
Created January 6, 2015 23:06
Creating an SSH tunnel that can be used in a larger program with Paramiko.
#!/usr/bin/env python
# Modified by: William Rouesnel (w.rouesnel@gmail.com)
# Copyright (C) 2003-2007 Robey Pointer <robeypointer@gmail.com>
#
# This file is part of paramiko.
#
# Paramiko is free software; you can redistribute it and/or modify it under the
# terms of the GNU Lesser General Public License as published by the Free
# Software Foundation; either version 2.1 of the License, or (at your option)
@wrouesnel
wrouesnel / zed.service
Last active July 11, 2023 19:25
systemd unit files for ZFS
[Unit]
Description=ZFS Event Daemon (zed)
Documentation=man:zed(8)
After=zfs-import-cache.service
After=zfs-import-scan.service
[Service]
Type=forking
ExecStart=/sbin/zed
PIDFile=/run/zed.pid