#!/bin/sh
# Created by Tim Yardley 
# version 1.2
# feel free to modify
#
# version 1.0 - initial release just to get apf/bfd installed.  
#   Worked, but had many bugs and was a quick batch job at best.
#
# version 1.1 - Edited first attempt and made it cleaner to install.
#  fixed most of the errors that got generated when installing. 
#  seems to work pretty well now, I am sure it could be done easier or cleaner,
#  but hell, it got the job done right!!
#
# version 1.2 - Change the rfx download url.  Who knew they changed it..
#


clear
echo "creating directory to perform install from"
mkdir $PWD/install-apfbfd
cd $PWD/install-apfbfd
echo "files will be installed from $PWD"
echo ""
echo "Doing wget to rfxnetworks."
echo ""
echo "wget http://www.rfxn.com/downloads/apf-current.tar.gz"
wget http://www.rfxn.com/downloads/apf-current.tar.gz
echo ""
echo ""

echo "wget http://www.rfxn.com/downloads/bfd-current.tar.gz"
wget http://www.rfxn.com/downloads/bfd-current.tar.gz

echo ""
echo ""
echo "Decompressing tar.gz files"
for files in `ls -1 | grep tar.gz` 
do
tar -zxvf $files
done

echo ""
echo ""

for appfiles in `ls -1 | grep -v tar.gz | grep -v install_apf_bfd.sh`
do
echo "going to cd to $appfiles and run the installers"
echo ""
echo ""
cd $appfiles
./install.sh && cd ../
echo ""
echo ""
echo "Done installing $appfiles"
echo ""
echo ""
done

