#!/bin/sh
# $Id: 5.patchfiles.sh,v 1.22 2004/09/15 15:43:28 drizzt Exp $
 
set -e -u

. ./config.sh
. ./.common.sh

FILES="rc rc.live rc.conf rc.shutdown fstab rc.local"

echo "Patching files in /etc directory..."
if [ "$RELEASE" -ge "5" ];
then
    cp $LOCALDIR/files/rc.conf.5 $FREESBIEBASEDIR/etc/rc.conf || print_error
    cp $LOCALDIR/files/freesbie_1st $FREESBIEBASEDIR/etc/rc.d/freesbie_1st || print_error
    mkdir -p $FREESBIEBASEDIR/usr/local/etc/rc.d || print_error
   # cp $LOCALDIR/files/000.freesbie_2nd.sh $FREESBIEBASEDIR/usr/local/etc/rc.d/000.freesbie_2nd.sh
    touch $FREESBIEBASEDIR/etc/fstab || print_error
    cp $LOCALDIR/files/rc.local.5 $FREESBIEBASEDIR/etc/rc.local || print_error
else
    for i in $FILES; do
        cp $LOCALDIR/files/$i $FREESBIEBASEDIR/etc || print_error
    done
fi

cp $LOCALDIR/files/motd         $FREESBIEBASEDIR/etc || print_error
cp $LOCALDIR/files/hosts        $FREESBIEBASEDIR/etc || print_error
cp $LOCALDIR/files/loader.conf  $FREESBIEBASEDIR/boot || print_error

if [ "$RELEASE" -lt "5" ];
then 
    echo
    echo "Making vnodes in /dev..."
    cd $FREESBIEBASEDIR/dev || print_error
    for i in 0 1 2 3 4 5 6 7 8 9
     do
       sh MAKEDEV vn$i || print_error
    done;
    
    echo "Copying cool scripts (from sysutils/livecd)"
    sleep 1
    mkdir -p $FREESBIEBASEDIR/scripts/lang || print_error
    cp -vp $LOCALDIR/files/livecd/scripts/* $FREESBIEBASEDIR/scripts/ || print_error
    cp -vp $LOCALDIR/files/livecd/scripts/lang/* $FREESBIEBASEDIR/scripts/lang || print_error
fi
echo "Copying FloppyBackup and cardDetect scripts"

mkdir -p $FREESBIEBASEDIR/scripts/ || print_error
cd $LOCALDIR/files/scripts/ || print_error
for i in `find . -type d -not -name 'CVS' -maxdepth 1`
do
	mkdir -p $FREESBIEBASEDIR/scripts/$i || print_error
	for j in `find $i -type f -maxdepth 1`
	do
		cp -p $j $FREESBIEBASEDIR/scripts/$j || print_error
	done
done
