home *** CD-ROM | disk | FTP | other *** search
- #!/static/bash
- ################################################################################
- #
- # Coreworks tv dec 2004
-
- function _debug() {
- local msg="$1"
- echo "DEBUG: $1"
- /static/bash
- }
-
- function _wait_with_bash {
-
- read -n 1 -s -t 3 -p "Waiting 3 seconds ... press s for a shell"
- if [ "x$REPLY" = "xs" ]; then
- echo
- echo " Press CTRL-D to continue ..."
- /static/bash
- else
- echo
- fi
- }
-
- #mount="/static/busybox mount"
- mount="/static/mount"
- umount="/static/busybox umount"
- insmod="/static/busybox insmod"
- tar="/static/busybox tar"
-
-
- dirs_to_bind_mount="bin lib opt sbin usr"
- MOUNTPOINT="/LIVECD" # live cd will be mounted there
- CLOOPPOINT="/LIVECLOOP" # if exists cloop will be mounted there
- ROOTPOINT="" # this will be the / of the cd (NOT the / of running livecd)
-
- echo "mounting cdrom..."
- for i in 0 1 2 3 4 5 6 7 8 9 ; do
- cddev="/dev/cdroms/cdrom$i"
- $mount -o iso9660,ro $cddev $MOUNTPOINT
- if [ -f /$MOUNTPOINT/livecd ] ; then
- echo "found cdrom at $cddev" ;
- break ;
- else
- echo "cdrom $cddev was the wrong device. trying next.\n";
-
- $umount $MOUNTPOINT
- fi
- done ;
-
- #_debug "after cdrom mount"
-
- if [ -f /$MOUNTPOINT/livecd.img ] ; then
-
- # live cd with cloop
- echo "This is a cloop live cd"
- $insmod cloop.o file=/$MOUNTPOINT/livecd.img
- $mount /dev/cloop/0 /$CLOOPPOINT -o ro
-
- ROOTPOINT=$CLOOPPOINT
-
- else
-
- # no cloop
- echo "This is a normal live cd (no cloop)"
- ROOTPOINT=$MOUNTPOINT
-
- fi
-
-
- # is bind mount really he thing we should do?
- for i in $dirs_to_bind_mount ; do
- #echo "bind mount $i"
- $mount -v --bind /$ROOTPOINT/$i /$i
- done
-
-
- # proc mount
- $mount /proc /proc -t proc
-
-
- #_debug "after proc, before RAMDISK stuff"
-
- # note: this tmpfs, it will not allocate the whole size
- # only if needed
- $mount -v -t tmpfs -o "size=50m" /ramdisk /ramdisk
-
- # we can use /bin/cp, as we have mounted /bin already
-
- # after this, we have etc/root/data with stuff from cd but writeable
- echo "Copying /etc to /ramdisk "
- /bin/cp -a /$ROOTPOINT/etc /ramdisk
-
- # we use the initrd fstab
- /bin/cp -v /etc/fstab /ramdisk/etc
- /bin/rm -rf /etc && /bin/ln -sf /ramdisk/etc /etc
-
- echo "Copying /root to /ramdisk"
- /bin/cp -a /$ROOTPOINT/root /ramdisk
- /bin/rm -rf /root && /bin/ln -sf /ramdisk/root /root
-
- echo "Copying /data to /ramdisk"
- /bin/cp -a /$ROOTPOINT/data /ramdisk
- /bin/rm -rf /data && /bin/ln -sf /ramdisk/data /data
-
- # FIXME /tmp stills lives on the initrd /
-
-
- # mtab
- /bin/rm /etc/mtab && /bin/ln -s /proc/mounts /etc/mtab
-
- # invoke this file if exists
- [ -f /linuxrc.ext ] && echo "found /linuxrc.ext, executing ..." && . /linuxrc.ext
-
- #_wait_with_bash
-
- # Change root device from ??? to /dev/ram0
- echo "0x100" > /proc/sys/kernel/real-root-dev
-
- exit 0
-