2 # Download, configure, build and install the netfilters libnfnetlink and libnetfilter_queue libraries
3 LOG="${PWD}/install.log"
4 ERR="failed, please see $LOG status code="
10 # universal error reporting and exit
11 # $1 exit code to return
12 # $2 textual error message
13 # $3 status returned by program that induced exit
14 function error_exit() {
19 # download, configure, make, make install package
20 # $1 URL to downloaded archive file
21 function lib_install() {
22 # get filename from URL
23 filename=`expr "$1" : '.*\/\(.\+\)'`
24 # get stub for directory name
25 dir=`expr "${filename}" : '\(.\+\)\.tar\..\+'`
27 # default type is bzip2
29 arc_type=`expr "${filename}" : '.*\.\(.\+\)'`
30 if [ "${arc_type}" = "bz2" ]; then
32 elif [ "${arc_type}" = "gz" ]; then
36 echo -n "${filename}: downloading..."
39 if [ ${STATUS} -eq 0 ]; then
40 echo -n "${OK}, extracting..."
41 echo "Extracting" >>${LOG}
43 tar -x${type}f ${filename} >>${LOG} 2>&1
45 if [ ${STATUS} -eq 0 ]; then
46 # move into the package directory
49 # if there is a ./configure script, run it
50 if [ -e "configure" ]; then
51 echo -n "${OK}, configuring..."
52 echo "Configuring" >>${LOG}
53 ./configure --prefix=/usr >>${LOG} 2>&1
55 if [ ${STATUS} -ne 0 ]; then
56 error_exit 3 "${ERR}" ${STATUS}
60 echo -n "${OK}, building..."
61 echo "Building" >>${LOG}
65 if [ ${STATUS} -eq 0 ]; then
66 echo -n "${OK}, installing..."
67 echo "Installing" >>${LOG}
69 sudo sh -c "make install >>${LOG} 2>&1"
71 if [ ${STATUS} -eq 0 ]; then
74 error_exit 4 "${ERR}" ${STATUS}
77 error_exit 3 "${ERR}" ${STATUS}
80 # return to parent directory
84 error_exit 2 "${ERR}" ${STATUS}
86 else # download failed
87 error_exit 1 "${ERR}" ${STATUS}
93 echo -n "Going to need to run sudo to do 'make install', please pre-authorise now..."
94 sudo echo -ne "accepted..."
96 echo -e "successful, thank-you.\n"
98 echo "Logging to ${LOG}"
99 echo "Starting at `date`" > ${LOG}
100 echo "Installing netfilter libraries"
101 lib_install "http://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-0.0.30.tar.bz2"
102 lib_install "http://www.netfilter.org/projects/libnetfilter_queue/files/libnetfilter_queue-0.0.15.tar.bz2"
103 lib_install "http://www.netfilter.org/projects/libnetfilter_conntrack/files/libnetfilter_conntrack-0.0.81.tar.bz2"
104 lib_install "http://belnet.dl.sourceforge.net/sourceforge/flex/flex-2.5.33.tar.bz2"
105 lib_install "http://ftp.gnu.org/gnu/bison/bison-2.3.tar.gz"
106 lib_install "http://www.tcpdump.org/release/libpcap-0.9.7.tar.gz"
109 echo "Finished successfully. To run use ./packeteer"
111 echo "failed. Please review error reports; problems occurred"
113 # expr "http://www.netfilter.org/projects/libnfnetlink/files/libnfnetlink-0.0.30.tar.bz2" : '.*\/\(.+\)$'
114 # echo "`expr "libnfnetlink-0.0.30.tar.bz2" : '.*\.\(.\+\)'`"