Skip to content

Instantly share code, notes, and snippets.

Avatar

Felix Hummel felixhummel

View GitHub Profile
View systemd_user_service.sh
# first, allow user services to be started on boot
# you only need to do this once
sudo loginctl enable-linger $USER
# this must be set to "no" (the default)
grep KillUserProcesses /etc/systemd/logind.conf
# create your user service file
mkdir -p ~/.config/systemd/user
@felixhummel
felixhummel / backup.sh
Last active Oct 17, 2020
borg backup script
View backup.sh
#!/bin/bash
set -euo pipefail
[[ $UID == 0 ]]
export BORG_REPO=/media/backup/borg/foo
export BORG_PASSPHRASE="TODO change this to a secret passphrase"
borg create \
--filter AME \
@felixhummel
felixhummel / configmap-and-deployment.md
Last active Jul 29, 2019
kubectl ConfigMap and Deployment
View configmap-and-deployment.md

Problem

ConfigMap changes do not result in deployment changes (which makes sense generally)

Solution

If you change the configuration of your app, then you want the Deployment to restart your pods.

@felixhummel
felixhummel / pre-commit
Created Mar 10, 2019
terraform pre-commit hook to format staged .tf files
View pre-commit
#!/bin/bash
# License: WTFPL
set -euo pipefail
# "--diff-filter d" excludes deleted files from this list
files=$(git diff --cached --diff-filter d --name-only -- "*.tf")
for f in $files; do
terraform fmt "$f"
git add "$f"
@felixhummel
felixhummel / lulz.sh
Created Jan 24, 2019
Docker Compose Lulz
View lulz.sh
LULZ=/tmp/compose-lulz
foolulz=$LULZ/foo/lulz
barlulz=$LULZ/bar/lulz
mkdir -p $foolulz $barlulz
cat <<'EOF' > $foolulz/docker-compose.yml
version: '3.7'
services:
app:
@felixhummel
felixhummel / disk-inspect.sh
Created Mar 22, 2018
list physical disks and their partitions
View disk-inspect.sh
#!/bin/bash
set -euo pipefail
# major device number 7 is loop
# grep loop /proc/devices
#disks=$(lsblk --raw --noheadings -o type,name | grep ^disk | awk '{ print "/dev/"$2 }')
# weird though: "--exclude 252" (device-mapper) does not work...
lsblk -o MAJ:MIN,UUID,SIZE,LABEL,NAME,MOUNTPOINT,FSTYPE --exclude 7 | grep -v ^252
View README.md

Generate the key-pair:

salt-call state.apply postfix.opendkim_genkey

Get the public key and set it on your DNS server:

salt-call file.read /etc/opendkim/keys/felixhummel.de/mail.txt
@felixhummel
felixhummel / srv__pillar__mine.sls
Created Feb 18, 2018
mine function to expose opendkim public keys
View srv__pillar__mine.sls
mine_functions:
dkim_pubkey:
- mine_function: file.read
- /etc/opendkim/foo/keys/bar.pub
@felixhummel
felixhummel / log_example.py
Created Dec 7, 2016
simple configurable logging for one-off scripts
View log_example.py
#!/usr/bin/env python
# encoding: utf-8
"""
Call me like this::
python log_example.py
To set the log level::
LOGLEVEL=INFO log_example.py
View port.pub
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDjah5JBLHIUshsVHW6qx/dift2JrRC84a1yXav7ksOQ0joAIgJnCCni84HN6FPzcXVox/f4TG7KIgqqM/46bmixGmCl2qeq4oBCGize8OVfhMRVnWiYBSmYOkGAZKk9iji7Z4E6l6qiXjNM7mu4Gxl+CN3kCHvgiyukcIFoiPLepA86Kj9CPPJclhSPlef0Apvil+dJ9R0LYMRKVeKHvuauqy2JoMreZIw3tM7/+JhxzYKVRJCfZ2GNHazX4xYjNDWDytwHtyjZ6kUD9cJCwk2nRwJ+PrR3bIG0UGlF1gcUBcQTCsjoG9sFfxZ3GCRzMTqFo3hh54XRq1h0QZnQFX30gs/ApLyimF6PDzQex7cH2Sj21OVsdBOmQT1hj8620c41zn85Mmk5r6lWwNRcQBNTXDCsU7sEK6YlgQGS9H1umQFFuAhAm2teNExOtcy8VryWnX97IkXuC64jb8KCLMF3Tkj87rBPsdz1zOH8OBYLavwV5Mbg1XZdwJe8pRKJ84lF7wXXu1UBlmk/OKFmFDe0CdmygFbrJE7nz/21OtjQKzi0SOgMrxAt0dGg1Yp1I0pka7N9cqc57BhShWy3LXMDoFEZjUcYvHZP24KsAaX0erkIsyOX+4x6WZLamoIfvYnYGVQMgw1zTxiccxtNNNG3GnibX5t7OtaYXVDtdylqQ== felix@port