Skip to content

Instantly share code, notes, and snippets.

View cupracer's full-sized avatar

Thomas Schulte cupracer

  • NRW, Germany
  • 18:13 (UTC +02:00)
View GitHub Profile
@cupracer
cupracer / bind-serial-update.sh
Last active January 26, 2018 10:07
Update the timestamp of a Bind DNS zonefile
#!/bin/bash
if [ $# -ne 1 ]; then
echo "missing parameter"
exit 1
fi
ZONEFILE=$1
if ! [ -f $ZONEFILE ]; then
@cupracer
cupracer / create-encrypted-volume.sh
Created May 11, 2016 17:28
Create encrypted volume with keyfile
dd if=/dev/urandom of=myvolume.key bs=1 count=2048
cryptsetup luksFormat -c aes-cbc-essiv:sha256 -s 256 /path/to/myvolume
cryptsetup luksAddKey /path/to/myvolume myvolume.key
cryptsetup luksRemoveKey /path/to/myvolume
cryptsetup luksDump /path/to/myvolume
cryptsetup luksOpen -d myvolume.key /path/to/myvolume myvolume_enc
mkfs.ext4 /dev/mapper/myvolume_enc
@cupracer
cupracer / resize-luks-partition.sh
Created May 11, 2016 17:29
Resize LUKS-encrypted partition
# http://www.gigahype.com/resize-luks-encryped-lvm-partition/
# 1. Unmount the filesystem:
umount /secret
# 2. Run a filesystem check to clean up the inode tables before working with it:
fsck.ext3 -C 0 -f /dev/mapper/encrypted
# 3. Close out the LUKS filesystem:
cryptsetup luksClose encrypted
@cupracer
cupracer / autoyast.bind-mount.snippet.xml
Last active January 26, 2018 10:06
Define a bind mount in SLES AutoYaST
<nfs>
<nfs_entries config:type="list">
<nfs_entry>
<mount_point>/var/tmp</mount_point>
<nfs_options>bind</nfs_options>
<server_path>/tmp</server_path>
<vfstype>auto</vfstype>
</nfs_entry>
</nfs_entries>
</nfs>
@cupracer
cupracer / s3-bucket-stats.sh
Last active March 16, 2019 16:17
Amazon S3 CLI: get bucket stats
aws s3api list-objects --bucket <bucket-name> --output json --query "[sum(Contents[].Size), length(Contents[])]"
@cupracer
cupracer / varnishlog-examples.sh
Last active May 12, 2024 17:50
varnishlog examples (version 4.x)
# filter by request host header
varnishlog -q 'ReqHeader ~ "Host: example.com"'
# filter by request url
varnishlog -q 'ReqURL ~ "^/some/path/"'
# filter by client ip (behind reverse proxy)
varnishlog -q 'ReqHeader ~ "X-Real-IP: .*123.123.123.123"'
# filter by request host header and show request url and referrer header
@cupracer
cupracer / lvresize.sh
Last active January 26, 2018 10:03
extend LVM thin-pool metadata (example)
lvresize --poolmetadata +50M data/dockerpool
@cupracer
cupracer / haproxy.cfg
Last active March 13, 2022 10:06
HAproxy HTTP + HTTPS passthrough (roughly created, but works for me)
global
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
log-send-hostname
maxconn 4096
pidfile /var/run/haproxy.pid
user haproxy
group haproxy
daemon
stats socket /var/run/haproxy.stats level admin
@cupracer
cupracer / nfs.stp
Last active February 10, 2021 17:54
Systemtap script to trace various NFS calls
#! /usr/bin/env stap
global log_nfs_file_open = 1;
global log_nfs_file_read = 1;
global log_nfs_file_write = 1;
global log_nfs_getattr = 1;
global log_nfs_permission = 1;
global log_nfs_opendir = 1;
global log_nfs_lookup = 1;
@cupracer
cupracer / delete-or-empty-bucket.sh
Created February 22, 2018 09:43
Delete or empty an AWS S3 bucket
# Source:
# https://docs.aws.amazon.com/AmazonS3/latest/dev/delete-or-empty-bucket.html
# empty a bucket
# aws s3 rm s3://bucket-name --recursive
# delete a bucket
# aws s3 rb s3://bucket-name --force