Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
dirkakrid / openjdk
Created October 29, 2016 17:14 — forked from yrps/openjdk
systemd-nspawn launcher for Java applications
#!/bin/sh
set -eu
container="$(basename "$0")"
program="$1"
shift
# logname returns the user calling sudo
host_user="$(logname)"
@dirkakrid
dirkakrid / systemd-nspawn
Created October 29, 2016 23:49 — forked from blalor/systemd-nspawn
systemd-nspawn replacement [containers/build#162]
#!/usr/bin/env bash
## this is a total hack. acbuild needs systemd-nspawn. initially, I tried
## running the go agent in a rkt container, but failed for reasons I forget
## right now (overlayfs problems?). then I ran into more problems with systemd-
## nspawn on CentOS 7.1, and I forget the origin. we're getting closer: in
## CentOS 7.2 I'm able to run acbuild as root outside of a container. but when
## running within the go agent, systemd-nspawn is killed for no discernable
## reason. so, we're back to faking out acbuild by providing this systemd-
## nspawn-alike.
@dirkakrid
dirkakrid / README.md
Created October 29, 2016 23:51 — forked from blalor/README.md
Bulk move messages from All Mail to Trash

I hate GMail, but sometimes you gotta. They're notoriously awful at deleting lots of messages at once, as their own search engine will tell you. I had more than 1,000,000 messages I needed to purge and couldn't do it using their own tools. So I wrote my own.

@dirkakrid
dirkakrid / tar-docker-image
Created October 29, 2016 23:58 — forked from aputs/tar-docker-image
tar docker image (squash)
docker_root=/var/lib/docker/btrfs
subvolumes=subvolumes
docker_image=aputs/archlinux
tar_file=/tmp/image.tar.gz
# tar
cd $docker_root/$subvolumes/$(docker inspect --format='{{.Id}}' $docker_image)
tar --exclude={'.','..'} -Pcvzf $tar_file .* *
#!/bin/bash
set -e
set -o pipefail
function list_tars {
ROOT=$1
TAG=${2:-latest}
BASE=$(sed -e 's/.*{\(".*"\)}.*/\1/g' "${ROOT}/repositories" | sed 's/"//g' | awk -v RS=',' -F: '/^'${TAG}'/ {print $2}')
CUR=$BASE
TGZ=http://hkg.mirror.rackspace.com/archlinux/iso/2014.11.01/archlinux-bootstrap-2014.11.01-x86_64.tar.gz
ROOT=/var/lib/archlinux
TMPROOT=/tmp/archlinux
sudo mkdir -p ${TMPROOT}
wget "${TGZ}" -O- | sudo tar --strip-components=1 -C ${TMPROOT} -Pxzf-
sudo sed --in-place s/^#//g ${TMPROOT}/etc/pacman.d/mirrorlist
sudo btrfs subvolume delete ${ROOT}
sudo btrfs subvolume create ${ROOT}
@dirkakrid
dirkakrid / build-ubuntu-rootfs.sh
Created October 30, 2016 00:10 — forked from aputs/build-ubuntu-rootfs.sh
shell script for creating ubuntu base image for running inside docker containers
#!/bin/sh
set -x
control_c()
# run if user hits control-c
{
echo -en "\n*** Ouch! Exiting ***\n"
exit $?
}
@dirkakrid
dirkakrid / lvbootstrap
Created October 30, 2016 00:12 — forked from lennart/lvbootstrap
diy shell script explanation of base image creation to run systemd-nspawn containers from btrfs subvolumes
#!/bin/sh
log=3
fence="s/.*/ &/"
echo "# How to make a new base image"
echo "for containers."
echo
echo "Create a new logical volume:"
echo
lvcreate --help 2> /dev/null | head -n $log | sed "$fence"
@dirkakrid
dirkakrid / container_dhcp.network
Created October 30, 2016 00:16 — forked from InsanePrawn/container_dhcp.network
block device passthrough into systemd-nspawn for testing the munin smartctl plugin
[Match]
Name=host*
[Network]
DHCP=yes
@dirkakrid
dirkakrid / nspawn-enter
Created October 30, 2016 01:05 — forked from ephemient/nspawn-enter
A substitute for "machinectl shell" when the systemd-machined inside the nspawn container is too old (e.g. CentOS 7)
#!/usr/bin/env python3
import argparse
import contextlib
import ctypes
import dbus
import errno
import fcntl
import io
import os
import pickle