Skip to content

Instantly share code, notes, and snippets.

@elico
Last active July 5, 2016 18:05
Show Gist options
  • Save elico/eb6f4116cafd0e526f6506cb56166a93 to your computer and use it in GitHub Desktop.
Save elico/eb6f4116cafd0e526f6506cb56166a93 to your computer and use it in GitHub Desktop.
CentOS 6 x86_64 https://github.com/betolj/ndpi-netfilter docker build files
#!/usr/bin/env bash
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/)@g' src/Makefile && \
sed -i -e 's/depmod -a/depmod -a $(shell ls \/lib\/modules\/)/g' src/Makefile && \
patch -p0 < /build/little-endian-patch.patch
NDPI_PATH=/build/ndpi-netfilter/nDPI make -j9 && \
#make install DESTDIR=/build/destdir && \
#make install && \
make modules_install DESTDIR=/build/destdir && \
make modules_install &&\
echo $?
mkdir -p /build/destdir/usr/local/lib && \
mkdir -p /build/destdir/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 && \
cd /build/destdir/lib64/xtables/ && \
echo $?
strip --strip-debug /build/destdir/lib/modules/$KERNEL_VERSION/extra/xt_ndpi.ko
FROM centos:6
ADD RPM-GPG-KEY-elrepo.org /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
ADD elrepo.repo /etc/yum.repos.d/elrepo.repo
RUN rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm \
&& yum remove -y kernel-headers kernel kernel-devel \
&& yum update -y \
&& yum --enablerepo=elrepo-kernel install -y kernel-lt kernel-lt-devel kernel-lt-doc.noarch kernel-lt-headers \
&& yum groupinstall -y "Development Tools" \
&& yum install -y libnetfilter_conntrack-devel libnfnetlink-devel libpcap-devel iptables-devel json-c-devel \
&& yum install -y wget git \
&& yum clean all
RUN mkdir /build
VOLUME /build
CMD ["/build/build.sh"]
FROM centos:6
ADD RPM-GPG-KEY-elrepo.org /etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
ADD elrepo.repo /etc/yum.repos.d/elrepo.repo
RUN rpm -iUvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm \
&& yum remove -y kernel-headers kernel kernel-devel \
&& yum update -y \
&& yum --enablerepo=elrepo-kernel install -y kernel-lt kernel-lt-devel kernel-lt-doc.noarch kernel-lt-headers \
&& yum groupinstall -y "Development Tools" \
&& yum install -y libnetfilter_conntrack-devel libnfnetlink-devel libpcap-devel iptables-devel json-c-devel \
&& yum install -y wget git \
&& yum clean all
RUN mkdir /build
VOLUME /build
CMD ["/build/build.sh"]
### Name: ELRepo.org Community Enterprise Linux Repository for el6
### URL: http://elrepo.org/
[elrepo]
name=ELRepo.org Community Enterprise Linux Repository - el6
baseurl=http://elrepo.org/linux/elrepo/el6/$basearch/
http://mirrors.coreix.net/elrepo/elrepo/el6/$basearch/
http://jur-linux.org/download/elrepo/elrepo/el6/$basearch/
http://repos.lax-noc.com/elrepo/elrepo/el6/$basearch/
http://mirror.ventraip.net.au/elrepo/elrepo/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo.el6
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-testing]
name=ELRepo.org Community Enterprise Linux Testing Repository - el6
baseurl=http://elrepo.org/linux/testing/el6/$basearch/
http://mirrors.coreix.net/elrepo/testing/el6/$basearch/
http://jur-linux.org/download/elrepo/testing/el6/$basearch/
http://repos.lax-noc.com/elrepo/testing/el6/$basearch/
http://mirror.ventraip.net.au/elrepo/testing/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-testing.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-kernel]
name=ELRepo.org Community Enterprise Linux Kernel Repository - el6
baseurl=http://elrepo.org/linux/kernel/el6/$basearch/
http://mirrors.coreix.net/elrepo/kernel/el6/$basearch/
http://jur-linux.org/download/elrepo/kernel/el6/$basearch/
http://repos.lax-noc.com/elrepo/kernel/el6/$basearch/
http://mirror.ventraip.net.au/elrepo/kernel/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-kernel.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
[elrepo-extras]
name=ELRepo.org Community Enterprise Linux Extras Repository - el6
baseurl=http://elrepo.org/linux/extras/el6/$basearch/
http://mirrors.coreix.net/elrepo/extras/el6/$basearch/
http://jur-linux.org/download/elrepo/extras/el6/$basearch/
http://repos.lax-noc.com/elrepo/extras/el6/$basearch/
http://mirror.ventraip.net.au/elrepo/extras/el6/$basearch/
mirrorlist=http://mirrors.elrepo.org/mirrors-elrepo-extras.el6
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-elrepo.org
protect=0
--- nDPI-patch/src/include/ndpi_define.h 2016-07-03 12:16:44.267661120 +0000
+++ nDPI-patch/src/include/ndpi_define.h 2016-07-03 12:17:11.543120986 +0000
@@ -27,8 +27,12 @@
/*
gcc -E -dM - < /dev/null |grep ENDIAN
+ python -c "import sys;sys.exit(0 if sys.byteorder=='big' else 1)"; if [ "$?" -eq 0 ];then echo "BIG";else; echo "LITTLE";fi
*/
+#define __BYTE_ORDER __LITTLE_ENDIAN__
+#define __LITTLE_ENDIAN__
+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__)
#include <machine/endian.h>
#endif

—–BEGIN PGP PUBLIC KEY BLOCK—– Version: GnuPG v1.4.5 (GNU/Linux)

mQGiBEm+/6QRBAC5mbtqOFSQ0FkTLIMdIoqxtraIeUqwbPp3IBYQ/u/EREjyEf1D qFyBEXII0dD8JDT85vRZ81jhB7nFWa0VbUfY0xfghkbnokiNBVNpiQcvszw3UYDF aLAaOC8Z98vmlsQaBBTQG6704ZXLr7FJyG3GP5WE6egXIQQbrMcdmCoRBwCg/dwC HLWjuemoDc5SX7hKHbB4zZ8D/jP+oMbqz+bDn8OZ2UuaGdxr+mHW8tzTdPjnEU8e hUt1ws8eBqn/gMfKvUBa8xFSILe8Ty99u+VjFbcRsdf0H6dRre9AdDVUz5oxzoPw gamA8mhPQvFh3wt9smtRUh5IoM2LiM1s5pGMLuYuvSnVUPArEnSfW6K5I6v7OarU 3WfrBACDEGGcaWKjfdkRtmKIQrzu6AnldVC1ISLVAoqxHnKNFTk1BgO0PSZDpfJI x8fMCnGlusoL6F5+LYEk4K4B0zvlj1ur3JocjxpuBLccl94JTo/+I9ZbS8ptUqLw LBUkgIQJzzIH4G5NZsQ3FpzSWGRFVa7etqTv9BfUMUmJxhEoobQ/ZWxyZXBvLm9y ZyAoUlBNIFNpZ25pbmcgS2V5IGZvciBlbHJlcG8ub3JnKSA8c2VjdXJlQGVscmVw by5vcmc+iGAEExECACAFAkm+/6QCGwMGCwkIBwMCBBUCCAMEFgIDAQIeAQIXgAAK CRAwm8MFuq2uUlgWAKCGWOpyodbzxS7Xy/0X9m9qVnHq+ACfUHrQzYAtFRpT07Sg giosE+mvAKu5Ag0ESb7/pxAIALgT0q0HhwugE717a7N+gAtCbFu8pCXOZcrAnJpG cMA9VWmsODZStPTxXYM2ggCMSzUnNis8pPZOPIP5C+t2IYtVjLshM4C9UiY7u5ET jErWCxWmF+2QLO50K56E4qxj0wufZt9P+Ih0USUM5L2oyrQG51uj/2v3Qq3igc8Z NTtmEOfis3losusQbAfZtTBmNQ0570kkhMxiyavgAUxLenXHYrkDJFuL7XdBCmna kykTn2dzU81rIDZ+QPxII4V/eZ5xGiRY/EDUIAysEV2m0NNZgWi/twUnZICm7zYp VRviJrBnFTvNEPMhiGRnJgQp/Krv4WIHQ67N8lQg3q5RJX8AAwUH/0UBjBgbsuWR dB+ZYWjKPBy+bJY/6HefPUuLrt3QDNINMW8kY7VzWRMWyGc4IlPJDW0nwOn/vT5H Dgc3YmA3tm7cKj5wpFijzff61Db8eq+CUKGscKxDBGzHq6oirM5U7DQLmipCs5Eb efwHIjE3aOUSnoQmniEnBWI2hm/rftmY9oJSi8xgns4wAokDPiMcucADtbV3fznx ppuowtBi8bcGB1vJZjTySQcSKWv+IVp5ej06uZ9501BEm6HxUZkuAGPecP65kcQu 5bg7B7LQeI5AWyujqvfuWgAF34xhl9QU/sDWxM3wUog+bw7y8pyWCqnJhp70yx8o SqzhFygT62eISQQYEQIACQUCSb7/pwIbDAAKCRAwm8MFuq2uUq8PAKC1+E2pSwiS oHXkKYPYDwApsP1mVACfRe1YnggLYQtG9LMeweVQQC77rK8= =qyRr —–END PGP PUBLIC KEY BLOCK—–

#!/usr/bin/env bash
docker build -t local/centos6-ndpi .
rm ./destdir -rf
docker run -i -t -v `pwd`:/build/ local/centos6-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