]> git.ipfire.org Git - people/ummeegge/ipfire-2.x.git/commitdiff
Pmacctd: New addon master
authorErik Kapfer <ummeegge@ipfire.org>
Sat, 21 Dec 2019 20:42:10 +0000 (21:42 +0100)
committerErik Kapfer <ummeegge@ipfire.org>
Sat, 21 Dec 2019 20:42:10 +0000 (21:42 +0100)
Signed-off-by: Erik Kapfer <ummeegge@ipfire.org>
config/backup/includes/pmacct [new file with mode: 0644]
config/pmacct/geoip-updater [new file with mode: 0644]
config/pmacct/interfaces.map [new file with mode: 0644]
config/pmacct/pmacctd.conf [new file with mode: 0644]
config/pmacct/pmacctd.init [new file with mode: 0644]
config/rootfiles/packages/pmacct [new file with mode: 0644]
lfs/pmacct [new file with mode: 0644]
src/paks/pmacct/install.sh [new file with mode: 0644]
src/paks/pmacct/uninstall.sh [new file with mode: 0644]
src/paks/pmacct/update.sh [new file with mode: 0644]

diff --git a/config/backup/includes/pmacct b/config/backup/includes/pmacct
new file mode 100644 (file)
index 0000000..de76361
--- /dev/null
@@ -0,0 +1 @@
+/etc/pmacctd
diff --git a/config/pmacct/geoip-updater b/config/pmacct/geoip-updater
new file mode 100644 (file)
index 0000000..82e23e6
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/bash -
+
+#
+# Cronjob script to update GeoIP for pmacct daily
+#
+# $author: ummeegge ipfire org ; $date: 21.10.2019
+########################################################
+#
+
+# Locations
+WORKDIR="/tmp/geoip";
+GEOIPDIR="/usr/share/pmacct/geoip";
+URLS="
+http://geolite.maxmind.com/download/geoip/database/GeoLite2-City.tar.gz
+";
+
+# Check if Pmacct is running, else exit here
+if ! pgrep 'pmacct'; then
+       logger -t pmacct "Pmacct is nor running. GeoIP updater script in /etc/fcron.daily/ is useless."
+       exit 1
+fi
+# Create temporary work dir and switch to it
+/bin/mkdir -p ${WORKDIR} && cd ${WORKDIR};
+# Download GeoIP with download log. If download fails write it to messages
+if ! /usr/bin/wget --no-check-certificate ${URLS} -o /tmp/geoip_update_dwn.log; then
+       /usr/bin/logger -t pmacct "Error: Downloading GeoIP database has been failed";
+       exit 1;
+       /bin/rm -rfv ${WORKDIR};
+fi
+# CleanUP GeoIP dir
+/bin/rm -rf ${GEOIPDIR}/*.mmdb
+# Unpack GeoIP mmdb
+tar xfvz GeoLite2-City.tar.gz --strip 1 --wildcards "**/*.mmdb"
+# Move GeoIP dats to ntopng
+/bin/mv ./*.mmdb ${GEOIPDIR}/ 2>/dev/null;
+# Restart ntopng
+/etc/init.d/pmacct restart;
+# Write to messages
+/usr/bin/logger -t pmacct "GeoIP database has been updated";
+# CleanUP
+/bin/rm -rf ${WORKDIR} 2>/dev/null;
+
+# EOF
+
diff --git a/config/pmacct/interfaces.map b/config/pmacct/interfaces.map
new file mode 100644 (file)
index 0000000..42964d7
--- /dev/null
@@ -0,0 +1,23 @@
+!
+! pcap_interfaces_map
+!
+! File syntax is key-based. Read full syntax rules in 'pretag.map.example' in
+! this same directory.
+!
+! pmacctd: mandatory keys: ifname.
+!
+! list of currently supported keys follows:
+!
+! 'ifname'             MATCH: name of the interface, ie. eth0, ens1, lo, etc.
+! 'ifindex'            SET: interface index. A positive 32-bit integer value
+!                      is expected.
+! 'direction'          SET: packet sampling direction. Possible values are
+'                      'in' and 'out'. It influences whether ifindex should
+!                      be used to populate in_iface or out_iface.
+!
+! Examples are IPFire sepcific:
+!
+ifindex=100    ifname=green0 direction=out
+ifindex=200    ifname=blue0 direction=out
+ifindex=100 ifname=orange0 direction=in
+ifindex=100 ifname=red0 direction=in
diff --git a/config/pmacct/pmacctd.conf b/config/pmacct/pmacctd.conf
new file mode 100644 (file)
index 0000000..f792d40
--- /dev/null
@@ -0,0 +1,20 @@
+!
+! pmacctd configuration
+!
+
+syslog: daemon
+
+promisc: true
+
+interface: green0
+# For multiple interface edit /etc/pmacctd/interfaces.map and uncomment the next line and comment the line above
+!pcap_interfaces_map: /etc/pmacctd/interfaces.map
+
+imt_mem_pools_number: 0
+
+plugins: memory[plugin1]
+
+imt_path[plugin1]: /var/spool/pmacct/plugin1.pipe
+
+# Simple Aggregation
+aggregate[plugin1]: src_host, src_port, dst_host, dst_port
diff --git a/config/pmacct/pmacctd.init b/config/pmacct/pmacctd.init
new file mode 100644 (file)
index 0000000..aba0a65
--- /dev/null
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+# Begin $rc_base/init.d/pmacct
+
+# Starts and stops pmacct daemon
+# Written by ummeegge  - ummeegge@ipfire.org
+
+# $Date: 2015-08-24 16:05:12 -0500 (Mon, 08 Aug 2015) $
+
+# Locations
+CONF="/etc/pmacctd/pmacctd.conf";
+# Pmacctd binary
+PMACCT="/usr/sbin/pmacctd";
+# Pmacctd start options '-d to daemonize' '-f' for the configuration file 
+OPT="-D -f ${CONF}";
+DESC="pmacct daemon";
+# Pmacctd syslog facilitiy
+#SYSLOG="local1";
+
+. /etc/sysconfig/rc
+. $rc_functions
+
+case "$1" in
+       start)
+               boot_mesg "Starting the ${DESC}... ";
+               loadproc ${PMACCT} ${OPT};
+               ;;
+
+       stop)
+               boot_mesg "Stopping the ${DESC}... ";
+               killproc ${PMACCT};
+               ;;
+
+       restart)
+               $0 stop
+               sleep 1
+               $0 start
+               ;;
+
+       status)
+               statusproc ${PMACCT}
+               ;;
+
+       *)
+               echo "Usage: $0 {start|stop|restart|status}"
+               exit 1
+               ;;
+esac
+
+# End $rc_base/init.d/pmacctd
diff --git a/config/rootfiles/packages/pmacct b/config/rootfiles/packages/pmacct
new file mode 100644 (file)
index 0000000..e54c731
--- /dev/null
@@ -0,0 +1,110 @@
+#etc/pmacctd
+etc/pmacctd/interfaces.map
+etc/pmacctd/pmacctd.conf
+etc/rc.d/init.d/pmacctd
+usr/bin/pmacct
+#usr/lib/pmacct
+#usr/lib/pmacct/examples
+#usr/lib/pmacct/examples/custom
+usr/lib/pmacct/examples/custom/libcustom.la
+#usr/lib/pmacct/examples/lg
+usr/lib/pmacct/examples/lg/pmbgp
+#usr/sbin/nfacctd
+usr/sbin/pmacctd
+#usr/sbin/pmbgpd
+#usr/sbin/pmbmpd
+#usr/sbin/pmtelemetryd
+#usr/sbin/sfacctd
+usr/share/pmacct
+#usr/share/pmacct/CONFIG-KEYS
+#usr/share/pmacct/FAQS
+#usr/share/pmacct/QUICKSTART
+#usr/share/pmacct/UPGRADE
+#usr/share/pmacct/docs
+#usr/share/pmacct/docs/IPFIX
+#usr/share/pmacct/docs/LOOKING_GLASS_FORMAT
+#usr/share/pmacct/docs/MSGLOG_DUMP_FORMATS
+#usr/share/pmacct/docs/SIGNALS
+#usr/share/pmacct/docs/TRIGGER_VARS
+#usr/share/pmacct/examples
+usr/share/pmacct/examples/allow.lst.example
+#usr/share/pmacct/examples/amqp
+usr/share/pmacct/examples/amqp/amqp_receiver.py
+#usr/share/pmacct/examples/avro
+usr/share/pmacct/examples/avro/avro_file_decoder.py
+#usr/share/pmacct/examples/bgp_agent.map.example
+#usr/share/pmacct/examples/bgp_md5.lst.example
+#usr/share/pmacct/examples/bgp_xconnects.map.example
+#usr/share/pmacct/examples/flow_to_rd.map.example
+#usr/share/pmacct/examples/kafka
+usr/share/pmacct/examples/kafka/kafka_consumer.py
+#usr/share/pmacct/examples/lg
+#usr/share/pmacct/examples/lg/pmbgp.py
+usr/share/pmacct/examples/networks.lst.example
+#usr/share/pmacct/examples/nfacctd-sql.conf.example
+usr/share/pmacct/examples/pcap_interfaces.map.example
+usr/share/pmacct/examples/peers.map.example
+usr/share/pmacct/examples/pmacctd-imt.conf.example
+usr/share/pmacct/examples/pmacctd-multiple-plugins.conf.example
+#usr/share/pmacct/examples/pmacctd-sql.conf.example
+usr/share/pmacct/examples/pmacctd-sqlite3.conf.example
+usr/share/pmacct/examples/ports.lst.example
+usr/share/pmacct/examples/pretag.map.example
+usr/share/pmacct/examples/primitives.lst.example
+#usr/share/pmacct/examples/probe_netflow.conf.example
+#usr/share/pmacct/examples/probe_sflow.conf.example
+usr/share/pmacct/examples/sampling.map.example
+usr/share/pmacct/examples/tee_receivers.lst.example
+#usr/share/pmacct/sql
+#usr/share/pmacct/sql/README.64bit
+#usr/share/pmacct/sql/README.GeoIP
+#usr/share/pmacct/sql/README.IPv6
+#usr/share/pmacct/sql/README.cos
+#usr/share/pmacct/sql/README.custom_primitives
+#usr/share/pmacct/sql/README.etype
+#usr/share/pmacct/sql/README.export_proto
+#usr/share/pmacct/sql/README.iface
+#usr/share/pmacct/sql/README.label
+#usr/share/pmacct/sql/README.mask
+#usr/share/pmacct/sql/README.mpls
+#usr/share/pmacct/sql/README.mysql
+#usr/share/pmacct/sql/README.nat
+#usr/share/pmacct/sql/README.pgsql
+#usr/share/pmacct/sql/README.sampling
+#usr/share/pmacct/sql/README.sqlite3
+#usr/share/pmacct/sql/README.tag2
+#usr/share/pmacct/sql/README.timestamp
+#usr/share/pmacct/sql/README.tunnel
+#usr/share/pmacct/sql/pmacct-create-db.pgsql
+#usr/share/pmacct/sql/pmacct-create-db_bgp_v1.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v1.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v2.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v3.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v4.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v5.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v6.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v7.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v8.mysql
+#usr/share/pmacct/sql/pmacct-create-db_v9.mysql
+#usr/share/pmacct/sql/pmacct-create-table_bgp_v1.pgsql
+#usr/share/pmacct/sql/pmacct-create-table_bgp_v1.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v1.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v1.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v2.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v2.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v3.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v3.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v4.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v4.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v5.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v5.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v6.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v6.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v7.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v7.sqlite3
+usr/share/pmacct/sql/pmacct-create-table_v8.sqlite3
+#usr/share/pmacct/sql/pmacct-create-table_v9.pgsql
+usr/share/pmacct/sql/pmacct-create-table_v9.sqlite3
+#usr/share/pmacct/sql/pmacct-grant-db.mysql
+var/ipfire/backup/addons/includes/pmacct
+var/spool/pmacctd
diff --git a/lfs/pmacct b/lfs/pmacct
new file mode 100644 (file)
index 0000000..01a120f
--- /dev/null
@@ -0,0 +1,116 @@
+###############################################################################
+#                                                                             #
+# IPFire.org - A linux based firewall                                         #
+# Copyright (C) 2019  IPFire Team  <info@ipfire.org>                          #
+#                                                                             #
+# This program is free software: you can redistribute it and/or modify        #
+# it under the terms of the GNU General Public License as published by        #
+# the Free Software Foundation, either version 3 of the License, or           #
+# (at your option) any later version.                                         #
+#                                                                             #
+# This program is distributed in the hope that it will be useful,             #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of              #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the               #
+# GNU General Public License for more details.                                #
+#                                                                             #
+# You should have received a copy of the GNU General Public License           #
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.       #
+#                                                                             #
+###############################################################################
+
+###############################################################################
+# Definitions
+###############################################################################
+
+include Config
+
+VER        = 1.7.3
+
+THISAPP    = pmacct-$(VER)
+DL_FILE    = $(THISAPP).tar.gz
+DL_FROM    = $(URL_IPFIRE)
+DIR_APP    = $(DIR_SRC)/$(THISAPP)
+TARGET     = $(DIR_INFO)/$(THISAPP)
+PROG       = pmacct
+PAK_VER    = 1
+
+DEPS       = ""
+
+###############################################################################
+# Top-level Rules
+###############################################################################
+
+objects = $(DL_FILE)
+
+$(DL_FILE) = $(DL_FROM)/$(DL_FILE)
+
+$(DL_FILE)_MD5 = 447f02f565718a942c9442f8dbd1c863
+
+install : $(TARGET)
+
+check : $(patsubst %,$(DIR_CHK)/%,$(objects))
+
+download :$(patsubst %,$(DIR_DL)/%,$(objects))
+
+md5 : $(subst %,%_MD5,$(objects))
+
+dist: 
+       @$(PAK)
+
+###############################################################################
+# Downloading, checking, md5sum
+###############################################################################
+
+$(patsubst %,$(DIR_CHK)/%,$(objects)) :
+       @$(CHECK)
+
+$(patsubst %,$(DIR_DL)/%,$(objects)) :
+       @$(LOAD)
+
+$(subst %,%_MD5,$(objects)) :
+       @$(MD5)
+
+###############################################################################
+# Installation Details
+###############################################################################
+
+$(TARGET) : $(patsubst %,$(DIR_DL)/%,$(objects))
+       @$(PREBUILD)
+       @rm -rf $(DIR_APP) && cd $(DIR_SRC) && tar zxf $(DIR_DL)/$(DL_FILE)
+       #cd $(DIR_APP) && ./autogen.sh
+       cd $(DIR_APP) && ./configure                    \
+               --prefix=/usr                           \
+               --sysconfdir=/etc/pmacctd               \
+               --enable-static=no                      \
+               --enable-sqlite3                        \
+               --enable-l2                             \
+               --enable-plabel                         \
+               --enable-jansson
+
+       # Add directory for plugins and pipes
+       -mkdir -vp /var/spool/pmacctd
+
+       # Add configuration folder
+       -mkdir -v /etc/pmacctd
+
+       # Add backup
+       install -v -m 644 $(DIR_SRC)/config/backup/includes/pmacct \
+               /var/ipfire/backup/addons/includes/pmacct
+
+       # Copy configuration to sysconfdir
+       install -v -m 750 $(DIR_CONF)/pmacct/pmacctd.conf \
+               /etc/pmacctd/pmacctd.conf
+
+       # Copy IPFire specific interfaces.map to configure directory
+       install -v -m 750 $(DIR_CONF)/pmacct/interfaces.map \
+               /etc/pmacctd/interfaces.map
+
+       # Copy initscript to dir
+       install -v -m 754 $(DIR_CONF)/pmacct/pmacctd.init \
+               /etc/rc.d/init.d/pmacctd
+
+       cd $(DIR_APP) && make $(MAKETUNING)
+       cd $(DIR_APP) && make install
+
+       @rm -rf $(DIR_APP)
+       @$(POSTBUILD)
diff --git a/src/paks/pmacct/install.sh b/src/paks/pmacct/install.sh
new file mode 100644 (file)
index 0000000..86319b8
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+
+extract_files
+restore_backup ${NAME}
+
+# Add symlinks for runlevels
+ln -s ../init.d/pmacctd /etc/rc.d/rc0.d/K85pmacctd
+ln -s ../init.d/pmacctd /etc/rc.d/rc3.d/S12pmacctd
+ln -s ../init.d/pmacctd /etc/rc.d/rc6.d/K85pmacctd
+
+# Add meta file for services control in WUI
+touch /opt/pakfire/db/installed/meta-pmacctd
+
+# Start pmacct
+start_service ${NAME}
diff --git a/src/paks/pmacct/uninstall.sh b/src/paks/pmacct/uninstall.sh
new file mode 100644 (file)
index 0000000..e52308b
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+
+stop_service ${NAME}
+extract_backup_includes
+make_backup ${NAME}
+remove_files
+
+# Delete symlinks
+rm -rfv /etc/rc.d/rc?.d/???pmacctd
+
diff --git a/src/paks/pmacct/update.sh b/src/paks/pmacct/update.sh
new file mode 100644 (file)
index 0000000..89c40d0
--- /dev/null
@@ -0,0 +1,26 @@
+#!/bin/bash
+############################################################################
+#                                                                          #
+# This file is part of the IPFire Firewall.                                #
+#                                                                          #
+# IPFire is free software; you can redistribute it and/or modify           #
+# it under the terms of the GNU General Public License as published by     #
+# the Free Software Foundation; either version 2 of the License, or        #
+# (at your option) any later version.                                      #
+#                                                                          #
+# IPFire is distributed in the hope that it will be useful,                #
+# but WITHOUT ANY WARRANTY; without even the implied warranty of           #
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            #
+# GNU General Public License for more details.                             #
+#                                                                          #
+# You should have received a copy of the GNU General Public License        #
+# along with IPFire; if not, write to the Free Software                    #
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA #
+#                                                                          #
+# Copyright (C) 2007 IPFire-Team <info@ipfire.org>.                        #
+#                                                                          #
+############################################################################
+#
+. /opt/pakfire/lib/functions.sh
+./uninstall.sh
+./install.sh