#! /bin/sh
#
# DESCRIPTION:
#
#    now we have changed to the new filesystem root
#    LiveBackup scripts are installed in /lib/LiveBackup
#
# 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
#


. /lib/LiveBackup/rc.LiveBackup

ROOTPATH=/

if [ $LB_DEBUG -gt 10 ]; then
    msg -c "enter new root environment"  
    msg -n -i "<ret> (continue) | v <ret> (verbose) | d <ret> (debug shell): "
    read ans
    if [ "$ans" = "d" ]; then
       rescue_shell
    fi
    if [ "$ans" = "v" ]; then
       set -x
    fi
fi


if [ "$LB_METHOD" = "symlinks" ]; then
    #
    # create and mount (optional) an additional ramdisk for var/ and home/
    #
    if [ ! "$(echo $LB_METHOD_OPT | grep auto)" ]; then
        # undokumented feature lb_symlinks=12M:64M
        # will create two ramdisks
        sz=$(echo $LB_METHOD_OPT | cut -d ":" -f 2)
    fi
    if [ "$sz" ]; then
	mkdir -p /ramdisk
        execute mount_rwdisk /ramdisk $sz
	mkdir -p /ramdisk/var/tmp /ramdisk/home
	rm -rf /var /home
	ln -s /ramdisk/home /home
	ln -s /ramdisk/var /var
    else
	mkdir -p /var
	mkdir -p /home
    fi

    execute filecopy 
fi


# common to all methods
execute configure 
execute hwdetect 
execute setup_swap 
execute cleanup 
execute mount_misc 
execute final 
execute runinit 


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