# Squidtaild install script version 0.0.4
# 9 March        - Stefan Folkerts -

echo ""
echo "Squidtaild installer version 0.0.4 -March 9 2000-"
echo "Pressing enter will give you default [ ] values"
echo "This will install Squidtaild Version 2.1a6"
echo ""

echo -n "Please enter directory to install the squidtail in [/usr/sbin] :"
read install

if [ "$install" = "" ]
  then
    cp sbin/squidtaild /usr/sbin/
     echo ""
     if [ -e "/usr/sbin/squidtaild" ]
       then
          echo " * Squidtaild copied *"
       else
          echo "-ERROR- Squidtaild program NOT in place!!!!"
     fi  
    echo ""
  else
    cp sbin/squidtaild "$install"/squidtaild
     echo ""
     if [ -e ""$install"/squidtaild" ]
       then
          echo "Squidtaild copied..."
       else
          echo "-ERROR- Squidtaild program NOT in place!!!!"
     echo "" 
    fi
 fi


echo -n "Enter directory to install startup-script in [/etc/rc.d/init.d] :"
read startup

if [ "$startup" = "" ]
  then
    cp startup-script/* /etc/rc.d/init.d/
     if [ -e "/etc/rc.d/init.d/squidtaild" ]
       then
          echo ""
          echo " * Squidtaild init.d file copied *"
       else
          echo ""
          echo "-ERROR- squidtaild init.d file not in place!!!"
     fi
echo ""
  else
    cp startup-script/* "$startup"
     if [ -e ""$startup"/squidtaild" ]
       then
          echo ""
          echo " * Squidtaild init.d file copied *"
       else
         echo ""
         echo "-ERROR- squidtaild init.d file not in place!!!"
     fi
echo ""
fi


echo "Installing Squidtaild configuration files into /etc/squidtaild"
if [ -d /etc/squidtaild ]
 then
   echo "Directory /etc/squidtaild exists, transfering files to directory."
   echo ""
   cp -rf config/squidtaild/* /etc/squidtaild/
 else
   mkdir /etc/squidtaild
   cp -rf config/squidtaild/* /etc/squidtaild/
fi
echo "Testing if squitaild configuration files are in place.."
echo ""  
if [ -e "/etc/squidtaild/squidtaild.conf" ]
  then
    echo  " * Squidtaild.conf file in place *"
        if [ -d "/etc/squidtaild/filters" ]
           then
             echo ""
             echo " * Squidtaild filters directory is in place *"
           else
             echo "-ERROR- Squidtaild filters directory is NOT in place!!!"
        fi
  else
    echo "-ERROR- squidtaild.conf file NOT in /etc/squidtaild dir!"
fi
echo ""

echo "Installing Config Reader"
    cd perl_modules/ConfigReader-Simple-0.5
    perl Makefile.PL
    make
    make test
    make install

echo "Done.."
echo ""
echo "This should be all, it's time to configurate"
echo "(Or press CTRL-BREAK to abort now)"
sleep 4
vi /etc/squidtaild/squidtaild.conf
