79 lines
2.5 KiB
Bash
79 lines
2.5 KiB
Bash
|
FOUND_ISO=
|
||
|
RAMSIZE=100000
|
||
|
|
||
|
msg ":: Creating new root ramdisk (dinamic size=${RAMSIZE}k) on /dev/shm..."
|
||
|
mkdir /newroot
|
||
|
/bin/mount -t tmpfs -o "size=${RAMSIZE}k" /dev/shm /newroot
|
||
|
mkdir -p /newroot/flash /newroot/cdrom /newroot/squashfs
|
||
|
|
||
|
#
|
||
|
# findiso(): looks for ISO9660 images stored in flash root
|
||
|
#
|
||
|
findiso(){
|
||
|
msg ":: Looking for openmamba ISO cdrom images"
|
||
|
|
||
|
# try removable devices only
|
||
|
for i in /newroot/flash/openmamba-*.iso; do
|
||
|
/bin/losetup /dev/loop0 $i
|
||
|
if mount -r -t iso9660 /dev/loop0 /newroot/cdrom >/dev/null 2>&1; then
|
||
|
if test -r /newroot/cdrom/rootfs.compressed; then
|
||
|
msg ":: Valid ISO image $i found..."
|
||
|
FOUND_ISO="$i"
|
||
|
return 0
|
||
|
fi
|
||
|
umount /newroot/cdrom
|
||
|
fi
|
||
|
/bin/losetup /dev/loop0
|
||
|
done
|
||
|
return 1
|
||
|
}
|
||
|
|
||
|
#/sbin/splash_util -c repaint ${splash_add} -t default --mesg="Looking for cdrom device" --progress="4444"
|
||
|
|
||
|
while true; do
|
||
|
msg ":: root device is ${root}"
|
||
|
if ! mount -t ext3 ${root} /newroot/flash >/dev/null 2>&1; then
|
||
|
if ! mount -t ext2 ${root} /newroot/flash >/dev/null 2>&1; then
|
||
|
err ":: Unable to mount USB rootfs. Supported filesystems are ext2 and ext3."
|
||
|
fi
|
||
|
fi
|
||
|
findiso
|
||
|
if [ "$FOUND_ISO" ]; then
|
||
|
# /sbin/splash_util -c repaint ${splash_add} -t default --mesg="Mounting compressed filesystem" --progress="5555"
|
||
|
msg ":: Mounting compressed filesystem"
|
||
|
/bin/losetup /dev/loop1 /newroot/cdrom/rootfs.compressed
|
||
|
mount -r -t squashfs /dev/loop1 /newroot/squashfs
|
||
|
|
||
|
msg ":: Creating directories and symlinks on ramdisk..."
|
||
|
|
||
|
mkdir -p \
|
||
|
/newroot/tmp /newroot/proc /newroot/sys \
|
||
|
/newroot/initrd /newroot/mnt /newroot/media \
|
||
|
/newroot/oldroot
|
||
|
|
||
|
ln -s squashfs/bin /newroot/bin
|
||
|
ln -s squashfs/boot /newroot/boot
|
||
|
ln -s squashfs/lib /newroot/lib
|
||
|
ln -s squashfs/opt /newroot/opt
|
||
|
ln -s squashfs/sbin /newroot/sbin
|
||
|
ln -s squashfs/srv /newroot/srv
|
||
|
ln -s squashfs/usr /newroot/usr
|
||
|
|
||
|
chroot /newroot /bin/cp -a \
|
||
|
/squashfs/dev /squashfs/home /squashfs/var \
|
||
|
/squashfs/etc /squashfs/root /
|
||
|
|
||
|
# Create empty utmp and wtmp
|
||
|
:> /newroot/var/run/utmp
|
||
|
:> /newroot/var/run/wtmp
|
||
|
|
||
|
[ "${init}" ] || init=/sbin/init
|
||
|
msg ":: Running init, runlevel:${runlevel}"
|
||
|
exec run-init /newroot ${init} ${runlevel}
|
||
|
exit 0
|
||
|
else
|
||
|
msg ":: Could not find a valid ISO image; opening a command prompt."
|
||
|
/bin/sh.shared
|
||
|
fi
|
||
|
done
|