rvc/guest-root/rvcinit
pi 134e85e485 add rng, rtc, networking, more CSR paravirt exts and fixes
honestly forgot what I added all over the last year or so, but here you
go, enjoy more cursed code
2022-11-25 23:11:56 +01:00

45 lines
1.1 KiB
Bash
Executable File

#!/bin/sh
if [ "$1" != "chroot" ]; then
echo
echo "> Welcome to userland!"
echo "> Setting up overlay mount for writeable root"
mount -t tmpfs tmpfs /tmp
mkdir /tmp/upper
mkdir /tmp/work
mkdir /tmp/newroot
mount -t overlay overlay \
-o lowerdir=/,upperdir=/tmp/upper,workdir=/tmp/work /tmp/newroot
mount --bind /dev /tmp/newroot/dev
chroot /tmp/newroot /rvcinit chroot
else
echo "> Entered overlay chroot, mounting /proc & /sys"
mount -t proc proc /proc
mount -t sysfs sys /sys
echo "> Startup took: $(cut -d' ' -f0 </proc/uptime)s"
cat << EOF
_ _
| (_)
_ ____ _____ | |_ _ __ _ ___ __
| '__\ \ / / __| | | | '_ \| | | \ \/ /
| | \ V / (__ | | | | | | |_| |> <
|_| \_/ \___| |_|_|_| |_|\__,_/_/\_\
by _pi_
EOF
echo "> Starting login shell on TTY /dev/hvc0"
export PATH="$PATH:/usr/local/bin"
while true; do
# use getty to start a shell in a new tty
getty -l /bin/sh -n 0 /dev/hvc0
echo "> Restarting login shell"
done
fi