Skip to content

Instantly share code, notes, and snippets.

View mark-kubacki's full-sized avatar
🎏

Mark Kubacki mark-kubacki

🎏
  • Germany, European Union
View GitHub Profile
@mark-kubacki
mark-kubacki / docker-gc.service
Created November 4, 2018 14:20
systemd timer that runs only if another service is active (running)
[Unit]
Description=Docker garbage collection
ConditionACPower=true
ConditionDirectoryNotEmpty=/var/lib/docker
Requisite=docker.service
PartOf=docker.service
After=docker.service
[Service]
Environment=GRACE_PERIOD=1h
@mark-kubacki
mark-kubacki / 00-reflinks-supported.sh
Last active August 14, 2018 22:00
file-level deduplication in O(n) utilizing reflinks
@mark-kubacki
mark-kubacki / docker-gitlab-runner.service
Created January 31, 2018 18:31
run the latest Docker image, and upgrade it using systemd timers (example for Gitlab-CI Runner)
[Unit]
Description=GITLAB Runner for Docker
Documentation=https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/blob/master/docs/install/docker.md
ConditionArchitecture=x86-64
ConditionACPower=true
AssertFileNotEmpty=/var/gitlab-runner/config/config.toml
After=docker.service docker-gitlab.service update-gitlab-runner.service
Requires=docker.service
Wants=update-gitlab-runner.service
@mark-kubacki
mark-kubacki / netboot-server.service
Created August 13, 2017 19:49
boot CoreOS and other images over the network, utilizing iPXE
[Unit]
Description=netboot server
Wants=network-online.target
After=network-online.target sys-subsystem-net-devices-ext0.device
AssertPathExists=/srv/ftp/tftproot
[Service]
Slice=machine.slice
KillMode=mixed
Restart=on-abort
@mark-kubacki
mark-kubacki / godoc-create-index.service
Last active June 28, 2017 16:20
godoc and systemd
[Unit]
Description=updates Golang's documentation index
ConditionFileNotEmpty=!/usr/share/go-1.6/godoc_index.db
ConditionACPower=true
AssertDirectoryNotEmpty=/usr/share/go-1.6
[Service]
Restart=on-failure
ExecStart=/usr/bin/godoc \
@mark-kubacki
mark-kubacki / newrelic-sysmond.service
Created July 5, 2016 21:58
Newrelic Sysmond unit file for systemd and Docker. Works with CoreOS and --storage-driver "overlay2" and "overlay".
[Unit]
Description=newrelic-sysmond
After=docker.service
[Service]
ProtectHome=true
ProtectSystem=full
PIDFile=/run/newrelic-sysmond.pid
ExecStartPre=-/bin/bash -c "[[ -x /opt/sbin/nrsysmond ]] || (mkdir -p /opt/sbin; docker pull newrelic/nrsysmond:latest && rsync -au $(docker inspect newrelic/nrsysmond:latest | jq -r '.[0].GraphDriver.Data.UpperDir // .[0].GraphDriver.Data.RootDir')/usr/sbin/nrsysmond /opt/sbin/)"
@mark-kubacki
mark-kubacki / backup.sh
Last active July 4, 2016 20:28
naive multi-processing backup script in BASH
#!/bin/bash
#
# Backup script that tries to utilize all available disc spindles and cores.
# For every target archive ("sink") create a file "sink.list"
# which contains what to backup ("sources") linewise.
# (Prefer plzip to xz if you have the former at hand.)
#
# wrapper to: tar sort xargs xz
#
# run: ./backup.sh run *.list
@mark-kubacki
mark-kubacki / get-video.sh
Last active October 6, 2016 19:26
gets videos from the internet and stores them as MKV
#!/bin/bash
#
# Gets videos, for example from YouTube, as best-quality separate tracks
# and stitches them, video by video, into a MKV – avoiding excess clutter files.
#
# wrapper to: mkvtoolnix youtube-dl iconv jq file
#
# author: W-Mark Kubacki <wmark@hurrikane.de>
set -e -o pipefail
@mark-kubacki
mark-kubacki / create-all.sh
Last active September 21, 2023 07:50
a dummy Certificate Authority for development and testing
#!/bin/bash
#
# Copyright (c) 2015 W. Mark Kubacki <wmark@hurrikane.de>
# Licensed under the terms of the RPL 1.5 for all usages
# http://www.opensource.org/licenses/rpl1.5
#
set -e -o pipefail
CAsubj="/C=DE/ST=Niedersachsen/L=Hannover/O=Dummy CA/CN=Sign-It-All"
@mark-kubacki
mark-kubacki / fields.go
Last active August 29, 2015 14:05
how to accept incoming email utilizing services of Mailgun
func BindHexEncodedField(field *[]byte) func(string, []string, binding.Errors) binding.Errors {
return func(fieldName string, formVals []string, errs binding.Errors) binding.Errors {
var err error
*field, err = hex.DecodeString(formVals[0])
if err != nil {
errs.Add([]string{fieldName}, binding.DeserializationError, err.Error())
}
return errs
}
}