Skip to content

Instantly share code, notes, and snippets.

@elico
Last active July 6, 2016 01:20
Show Gist options
  • Save elico/45c87420850803a4837366e728885575 to your computer and use it in GitHub Desktop.
Save elico/45c87420850803a4837366e728885575 to your computer and use it in GitHub Desktop.
Debian wheezy netfilter-ndpi
#!/usr/bin/env bash
set -e
declare -x PKG_CONFIG=`which pkg-config`
KERNEL_VERSION=`ls /lib/modules/`
cd /build
ls /build/
mkdir /build/destdir
chmod 777 /build/destdir
rm -rf ./ndpi-netfilter
if [ -e "./master.tar" ]; then
tar xvf master.tar
mv ndpi-netfilter-master ndpi-netfilter
else
git clone https://github.com/betolj/ndpi-netfilter
fi
cd ndpi-netfilter
tar xvf nDPI.tar.gz
cd nDPI
./autogen.sh
# The autogen should run configure automatically
#./configure
make
make install DESTDIR=/build/destdir
make install
ldconfig
cd ..
ls
#sed -i -e 's/-DOPENDPI_NETFILTER_MODULE/$(shell pkg-config --cflags xtables)/g' ipt/Makefile && \
#sed -i -e 's@MODULES_DIR := /lib/modules/$(shell uname -r)@MODULES_DIR := /lib/modules/$(shell ls /lib/modules/|grep 3.16)@g' src/Makefile && \
#sed -i -e 's/depmod -a/depmod -a $(shell ls \/lib\/modules\/|grep 3\.16)/g' src/Makefile && \
sed -i -e 's/-DOPENDPI_NETFILTER_MODULE/$(shell pkg-config --cflags xtables)/g' ipt/Makefile && \
sed -i -e 's@MODULES_DIR := /lib/modules/$(shell uname -r)@MODULES_DIR := /lib/modules/$(shell ls /lib/modules/)@g' src/Makefile && \
sed -i -e 's/depmod -a/depmod -a $(shell ls \/lib\/modules\/)/g' src/Makefile && \
NDPI_PATH=/build/ndpi-netfilter/nDPI make -j9 && \
cat Makefile|grep install ; \
#make install DESTDIR=/build/destdir && \
make modules_install DESTDIR=/build/destdir && \
#make install && \
make modules_install &&\
echo $?
mkdir -p /build/destdir/usr/local/lib && \
mkdir -p /build/destdir/usr/lib64/xtables && \
mkdir -p /build/destdir/lib/modules/$KERNEL_VERSION/extra/ && \
cp /build/ndpi-netfilter/src/xt_ndpi.ko /build/destdir/lib/modules/$KERNEL_VERSION/extra/xt_ndpi.ko && \
cp /build/ndpi-netfilter/src/xt_ndpi.ko /build/destdir/lib/modules/$KERNEL_VERSION/extra/xt_ndpi.ko-non-stripped && \
cp /build/ndpi-netfilter/ipt/libxt_ndpi.so /build/destdir/usr/lib64/xtables/ &&
cd /build/destdir/usr/lib64/xtables/ && \
echo $?
strip --strip-debug /build/destdir/lib/modules/$KERNEL_VERSION/extra/xt_ndpi.ko
#!/usr/bin/env bash
find /var/cache/apt/archives/ -name '*deb' |
perl -ne 'print "$1\n" if /([^\/_]+)_/'|
sort -u |
while read a; do
find /var/cache/apt/archives/ -name "${a}_*" |
sort -r | tail -n+1 | xargs -rp rm -v;
done
FROM debian:wheezy
RUN echo "deb http://ftp.debian.org/debian/ wheezy-backports main non-free contrib" >> /etc/apt/sources.list \
&& apt-get update \
&& apt-get upgrade -y \
&& apt-get -t wheezy-backports install -y linux-image-amd64 linux-headers-amd64 \
&& apt-get install -y build-essential iptables-dev iptables conntrack libnetfilter-conntrack-dev \
&& apt-get install -y autoconf libtool git libpcap-dev \
&& apt-get clean -y && apt-get autoclean -y && apt-get autoremove -y
ADD clean.sh /clean.sh
RUN chmod +x /clean.sh \
&& /bin/bash clean.sh
RUN mkdir /build
VOLUME /build
CMD ["/build/build.sh"]
#!/usr/bin/env bash
set -e
docker build -t local/debian7-ndpi .
rm ./destdir -rf
docker run -i -t -v `pwd`:/build/ local/debian7-ndpi
cd destdir
tar cvfJ xt_ndpi.tar.xz ./*
tar tvf xt_ndpi.tar.xz
cd -
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment