#!/usr/bin/env bash set -e set -u set -o pipefail root="${1:?Usage $0 container-root}" mkdir -p "$root" mkdir "$root/bin" cp $(type -P busybox) "$root/bin" os_release=$(test -e /etc/os-release && echo /etc/os-release || echo /usr/lib/os-release) ID_LIKE=$(awk -F= '$1=="ID_LIKE" { print $2 ;}' $os_release) if [[ "$ID_LIKE" = *"suse"* ]]; then mkdir -p "$root/lib" mkdir -p "$root/lib64" for lib in $(find /lib*/ld*); do [[ -d $root/$(dirname $lib) ]] || mkdir -p $root/$(dirname $lib) cp $lib $root/$lib done fi mkdir -p "$root/usr/lib" touch "$root/usr/lib/os-release" ln -s busybox "$root/bin/sh" ln -s busybox "$root/bin/cat" ln -s busybox "$root/bin/tr" ln -s busybox "$root/bin/ps" ln -s busybox "$root/bin/ip" ln -s busybox "$root/bin/seq" ln -s busybox "$root/bin/sleep" ln -s busybox "$root/bin/test" mkdir -p "$root/sbin" cat <<'EOF' >"$root/sbin/init" #!/bin/sh printf "ps aufx:\n" ps aufx printf "/proc/1/cmdline:\n" printf "%s\n\n" "$(tr '\0' ' '