#!/bin/bash
#kernel zassac ze slackware.com

rm -rf /tmp/kubelek/

cd /usr/src/
if [ ! -f iptables-1.2.9.tar.bz2 ] ; then
  wget http://www.netfilter.org/files/iptables-1.2.9.tar.bz2
fi
if [ ! -f patch-o-matic-ng-20040302.tar.bz2 ] ; then
  wget http://www.netfilter.org/files/patch-o-matic-ng-20040302.tar.bz2
fi
if [ ! -f iptables-1.2.9-imq1.diff ] ; then
  wget http://www.linuximq.net/patchs/iptables-1.2.9-imq1.diff
fi
if [ ! -f linux-2.4.26-imq.diff ] ; then
  wget http://www.linuximq.net/patchs/linux-2.4.26-imq.diff
fi
if [ ! -f ipp2p.tar.gz ] ; then
  wget http://rnvs.informatik.uni-leipzig.de/ipp2p/downloads/ipp2p.tar.gz
fi

#wget http://werg.icequake.net/~witwerg/imq/linux-2.4.24-imq-2.final.diff
#wget http://www.linuximq.net/patchs/IMQ.pom-ng.patch


echo "Zassalem zrodla ... wcisnij cosik..."
read a
mv linux-2.4.26-imq.diff linux-2.4.26
cd linux-2.4.26
patch -p1 < linux-2.4.26-imq.diff
cd /usr/src/

echo "Zapatchowalem kernela na IMQ ... wcisnij cosik..."
read a
rm -rf iptables-1.2.9
rm -rf patch-o-matic-ng-20040302
tar -jxvf patch-o-matic-ng-20040302.tar.bz2
tar -jxvf iptables-1.2.9.tar.bz2
export KERNEL_DIR=/usr/src/linux-2.4.26
cp iptables-1.2.9-imq1.diff iptables-1.2.9
cd iptables-1.2.9
patch -p1 < iptables-1.2.9-imq1.diff
chmod +x extensions/.IMQ-test*

echo "Zapatchowalem iptables na IMQ + patchomatiq ... wcisnij cosik..."
read a

cd /usr/src/patch-o-matic-ng-20040302

echo "Podawaj sciezke wiadomo : /usr/src/iptables-1.2.9 "

for latata in connlimit IPV4OPTSSTRIP mport nth quota random time TTL dstlimit iprange raw connbytes h323-conntrack-nat IPMARK ROUTE string ; do
  ./runme --batch $latata
done

cd /usr/src/iptables-1.2.9
make

echo "Skompilowane iptablesy ... wcisnij cosik..."
mkdir /tmp/kubelek/iptables-1.2.9
make install DESTDIR=/tmp/kubelek/iptables-1.2.9

echo "Zainstalowane w /tmp/kubelek/iptables-1.2.9 - zrob sobie paczuszke czy co tam"

cd /usr/src/
rm -rf ipp2p
tar -zxvf ipp2p.tar.gz
cd ipp2p
make
cp -f libipt_ipp2p.so /tmp/kubelek/iptables-1.2.9/usr/local/lib/iptables/

cd /usr/src/linux
echo "jedziesz kernela configi te sprawy"
echo "a potem"
echo "make modules_install MODLIB=/tmp/kubelek/kernel-modules-2.4.26"
echo "cp -f /usr/src/ipp2p/ipt_ipp2p.o /tmp/kubelek/kernel-modules-2.4.26"

