]> git.ipfire.org Git - thirdparty/systemd.git/blob - test/create-busybox-container
firstboot: Check if the given shell exists
[thirdparty/systemd.git] / test / create-busybox-container
1 #!/usr/bin/env bash
2
3 set -e
4 set -u
5 set -o pipefail
6
7 root="${1:?Usage $0 container-root}"
8 mkdir -p "$root"
9 mkdir "$root/bin"
10 cp $(type -P busybox) "$root/bin"
11
12 mkdir -p "$root/usr/lib"
13 touch "$root/usr/lib/os-release"
14
15 ln -s busybox "$root/bin/sh"
16 ln -s busybox "$root/bin/cat"
17 ln -s busybox "$root/bin/tr"
18 ln -s busybox "$root/bin/ps"
19 ln -s busybox "$root/bin/ip"
20
21 mkdir -p "$root/sbin"
22 cat <<'EOF' >"$root/sbin/init"
23 #!/bin/sh
24
25 printf "ps aufx:\n"
26 ps aufx
27
28 printf "/proc/1/cmdline:\n"
29 printf "%s\n\n" "$(tr '\0' ' ' </proc/1/cmdline)"
30
31 printf "/proc/1/environ:\n"
32 printf "%s\n\n" "$(tr '\0' '\n' </proc/1/environ)"
33
34 printf "/proc/1/mountinfo:\n"
35 cat /proc/self/mountinfo
36 printf "\n"
37
38 printf "/proc/1/cgroup:\n"
39 printf "%s\n\n" "$(cat /proc/1/cgroup)"
40
41 printf "/proc/1/uid_map:\n"
42 printf "%s\n\n" "$(cat /proc/1/uid_map)"
43
44 printf "/proc/1/setgroups:\n"
45 printf "%s\n\n" "$(cat /proc/1/setgroups)"
46
47 printf "/proc/1/gid_map:\n"
48 printf "%s\n\n" "$(cat /proc/1/gid_map)"
49
50 printf "ip link:\n"
51 ip link
52 EOF
53 chmod +x "$root/sbin/init"