#
# use copy to ram and symbolic links to prepare a root 
# filesystem under $ROOTPATH
#
# part of the LiveBackup project:  
#
#                     http://livebackup.sourceforge.net/
#
# Copyright 2006 by Wolfgang Rohrmoser <info@rohrmoser-engineering.de>
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
#


# detect media and mount backup image 
execute netconf
execute mount_nfs
execute netload
execute mount_media
execute drive_settings
execute search_image
execute verify_image
execute copy2ram
execute mount_image
execute mount_nested_image

#
# create a writable filesystem
#
mkdir -p $ROOTPATH
execute mount_rwdisk $ROOTPATH $LB_METHOD_OPT

# to execute stage2 we need a basic shell (busybox) in $ROOTPATH
mkdir -p $ROOTPATH/bin
cp -a /bin/busybox $ROOTPATH/bin/
cd $ROOTPATH/bin 
ln -s busybox sh
mkdir -p $ROOTPATH/usr/i386-uclibc-linux/lib/
cp -a /lib/* $ROOTPATH/usr/i386-uclibc-linux/lib/

# if we need busybox applets as links, create them now
# in directory /busybox 
if [ -f /etc/busybox.links ]; then
    mkdir -p $ROOTPATH/busybox
    cd $ROOTPATH/busybox/ 
    for name in $(cat /etc/busybox.links); do
        bin=$(basename $name)
        if [ ! -e $bin ]; then
            ln -s /bin/busybox $bin
        fi
    done 
fi

#
# Local Variables: 
# mode: shell-script
# End: 
#










