#
# DESCRIPTION:
#
#   Get master directory via network. Copy all files on ramdisk 
#   which replaces $MEDIA_MNT  
#
# part of the LiveBackup project:  
#
#                     http://livebackup.sourceforge.net/
#
# Copyright 2006-2010 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
#

if [ "$WGETARGS" != "not_set" ] && [ ! "$(is_mounted $MEDIA_MNT)" ]; then

    if [ $LB_DEBUG -eq 50 ]; then  set -x; fi

    # sz (Bytes) must fit into available memory
    sz=$MASTERSIZE

    mount -n -t tmpfs -o "size=$sz" tmpfs $MEDIA_MNT

    msg -i "loading system over network (please be patient) ..."
    ( cd $MEDIA_MNT; wget $WGETARGS )

    subdir=$(find $MEDIA_MNT -name $POLICYFILE)
    if [ "$subdir" ]; then
	mv $(dirname $subdir)/* $MEDIA_MNT
    else
	msg -c "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
	msg -c "ERROR: LiveBackup root directory not found "
	msg -c "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!"
	rescue_shell "provide LB root directory under $MEDIA_MNT, boot continues after exit" 
    fi 

fi


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