Skip to content

Instantly share code, notes, and snippets.

@stbuehler
stbuehler / .gitignore
Last active November 2, 2023 10:58 — forked from markusfisch/README.md
Force any binary to use a specific network interface in Linux
*.so
@stbuehler
stbuehler / post-commit
Last active September 12, 2018 17:12
etckeeper-commit-gpg-mail
#!/bin/sh
# post-commit hook for etckeeper
set -e
recipients=admin@example.com
hostname=$(hostname -f)
git format-patch -1 --subject-prefix="etckeeper ${hostname}" --stdout | safe-mail $recipients
@stbuehler
stbuehler / fstab-uuid.sh
Created January 17, 2018 15:06
Use UUID instead of block device paths in /etc/fstab
#!/bin/sh
for bdev in $(blkid -o device); do
if [ ! -b "${bdev}" ]; then
echo >&2 "Not a block device: ${bdev}"
continue
fi
uuid=$(blkid -o value -s UUID -- "${bdev}")
# echo "Found UUID '${uuid}' for '${bdev}'"
# block device names hopefully don't contain special shit -.-
@stbuehler
stbuehler / monitor-systemd.sh
Last active May 23, 2019 11:55
monitor failed systemd units with cron and send mail
#!/bin/bash
# crontab entry:
# */10 * * * * /usr/local/sbin/monitor-systemd.sh --cron
tmpdir=$(mktemp --tmpdir -d systemd-monitor-XXXXXXX)
trap 'rm -rf "${tmpdir}"' EXIT
sendmail=0
if [ "$1" == "--cron" ]; then
@stbuehler
stbuehler / send.sh
Created August 4, 2017 10:49
S/MIME test mails send scripts
#!/bin/bash
set -e
tmpdir=$(mktemp --tmpdir -d smime-build-msg-XXXXXXX)
trap 'rm -rf "${tmpdir}"' EXIT
cd "${tmpdir}"
debug_show() {
#!/usr/bin/env ruby
require 'rotp'
require 'uri'
require 'cgi'
otpuri = STDIN.readline
otpuri = URI(otpuri)
if otpuri.scheme != "otpauth"
@stbuehler
stbuehler / rangealign.sh
Last active July 18, 2016 09:55
align port range to 2^n start and 2^n-1 size for smallest n
#!/bin/bash
# align port range to 2^n start and 2^n-1 size for smallest n
# call: rangealign.sh a-b
a=${1%-*}
b=${1##*-}
dist=$((b-a))
n=2
while [ $dist -ge $((2**n)) ]; do
((++n));
@stbuehler
stbuehler / open-xchange-nginx.conf
Created July 9, 2016 13:58
Open-Xchange nginx config
# route balancing only in commercial edition...
#map $cookie_JESSIONID $route_cookie1 {
# ~.+\.(?P<route>\w+)$ $route;
#}
#map $cookie_jsessionid $route_cookie2 {
# ~.+\.(?P<route>\w+)$ $route;
#}
#map $request_uri $route_uri1 {
# ~JSESSIONID=.+\.(?P<route>\w+)$ $route;
#}
#!/bin/sh
# Find model names current PPDs were installed from
set -e
tmpdir=$(mktemp --tmpdir -d cups-ppd-source-XXXXXXX)
trap 'rm -rf "${tmpdir}"' EXIT
ppd_updater () {
#!/bin/bash
# REQUIRES
# - bash
# - gnutls "certtool"
# - perl
# - awk
set -e
set -o pipefail