#!/bin/sh
# $Id: 5.patchfiles.sh,v 1.18 2004/03/15 00:12:24 saturnero Exp $
 
set -e -u

. ./config.sh

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

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

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

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

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