summarylogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.SRCINFO44
-rw-r--r--01-bandwidthd-recover-cdf.patch16
-rw-r--r--02-bandwidthd-missing-comma.patch12
-rw-r--r--03-bandwidthd-subnet-reporting.patch17
-rw-r--r--04-bandwidthd-misc.patch107
-rw-r--r--05-bandwidthd-pidfile.patch40
-rw-r--r--PKGBUILD97
-rw-r--r--bandwidthd-rotate.service7
-rw-r--r--bandwidthd-rotate.timer10
-rw-r--r--bandwidthd-webui.conf36
-rw-r--r--bandwidthd-webui.service15
-rw-r--r--bandwidthd.service14
-rw-r--r--bandwidthd.sysusers1
-rw-r--r--bandwidthd.tmpfiles4
14 files changed, 420 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 000000000000..8ad77f6975b9
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,44 @@
+pkgbase = bandwidthd
+ pkgdesc = Daemon for graphing traffic of subnet machines
+ pkgver = 2.0.2.r1.0307fbba56
+ pkgrel = 4
+ epoch = 1
+ url = https://github.com/neatbasis/bandwidthd
+ arch = x86_64
+ license = GPL
+ depends = sqlite
+ depends = libpcap
+ depends = libpng
+ depends = gd
+ depends = nginx
+ backup = etc/bandwidthd/bandwidthd.conf
+ backup = etc/bandwidthd/bandwidthd-webui.conf
+ source = bandwidthd-2.0.2.r1.0307fbba56.tar.gz::https://github.com/neatbasis/bandwidthd/archive/0307fbba56a39a6e65ebadf488ad87979c64fdef.tar.gz
+ source = 01-bandwidthd-recover-cdf.patch
+ source = 02-bandwidthd-missing-comma.patch
+ source = 03-bandwidthd-subnet-reporting.patch
+ source = 04-bandwidthd-misc.patch
+ source = 05-bandwidthd-pidfile.patch
+ source = bandwidthd.service
+ source = bandwidthd-webui.service
+ source = bandwidthd-webui.conf
+ source = bandwidthd-rotate.timer
+ source = bandwidthd-rotate.service
+ source = bandwidthd.sysusers
+ source = bandwidthd.tmpfiles
+ sha256sums = 7e8ebf7e2eeb5266af904a8f7188b11d5a13ebb0343022c2a118b86f48a952e4
+ sha256sums = b679dbd2fcc4ac8246c75cab0a5f0db86c00d2083c3b202e7fafb339114c971f
+ sha256sums = 641c006a8b90e9548a1b2ea3e40326a2128df69d490a13173e61469543b20352
+ sha256sums = 88c38a18b7bda6f3496dda3030ba118f8c461447dea426c13245099ae37a6d86
+ sha256sums = be5fa230311258f14d4af6a00496443bfbc1a148a77f237bb4a0b663947e090a
+ sha256sums = fc38a5623e66d82dec2efd28d2729e76e8f3b6056fb2bc2462a1ea1549f68807
+ sha256sums = f3a9ade36279f86e897d3842a8cb22a5a56db419b12f1689557b2d03ea765e58
+ sha256sums = ab93801ae0b05129aaf62a49c065fdb62b7ae16d88d8b956164c2f416df5da81
+ sha256sums = 08f360c4ee926bd28ee5f945e03aa8b2b96f299c2022e48dc9b3abf9be4ad7b9
+ sha256sums = 31780d5d9c67158277a0edeeb672c594af97f96678222107db47ab4b2ede43b2
+ sha256sums = 90e0fec629c87d2465ca311acedf0ca4ccf5d77ddf60a8db1f5095cc8c41a748
+ sha256sums = d734cea9710691a1658b9996e35cd407e85b542aa0961aec57fc49281516aa5d
+ sha256sums = 21886618648cbd5ac499328740e3d1185537d3ad81cfceeaeb3167c468fa4e41
+
+pkgname = bandwidthd
+
diff --git a/01-bandwidthd-recover-cdf.patch b/01-bandwidthd-recover-cdf.patch
new file mode 100644
index 000000000000..edfe3e7bd2ee
--- /dev/null
+++ b/01-bandwidthd-recover-cdf.patch
@@ -0,0 +1,16 @@
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c 2020-04-09 10:49:12.151941214 +0200
+@@ -1148,10 +1148,10 @@
+ ip->timestamp = timestamp;
+ if (fscanf(cdf, "%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,",
+ &ip->Send.total, &ip->Send.icmp, &ip->Send.udp,
+- &ip->Send.tcp, &ip->Send.ftp, &ip->Send.http, &ip->Send.mail, &ip->Send.p2p) != 7
++ &ip->Send.tcp, &ip->Send.ftp, &ip->Send.http, &ip->Send.mail, &ip->Send.p2p) != 8
+ || fscanf(cdf, "%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu",
+ &ip->Receive.total, &ip->Receive.icmp, &ip->Receive.udp,
+- &ip->Receive.tcp, &ip->Receive.ftp, &ip->Receive.http, &ip->Receive.mail, &ip->Receive.p2p) != 7)
++ &ip->Receive.tcp, &ip->Receive.ftp, &ip->Receive.http, &ip->Receive.mail, &ip->Receive.p2p) != 8)
+ goto End_RecoverDataFromCdf;
+ }
+ End_RecoverDataFromCdf:
diff --git a/02-bandwidthd-missing-comma.patch b/02-bandwidthd-missing-comma.patch
new file mode 100644
index 000000000000..934fba08d5a2
--- /dev/null
+++ b/02-bandwidthd-missing-comma.patch
@@ -0,0 +1,12 @@
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c 2020-04-09 10:58:06.145231013 +0200
+@@ -889,7 +889,7 @@
+ HostIp2CharIp(IPData->ip, IPBuffer);
+ fprintf(cdf, "%s,%lu,", IPBuffer, IPData->timestamp);
+ Stats = &(IPData->Send);
+- fprintf(cdf, "%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu", Stats->total, Stats->icmp, Stats->udp, Stats->tcp, Stats->ftp, Stats->http, Stats->mail, Stats->p2p);
++ fprintf(cdf, "%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu,", Stats->total, Stats->icmp, Stats->udp, Stats->tcp, Stats->ftp, Stats->http, Stats->mail, Stats->p2p);
+ Stats = &(IPData->Receive);
+ fprintf(cdf, "%llu,%llu,%llu,%llu,%llu,%llu,%llu,%llu\n", Stats->total, Stats->icmp, Stats->udp, Stats->tcp, Stats->ftp, Stats->http, Stats->mail, Stats->p2p);
+ }
diff --git a/03-bandwidthd-subnet-reporting.patch b/03-bandwidthd-subnet-reporting.patch
new file mode 100644
index 000000000000..4f1a15e98c8a
--- /dev/null
+++ b/03-bandwidthd-subnet-reporting.patch
@@ -0,0 +1,17 @@
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c 2020-04-09 11:13:08.489071600 +0200
+@@ -346,9 +346,12 @@
+ // Log list of monitored subnets
+ for (Counter = 0; Counter < SubnetCount; Counter++)
+ {
++ char subnet[16], mask[16];
+ addr.s_addr = ntohl(SubnetTable[Counter].ip);
+ addr2.s_addr = ntohl(SubnetTable[Counter].mask);
+- syslog(LOG_INFO, "Monitoring subnet %s with netmask %s", inet_ntoa(addr), inet_ntoa(addr2));
++ strncpy(subnet, inet_ntoa(addr), 16);
++ strncpy(mask, inet_ntoa(addr2), 16);
++ syslog(LOG_INFO, "Monitoring subnet %s with netmask %s", subnet, mask);
+ }
+ for (Counter = 0; Counter < NotSubnetCount; Counter++)
+ {
diff --git a/04-bandwidthd-misc.patch b/04-bandwidthd-misc.patch
new file mode 100644
index 000000000000..f830a1df01d5
--- /dev/null
+++ b/04-bandwidthd-misc.patch
@@ -0,0 +1,107 @@
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c 2020-04-09 11:23:31.431948002 +0200
+@@ -120,6 +120,7 @@
+ int NumGraphs = 0;
+ pid_t graphpid;
+ int Counter;
++ int niceness __attribute__((unused));
+ /* Did we catch any packets since last time? */
+ if (!DataStore)
+ return -2;
+@@ -136,7 +137,7 @@
+ monstartup((u_long) &_start, (u_long) &etext);
+ #endif
+ signal(SIGHUP, SIG_IGN);
+- nice(4); // reduce priority so I don't choke out other tasks
++ niceness = nice(4); // reduce priority so I don't choke out other tasks
+ // Count Number of IP's in datastore
+ for (DataStore = IPDataStore, Counter = 0; DataStore; Counter++, DataStore = DataStore->Next);
+ // +1 because we don't want to accidently allocate 0
+@@ -256,6 +257,7 @@
+ int ForkBackground = TRUE;
+ int ListDevices = FALSE;
+ int Counter;
++ int niceness __attribute__((unused));
+ char *bd_conf = NULL;
+ struct in_addr addr, addr2;
+ signal(SIGHUP, SIG_IGN);
+@@ -480,7 +482,7 @@
+ // This is also set in CloseInterval because it gets overwritten in some commit modules
+ signal(SIGALRM, handle_interval);
+ alarm(config.interval);
+- nice(1);
++ niceness = nice(1);
+ while (1)
+ {
+ // Bookeeping
+@@ -610,7 +612,7 @@
+ int AlreadyTotaled = FALSE;
+ PacketCallbackLock = TRUE;
+ eptr = (struct ether_header *) p;
+- vlanhdr = (struct vlanhdr *) p;
++ vlanhdr = (struct VlanHeader *) p;
+ if (eptr->ether_type == htons(1537))
+ ParseBroadcast(p);
+ if (vlanhdr->ether_type[0]==0x81 && vlanhdr->ether_type[1]==0x00) //Two byte-wise checks instead of 1 word-wise check to avoid word boundary issues on some intel processors
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/graph.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/graph.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/graph.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/graph.c 2020-04-09 11:21:50.611498930 +0200
+@@ -387,7 +387,7 @@
+ FILE *OutputFile;
+ char filename[MAX_FILENAME];
+ gdImagePtr im, im2;
+- int white;
++ int white __attribute__((unused));
+ unsigned long long int YMax;
+ char CharIp[20];
+
+@@ -489,7 +489,9 @@
+ char Buffer2[50];
+
+ int blue, lblue, orange, red, yellow, purple, green, brown, black;
+- int blue2, lblue2, orange2, red2, yellow2, purple2, green2, brown2, black2;
++ int blue2, lblue2;
++ int orange2 __attribute__((unused));
++ int red2, yellow2, purple2, green2, brown2, black2;
+
+ unsigned long long int SentPeak = 0;
+ unsigned long long int ReceivedPeak = 0;
+@@ -802,7 +804,8 @@
+ {
+ char buffer[100];
+ int black, red;
+- time_t sample_begin, sample_end;
++ time_t sample_begin;
++ time_t sample_end __attribute__((unused));
+ struct tm *timestruct;
+ long int MarkTime;
+ long int MarkTimeStep;
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/pgsql.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/pgsql.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/pgsql.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/pgsql.c 2020-04-09 11:24:13.432131299 +0200
+@@ -471,10 +471,12 @@
+ }
+ #endif
+
++#ifdef HAVE_LIBPQ
+ static void pgsqllngjmp(int signal)
+ {
+ longjmp(pgsqljmp, 1);
+ }
++#endif
+
+ void pgsqlStoreIPData(struct IPData IncData[], struct extensions *extension_data)
+ {
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/sqlite.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/sqlite.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/sqlite.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/sqlite.c 2020-04-09 11:27:57.313078710 +0200
+@@ -250,7 +250,7 @@
+
+ time_t now;
+
+- if (!config.output_database == DB_SQLITE)
++ if (config.output_database != DB_SQLITE)
+ return;
+
+ // ************ Inititialize the db if it's not already
diff --git a/05-bandwidthd-pidfile.patch b/05-bandwidthd-pidfile.patch
new file mode 100644
index 000000000000..bc6afc751098
--- /dev/null
+++ b/05-bandwidthd-pidfile.patch
@@ -0,0 +1,40 @@
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/README.md bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/README.md
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/README.md 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/README.md 2020-04-09 13:41:44.713813385 +0200
+@@ -113,7 +113,7 @@
+ in it's directory. recover_cdf will cause Bandwidthd to load that file when
+ it starts. You will also want to make a crontab entry like so:
+
+-0 0 * * * * /bin/kill -HUP `cat /var/run/bandwidthd.pid`
++0 0 * * * * /bin/kill -HUP `cat /run/bandwidthd/bandwidthd.pid`
+
+ This will send Bandwidthd a HUP every night at midnight. When Bandwidthd
+ receives a HUP it schedules a rotation of it's log files during the next
+diff -u bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c
+--- bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef/bandwidthd.c 2019-03-27 20:05:31.000000000 +0100
++++ bandwidthd-0307fbba56a39a6e65ebadf488ad87979c64fdef~/bandwidthd.c 2020-04-09 13:41:49.993831659 +0200
+@@ -208,20 +208,20 @@
+ void makepidfile(pid_t pid)
+ {
+ FILE *pidfile;
+- pidfile = fopen("/var/run/bandwidthd.pid", "wt");
++ pidfile = fopen("/run/bandwidthd/bandwidthd.pid", "wt");
+ if (pidfile)
+ {
+ if (fprintf(pidfile, "%d\n", pid) == 0)
+ {
+- syslog(LOG_ERR, "Bandwidthd: failed to write '%d' to /var/run/bandwidthd.pid", pid);
++ syslog(LOG_ERR, "Bandwidthd: failed to write '%d' to /run/bandwidthd/bandwidthd.pid", pid);
+ fclose(pidfile);
+- unlink("/var/run/bandwidthd.pid");
++ unlink("/run/bandwidthd/bandwidthd.pid");
+ }
+ else
+ fclose(pidfile);
+ }
+ else
+- syslog(LOG_ERR, "Could not open /var/run/bandwidthd.pid for write");
++ syslog(LOG_ERR, "Could not open /run/bandwidthd/bandwidthd.pid for write");
+ }
+
+ void PrintHelp(void)
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 000000000000..fd595081f1bb
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,97 @@
+# Maintainer: Oleksandr Natalenko <oleksandr@natalenko.name>
+
+pkgname=bandwidthd
+_repouser=neatbasis
+_reponame=bandwidthd
+_rev=0307fbba56a39a6e65ebadf488ad87979c64fdef
+pkgver=2.0.2.r1.${_rev:0:10}
+pkgrel=4
+epoch=1
+pkgdesc="Daemon for graphing traffic of subnet machines"
+arch=(x86_64)
+url="https://github.com/neatbasis/bandwidthd"
+license=(GPL)
+depends=(sqlite libpcap libpng gd nginx)
+
+source=(${pkgname}-${pkgver}.tar.gz::https://github.com/${_repouser}/${_reponame}/archive/${_rev}.tar.gz
+ 01-bandwidthd-recover-cdf.patch
+ 02-bandwidthd-missing-comma.patch
+ 03-bandwidthd-subnet-reporting.patch
+ 04-bandwidthd-misc.patch
+ 05-bandwidthd-pidfile.patch
+ bandwidthd.service
+ bandwidthd-webui.service
+ bandwidthd-webui.conf
+ bandwidthd-rotate.timer
+ bandwidthd-rotate.service
+ bandwidthd.sysusers
+ bandwidthd.tmpfiles)
+
+sha256sums=('7e8ebf7e2eeb5266af904a8f7188b11d5a13ebb0343022c2a118b86f48a952e4'
+ 'b679dbd2fcc4ac8246c75cab0a5f0db86c00d2083c3b202e7fafb339114c971f'
+ '641c006a8b90e9548a1b2ea3e40326a2128df69d490a13173e61469543b20352'
+ '88c38a18b7bda6f3496dda3030ba118f8c461447dea426c13245099ae37a6d86'
+ 'be5fa230311258f14d4af6a00496443bfbc1a148a77f237bb4a0b663947e090a'
+ 'fc38a5623e66d82dec2efd28d2729e76e8f3b6056fb2bc2462a1ea1549f68807'
+ 'f3a9ade36279f86e897d3842a8cb22a5a56db419b12f1689557b2d03ea765e58'
+ 'ab93801ae0b05129aaf62a49c065fdb62b7ae16d88d8b956164c2f416df5da81'
+ '08f360c4ee926bd28ee5f945e03aa8b2b96f299c2022e48dc9b3abf9be4ad7b9'
+ '31780d5d9c67158277a0edeeb672c594af97f96678222107db47ab4b2ede43b2'
+ '90e0fec629c87d2465ca311acedf0ca4ccf5d77ddf60a8db1f5095cc8c41a748'
+ 'd734cea9710691a1658b9996e35cd407e85b542aa0961aec57fc49281516aa5d'
+ '21886618648cbd5ac499328740e3d1185537d3ad81cfceeaeb3167c468fa4e41')
+
+backup=('etc/bandwidthd/bandwidthd.conf'
+ 'etc/bandwidthd/bandwidthd-webui.conf')
+
+prepare () {
+ cd "${_reponame}-${_rev}"
+
+ patch -Np1 -i ../01-bandwidthd-recover-cdf.patch
+ patch -Np1 -i ../02-bandwidthd-missing-comma.patch
+ patch -Np1 -i ../03-bandwidthd-subnet-reporting.patch
+ patch -Np1 -i ../04-bandwidthd-misc.patch
+ patch -Np1 -i ../05-bandwidthd-pidfile.patch
+
+ sed -i 's|EXTRA_VERSION=".IPv6"|EXTRA_VERSION=".'${_rev:0:10}'"|' configure.in
+
+ sed -i 's|output_cdf false|output_cdf true|' etc/bandwidthd.conf
+ sed -i 's|recover_cdf false|recover_cdf true|' etc/bandwidthd.conf
+ sed -i 's|graph false|graph true|' etc/bandwidthd.conf
+
+ sed -i 's|#log_dir "/usr/local/var/bandwidthd"|log_dir "/var/lib/bandwidthd"|' etc/bandwidthd.conf
+ sed -i 's|#htdocs_dir "/usr/local/var/bandwidthd/htdocs"|htdocs_dir "/var/lib/bandwidthd/htdocs"|' etc/bandwidthd.conf
+
+ sed -i 's|pgsql_connect_string "dbname = bandwidthd password=kahlas12451 user = perkins host = localhost"|#pgsql_connect_string "dbname = bandwidthd password=kahlas12451 user = perkins host = localhost"|' etc/bandwidthd.conf
+ sed -i 's|#sqlite_filename "/var/bandwidthd.db"|sqlite_filename "/var/lib/bandwidthd/bandwidthd.db"|' etc/bandwidthd.conf
+
+ CFLAGS="-std=gnu89 -march=x86-64 -mtune=generic -O2 -pipe -fno-plt" ./configure \
+ --prefix=/usr \
+ --sysconfdir=/etc/bandwidthd \
+ --localstatedir=/var/lib \
+ --disable-python \
+ --disable-pgsql \
+ --without-x
+}
+
+build() {
+ cd "${_reponame}-${_rev}"
+
+ make -j1
+}
+
+package() {
+ cd "${_reponame}-${_rev}"
+
+ make DESTDIR="${pkgdir}" install
+
+ install -Dm644 "../bandwidthd.service" -t "${pkgdir}/usr/lib/systemd/system"
+ install -Dm644 "../bandwidthd-webui.service" -t "${pkgdir}/usr/lib/systemd/system"
+ install -Dm644 "../bandwidthd-webui.conf" -t "${pkgdir}/etc/bandwidthd"
+ install -Dm644 "../bandwidthd-rotate.timer" -t "${pkgdir}/usr/lib/systemd/system"
+ install -Dm644 "../bandwidthd-rotate.service" -t "${pkgdir}/usr/lib/systemd/system"
+ install -Dm644 "../bandwidthd.sysusers" "${pkgdir}/usr/lib/sysusers.d/bandwidthd.conf"
+ install -Dm644 "../bandwidthd.tmpfiles" "${pkgdir}/usr/lib/tmpfiles.d/bandwidthd.conf"
+}
+
+# vim: set tabstop=4:softtabstop=4:shiftwidth=4:noexpandtab
diff --git a/bandwidthd-rotate.service b/bandwidthd-rotate.service
new file mode 100644
index 000000000000..aea502296196
--- /dev/null
+++ b/bandwidthd-rotate.service
@@ -0,0 +1,7 @@
+[Unit]
+Description=Daemon for graphing traffic of subnet machines - Rotate
+
+[Service]
+User=bandwidthd
+Group=bandwidthd
+ExecStart=/usr/bin/bash -c '/usr/bin/kill -s HUP `cat /run/bandwidthd/bandwidthd.pid`'
diff --git a/bandwidthd-rotate.timer b/bandwidthd-rotate.timer
new file mode 100644
index 000000000000..ba338c07f46d
--- /dev/null
+++ b/bandwidthd-rotate.timer
@@ -0,0 +1,10 @@
+[Unit]
+Description=Daemon for graphing traffic of subnet machines - Rotate
+PartOf=bandwidthd.service
+After=bandwidthd.service
+
+[Timer]
+OnCalendar=*-*-* 00:00:00
+
+[Install]
+WantedBy=bandwidthd.service
diff --git a/bandwidthd-webui.conf b/bandwidthd-webui.conf
new file mode 100644
index 000000000000..4fb6ed8263ab
--- /dev/null
+++ b/bandwidthd-webui.conf
@@ -0,0 +1,36 @@
+daemon off;
+worker_processes auto;
+
+pid /run/bandwidthd/bandwidthd-webui.pid;
+
+error_log stderr;
+
+events {
+ worker_connections 1024;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ access_log off;
+
+ types_hash_max_size 4096;
+
+ sendfile on;
+ gzip on;
+
+ server {
+ listen 667;
+
+ root /var/lib/bandwidthd/htdocs;
+
+ location / {
+ index index.html;
+ }
+
+ location = /favicon.ico {
+ log_not_found off;
+ }
+ }
+}
diff --git a/bandwidthd-webui.service b/bandwidthd-webui.service
new file mode 100644
index 000000000000..b77740cdd931
--- /dev/null
+++ b/bandwidthd-webui.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Daemon for graphing traffic of subnet machines - Web UI
+PartOf=bandwidthd.service
+After=bandwidthd.service
+
+[Service]
+User=bandwidthd
+Group=bandwidthd
+CapabilityBoundingSet=CAP_NET_BIND_SERVICE
+AmbientCapabilities=CAP_NET_BIND_SERVICE
+ExecStart=/usr/bin/nginx -c /etc/bandwidthd/bandwidthd-webui.conf
+PIDFile=/run/bandwidthd/bandwidthd-webui.pid
+
+[Install]
+WantedBy=bandwidthd.service
diff --git a/bandwidthd.service b/bandwidthd.service
new file mode 100644
index 000000000000..b9bf7c9734b4
--- /dev/null
+++ b/bandwidthd.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Daemon for graphing traffic of subnet machines
+Requires=network-online.target
+
+[Service]
+User=bandwidthd
+Group=bandwidthd
+CapabilityBoundingSet=CAP_NET_RAW
+AmbientCapabilities=CAP_NET_RAW
+ExecStart=/usr/bin/bandwidthd -D -c /etc/bandwidthd/bandwidthd.conf
+PIDFile=/run/bandwidthd/bandwidthd.pid
+
+[Install]
+WantedBy=multi-user.target
diff --git a/bandwidthd.sysusers b/bandwidthd.sysusers
new file mode 100644
index 000000000000..20ff47332073
--- /dev/null
+++ b/bandwidthd.sysusers
@@ -0,0 +1 @@
+u bandwidthd - "bandwidthd user" /var/lib/bandwidthd -
diff --git a/bandwidthd.tmpfiles b/bandwidthd.tmpfiles
new file mode 100644
index 000000000000..8f846983a5b4
--- /dev/null
+++ b/bandwidthd.tmpfiles
@@ -0,0 +1,4 @@
+d /var/lib/bandwidthd 0755 bandwidthd bandwidthd -
+Z /var/lib/bandwidthd - bandwidthd bandwidthd -
+d /run/bandwidthd 0755 bandwidthd bandwidthd -
+Z /run/bandwidthd - bandwidthd bandwidthd -