Skip to content

Instantly share code, notes, and snippets.

@dirkakrid
dirkakrid / 0-image.sh
Created October 30, 2016 04:02 — forked from gdamjan/0-image.sh
grub imagelet to start VMs from an image without bootloader
# Create the grub boot image
grub-mkimage -O i386-pc -o grub.img -c grub.cfg \
at_keyboard configfile biosdisk ext2 linux test serial halt minicmd terminal cat acpi
# to create the unbootable linux image, no partitions
qemu-img create -f qcow2 unbootable.img 10G
sudo modprobe nbd max_part=16
sudo qemu-nbd -c /dev/nbd0 unbootable.img
sudo mkfs.ext4 -L ROOT /dev/nbd0
@dirkakrid
dirkakrid / systemd-ubuntu.md
Created October 30, 2016 03:30 — forked from webwurst/systemd-ubuntu.md
systemd-ubuntu
#!/bin/bash
# And now we cry because --network-interface on systemd-nspawn is broken. :(
set -e
NAME="$1"
shift
for retry in {1..5}; do
if machinectl status "$NAME" &>/dev/null; then
#!/usr/bin/env bash
# Download HTML converted from provided Markdown, using GitHub API v3
##
md2html(){
if [[ $# -ne 2 ]]; then
echo "ERROR.\nSYNTAX: Markdown_To_HTML <markdown-filepath> <dest-html-filepath>"
return
fi
unset _markdown_filepath
@dirkakrid
dirkakrid / README.md
Created October 30, 2016 01:14 — forked from abhishekkr/editor-bookmarklet.md
in browser editor ~ save them as link of bookmark

Use of each:

  • notepad : is a bit tweaked console-color notepad available in browser via bookmark

  • markdown-editor-need-www : live-preview markdown editor; does GET 2 Markdown JS files online

  • live-preview-markdown-editor-offline : will give a pure offline live-preview markdown editor

These will work directly by copy/pasting the content in Browser URL and pressing "Enter". Then you can bookmark it on render with proper name and use whenever want.

@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
@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 / 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 / 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 $?
}
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}