Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
25efbd5f5c |
+10
-12
@@ -14,37 +14,35 @@ mount -t tmpfs tmpfs /tmp -o mode=1777
|
|||||||
|
|
||||||
# === cgroup2 ===
|
# === cgroup2 ===
|
||||||
mkdir -p /sys/fs/cgroup
|
mkdir -p /sys/fs/cgroup
|
||||||
mount -t cgroup2 none /sys/fs/cgroup 2>/dev/null || echo "mount cgroup2 failed"
|
mount -t cgroup2 none /sys/fs/cgroup 2>/dev/null || true
|
||||||
# shellcheck disable=SC2013 # word-splitting is intentional: controllers are space-separated
|
|
||||||
for c in $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null); do
|
for c in $(cat /sys/fs/cgroup/cgroup.controllers 2>/dev/null); do
|
||||||
echo "+$c" > /sys/fs/cgroup/cgroup.subtree_control 2>/dev/null || echo "enable cgroup controller $c failed"
|
echo "+$c" > /sys/fs/cgroup/cgroup.subtree_control 2>/dev/null || true
|
||||||
done
|
done
|
||||||
|
|
||||||
# === Rootless container prerequisites (best-effort) ===
|
# === Rootless container prerequisites (best-effort) ===
|
||||||
mount --make-rshared / 2>/dev/null || echo "make-rshared / failed"
|
mount --make-rshared / 2>/dev/null || true
|
||||||
chmod u+s /usr/bin/newuidmap /usr/bin/newgidmap 2>/dev/null || echo "chmod newuidmap/newgidmap failed"
|
chmod u+s /usr/bin/newuidmap /usr/bin/newgidmap 2>/dev/null || true
|
||||||
|
|
||||||
# === Timezone ===
|
# === Timezone ===
|
||||||
ln -sf /usr/share/zoneinfo/Europe/Stockholm /etc/localtime 2>/dev/null || echo "set timezone failed"
|
ln -sf /usr/share/zoneinfo/Europe/Stockholm /etc/localtime 2>/dev/null || true
|
||||||
|
|
||||||
# === Networking (QEMU slirp: guest 10.0.2.15/24, gw 10.0.2.2, dns 10.0.2.3) ===
|
# === Networking (QEMU slirp: guest 10.0.2.15/24, gw 10.0.2.2, dns 10.0.2.3) ===
|
||||||
ip link set lo up 2>/dev/null || echo "ip link set lo up failed"
|
ip link set lo up 2>/dev/null || true
|
||||||
ip link set eth0 up 2>/dev/null || echo "ip link set eth0 up failed"
|
ip link set eth0 up 2>/dev/null || true
|
||||||
ip addr add 10.0.2.15/24 dev eth0 2>/dev/null || echo "ip addr add eth0 failed"
|
ip addr add 10.0.2.15/24 dev eth0 2>/dev/null || true
|
||||||
ip route add default via 10.0.2.2 2>/dev/null || echo "ip route add default failed"
|
ip route add default via 10.0.2.2 2>/dev/null || true
|
||||||
echo nameserver 10.0.2.3 > /etc/resolv.conf
|
echo nameserver 10.0.2.3 > /etc/resolv.conf
|
||||||
|
|
||||||
# === Execute the configured command ===
|
# === Execute the configured command ===
|
||||||
# If slim.cmd=<base64> is on the kernel cmdline, decode and exec it.
|
# If slim.cmd=<base64> is on the kernel cmdline, decode and exec it.
|
||||||
# Otherwise, exec /slim/exec (generated from the image's CMD/ENTRYPOINT).
|
# Otherwise, exec /slim/exec (generated from the image's CMD/ENTRYPOINT).
|
||||||
# shellcheck disable=SC2013 # word-splitting is intentional: cmdline tokens are space-separated
|
|
||||||
for tok in $(cat /proc/cmdline 2>/dev/null); do
|
for tok in $(cat /proc/cmdline 2>/dev/null); do
|
||||||
case "$tok" in
|
case "$tok" in
|
||||||
slim.cmd=*)
|
slim.cmd=*)
|
||||||
v=${tok#slim.cmd=}
|
v=${tok#slim.cmd=}
|
||||||
decoded=$(printf '%s' "$v" | base64 -d 2>/dev/null) \
|
decoded=$(printf '%s' "$v" | base64 -d 2>/dev/null) \
|
||||||
|| decoded=$(printf '%s' "$v" | openssl base64 -d 2>/dev/null) \
|
|| decoded=$(printf '%s' "$v" | openssl base64 -d 2>/dev/null) \
|
||||||
|| echo "base64 decode failed"
|
|| true
|
||||||
if [ -n "$decoded" ]; then
|
if [ -n "$decoded" ]; then
|
||||||
exec /bin/sh -c "$decoded"
|
exec /bin/sh -c "$decoded"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user