Skip to content

Instantly share code, notes, and snippets.

@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
@stbuehler
stbuehler / abi-tag.patch
Last active December 14, 2015 16:37
clang abi-tag support.patch
Author: Stefan Bühler <stbuehler@web.de>
add gcc abi_tag support
- parse abi_tag attribute
- emit abi tags in name Itanium Mangling (but not for namespaces)
- for functions the abi tags from the return type need to be added
to the mangling of the function name, as long as they are not part of
the mangled function name otherwise (as tag on any involved namespace
or parameter type). Use nested "null" mangling of the signature to
@stbuehler
stbuehler / capture-output.sh
Created July 12, 2015 09:11
Capture stdout/stderr of a command while keeping the exit code
#!/bin/bash
syntax() {
echo "$0 [options] [--] cmd..."
echo "Options:"
echo " --stdout <logfile>: append stdout to logfile"
echo " --stderr <logfile>: append stderr to logfile"
echo "Returns exit code returned by captured command"
exit 1
}