mirror of
https://github.com/pygos/build.git
synced 2024-11-10 21:57:10 +01:00
8239578deb
Signed-off-by: David Oberhollenzer <david.oberhollenzer@tele2.at>
83 lines
1.5 KiB
Bash
83 lines
1.5 KiB
Bash
#!/bin/sh
|
|
|
|
PATH=/bin
|
|
|
|
/bin/busybox --install
|
|
busybox sleep 1
|
|
busybox mount -t proc proc /proc
|
|
busybox mount -t sysfs sysfs /sys
|
|
busybox mount -t devtmpfs none /dev
|
|
|
|
root_sfs=""
|
|
root=""
|
|
overlay_dev=""
|
|
singleuser=0
|
|
|
|
for param in `cat /proc/cmdline`; do
|
|
case $param in
|
|
root=*)
|
|
root="${param##root=}"
|
|
;;
|
|
root_sfs=*)
|
|
root_sfs="${param##root_sfs=}"
|
|
;;
|
|
overlay_dev=*)
|
|
overlay_dev="${param##overlay_dev=}"
|
|
;;
|
|
single*)
|
|
singleuser=1
|
|
;;
|
|
esac
|
|
done
|
|
|
|
if [ -z "${root}" ]; then
|
|
echo "No root drive specified!"
|
|
exec /bin/busybox sh
|
|
fi
|
|
|
|
if [ -z "${root_sfs}" ]; then
|
|
echo "No squashfs image specified!"
|
|
exec /bin/busybox sh
|
|
fi
|
|
|
|
while [ ! -e ${root} ]; do
|
|
echo "Waiting for root"
|
|
busybox sleep 1
|
|
done
|
|
|
|
# file system setup
|
|
mount ${root} /images
|
|
|
|
if [ ! -e /images/${root_sfs} ]; then
|
|
echo "${root_sfs} not found!"
|
|
exec /bin/busybox sh
|
|
exit 1
|
|
fi
|
|
|
|
mount -t squashfs /images/${root_sfs} /newroot
|
|
|
|
if [ ! -z "$overlay_dev" ]; then
|
|
while [ ! -e ${overlay_dev} ]; do
|
|
echo "Waiting for overlay device"
|
|
busybox sleep 1
|
|
done
|
|
|
|
mount ${overlay_dev} /newroot/cfg/overlay
|
|
chroot /newroot mount -n -t overlay overlay -olowerdir=/cfg/preserve/etc,upperdir=/cfg/overlay/etc,workdir=/cfg/overlay/etc_work /etc
|
|
else
|
|
chroot /newroot mount -n --bind /cfg/preserve/etc /etc
|
|
fi
|
|
|
|
# cleanup mounts
|
|
umount -l /images
|
|
umount -l /dev
|
|
umount /sys
|
|
umount /proc
|
|
|
|
if [ "$singleuser" == "1" ]; then
|
|
unset -v singleuser overlay_dev root root_sfs
|
|
exec /bin/busybox switch_root /newroot /bin/bash
|
|
fi
|
|
|
|
unset -v singleuser overlay_dev root root_sfs
|
|
exec /bin/busybox switch_root /newroot /bin/init
|