This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
KEEP_DAYS=15 | |
VG="vg" # LVM volume group we are snapshoting | |
LV="data-volume-name" # Name of LVM-volume to take a snapshot of | |
BACKUP_PREFIX="backup-volume-prefix-" # Prefix of snapshot volume name. | |
SIZE=40G # Amount of disk space to allocate for the snapshot | |
# Create new snapshot |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
WORK_DIR="$(mktemp --directory --tmpdir build-root.XXXXXXXX)" | |
trap 'rm -rf "${WORK_DIR}"' EXIT | |
if [ -f rootcache.tar.gz ]; then | |
tar --extract --numeric-owner --gzip --file rootcache.tar.gz --directory "${WORK_DIR}" | |
else | |
debootstrap --variant=minbase --include=linux-image-amd64,ifupdown,isc-dhcp-client,openssh-server,less,nano,python,lvm2,debootstrap jessie "${WORK_DIR}" http://httpredir.debian.org/debian |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
cd /tmp | |
mkdir testroot | |
debootstrap wheezy testroot http://http.debian.net/debian | |
chroot testroot env LC_ALL=C apt-get install --no-install-recommends linux-image-amd64 | |
rm -rf testroot/var/cache/apt/* | |
ln -s bin/bash testroot/init | |
echo 'T0:23:respawn:/sbin/getty -L ttyS0 115200 vt100' >>testroot/etc/inittab | |
passwd -R "$(pwd)"/testroot -d root |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Remove every file except "./somefile.txt" and the directory "./somedir". | |
# --prune-empty to remove empty commits. | |
git filter-branch --tree-filter "find . -not -path './.git' -not -path './.git/*' -not -path './somefile.txt' -not -path './somedir/*' -not -path './somedir' -delete" --prune-empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
wireshark -k -i <(ssh root@dumphost.example.org tcpdump -U -w - host somehost.example.org and port 80) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copy the filesystem: | |
rsync --numeric-ids --checksum --delete --archive --verbose --exclude /dev --exclude /proc --exclude /run --exclude /sys root@someserver:/ /mnt/tmp | |
# Create a squashfs image | |
mksquashfs /mnt/tmp someserver.squashfs -comp xz -noappend | |
# Create LVM volume | |
lvcreate --size $(stat --format %s someserver.squashfs)B --name old-someserver vg | |
# Archive image on LVM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import socket | |
import struct | |
import sys | |
src_ip = sys.argv[1] | |
src_port = int(sys.argv[2]) | |
dst_addr = sys.argv[3] | |
dst_port = int(sys.argv[4]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import argparse | |
import crypt | |
import getpass | |
import random | |
import string | |
import sys | |
def parse_args(): | |
parser = argparse.ArgumentParser(description='Generate SHA-512 crypt() password hash with configurable number of rounds') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import select | |
import socket | |
import struct | |
import sys | |
TIMEOUT = 10.0 | |
ip = sys.argv[1] | |
port = int(sys.argv[2]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
dmsetup info | while IFS=: read NAME VALUE; do | |
# Trim leading and trailing whitespace from NAME and VALUE | |
NAME="$(echo "$NAME" | sed -e 's/^ *//g' -e 's/ *$//g')" | |
VALUE="$(echo "$VALUE" | sed -e 's/^ *//g' -e 's/ *$//g')" | |
if [ -z "$NAME" ]; then | |
continue | |
fi |
NewerOlder