#!/bin/sh
set -eu

# Ensure that we don't clean up /tmp setup by the Microsoft init process.
mkdir -p /run/tmpfiles.d
ln -s /dev/null /run/tmpfiles.d/tmp.conf

# https://githubmemory.com/repo/arkane-systems/genie/issues/142
# We have to unmount binfmt so it's completely handled by systemd in its own namespace with its automount service.
umount /proc/sys/fs/binfmt_misc

# Start systemd in its own namespace.
env -i /usr/bin/unshare --fork --mount-proc --pid --propagation unchanged -- sh -c "
exec /lib/systemd/systemd --unit=multi-user.target
" &
