#!/bin/sh
# $Id: 5.patchfiles.sh,v 1.23 2004/10/15 01:38:23 saturnero 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
    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;
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