From bd26bff8250a70e3532218bb1f59157d6bbc86f2 Mon Sep 17 00:00:00 2001 From: Trevor Batley Date: Sat, 7 Sep 2024 20:10:36 +1000 Subject: [PATCH] initial commit of file from CVS for smeserver-bandwidthd on Sat Sep 7 20:10:36 AEST 2024 --- .gitignore | 4 + Makefile | 21 +++ README.md | 17 ++- contriborbase | 1 + createlinks | 59 ++++++++ root/etc/cron.d/bandwidthd_mysql_purge | 1 + root/etc/cron.d/bandwidthd_rotate | 1 + .../db/accounts/defaults/bandwidthd/type | 1 + .../configuration/defaults/bandwidthd/DbName | 1 + .../configuration/defaults/bandwidthd/DbUser | 1 + .../db/configuration/defaults/bandwidthd/Name | 1 + .../configuration/defaults/bandwidthd/status | 1 + .../db/configuration/defaults/bandwidthd/type | 1 + .../defaults/bandwidthd/webaccess | 1 + .../db/configuration/migrate/80bandwidthd | 16 +++ .../e-smith/events/actions/bandwidthd-enable | 2 + .../e-smith/events/actions/bandwidthd-start | 2 + .../templates.metadata/etc/bandwidthd.conf | 3 + .../etc/e-smith/sql/init/80bandwidthd | 1 + .../var/www/bandwidthd/phphtdocs/config.conf | 3 + .../templates/etc/bandwidthd.conf/05header | 7 + .../templates/etc/bandwidthd.conf/07subnet | 73 ++++++++++ .../templates/etc/bandwidthd.conf/08device | 11 ++ .../templates/etc/bandwidthd.conf/09options | 72 ++++++++++ .../etc/bandwidthd.conf/10sensorName | 8 ++ .../templates/etc/bandwidthd.conf/15DBtype | 7 + .../templates/etc/bandwidthd.conf/17pgsql | 15 +++ .../templates/etc/bandwidthd.conf/20mysql | 12 ++ .../etc/e-smith/sql/init/80bandwidthd | 21 +++ .../etc/httpd/conf/httpd.conf/86bandwidthd | 117 ++++++++++++++++ .../conf/httpd.conf/VirtualHosts/80bandwidthd | 16 +++ .../49-koozali.preset/06bandwidthd | 1 + .../bandwidthd/phphtdocs/config.conf/20config | 45 +++++++ root/etc/e-smith/web/functions/bandwidthd | 31 +++++ .../bandwidthd.service.d/50koozali.conf | 8 ++ smeserver-bandwidthd.spec | 127 ++++++++++++++++++ 36 files changed, 707 insertions(+), 2 deletions(-) create mode 100644 .gitignore create mode 100644 Makefile create mode 100644 contriborbase create mode 100644 createlinks create mode 100644 root/etc/cron.d/bandwidthd_mysql_purge create mode 100644 root/etc/cron.d/bandwidthd_rotate create mode 100644 root/etc/e-smith/db/accounts/defaults/bandwidthd/type create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/DbName create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/DbUser create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/Name create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/status create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/type create mode 100644 root/etc/e-smith/db/configuration/defaults/bandwidthd/webaccess create mode 100644 root/etc/e-smith/db/configuration/migrate/80bandwidthd create mode 100644 root/etc/e-smith/events/actions/bandwidthd-enable create mode 100644 root/etc/e-smith/events/actions/bandwidthd-start create mode 100644 root/etc/e-smith/templates.metadata/etc/bandwidthd.conf create mode 100644 root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/80bandwidthd create mode 100644 root/etc/e-smith/templates.metadata/var/www/bandwidthd/phphtdocs/config.conf create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/05header create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/07subnet create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/08device create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/09options create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/10sensorName create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/15DBtype create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/17pgsql create mode 100644 root/etc/e-smith/templates/etc/bandwidthd.conf/20mysql create mode 100644 root/etc/e-smith/templates/etc/e-smith/sql/init/80bandwidthd create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/86bandwidthd create mode 100644 root/etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/80bandwidthd create mode 100644 root/etc/e-smith/templates/etc/systemd/system-preset/49-koozali.preset/06bandwidthd create mode 100644 root/etc/e-smith/templates/var/www/bandwidthd/phphtdocs/config.conf/20config create mode 100644 root/etc/e-smith/web/functions/bandwidthd create mode 100644 root/usr/lib/systemd/system/bandwidthd.service.d/50koozali.conf create mode 100644 smeserver-bandwidthd.spec diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..cbb3a13 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.rpm +*.log +*spec-20* +*.tar.gz diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c370b1a --- /dev/null +++ b/Makefile @@ -0,0 +1,21 @@ +# Makefile for source rpm: smeserver-bandwidthd +# $Id: Makefile,v 1.1 2020/10/20 11:11:11 brianr Exp $ +NAME := smeserver-bandwidthd +SPECFILE = $(firstword $(wildcard *.spec)) + +define find-makefile-common +for d in common ../common ../../common ; do if [ -f $$d/Makefile.common ] ; then if [ -f $$d/CVS/Root -a -w $$/Makefile.common ] ; then cd $$d ; cvs -Q update ; fi ; echo "$$d/Makefile.common" ; break ; fi ; done +endef + +MAKEFILE_COMMON := $(shell $(find-makefile-common)) + +ifeq ($(MAKEFILE_COMMON),) +# attept a checkout +define checkout-makefile-common +test -f CVS/Root && { cvs -Q -d $$(cat CVS/Root) checkout common && echo "common/Makefile.common" ; } || { echo "ERROR: I can't figure out how to checkout the 'common' module." ; exit -1 ; } >&2 +endef + +MAKEFILE_COMMON := $(shell $(checkout-makefile-common)) +endif + +include $(MAKEFILE_COMMON) diff --git a/README.md b/README.md index ec53783..40d854e 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,16 @@ -# smeserver-bandwidthd +# smeserver-bandwidthd -SMEServer Koozali developed git repo for smeserver-bandwidthd smecontribs \ No newline at end of file +SMEServer Koozali developed git repo for smeserver-bandwidthd smecontribs + +## Wiki +
https://wiki.koozali.org/Bandwidthd +
https://wiki.koozali.org/Bandwidthd/fr + +## Bugzilla +Show list of outstanding bugs: [here](https://bugs.koozali.org/buglist.cgi?component=smeserver-bandwidthd&product=SME%20Contribs&query_format=advanced&limit=0&bug_status=UNCONFIRMED&bug_status=NEW&bug_status=ASSIGNED&bug_status=REOPENED&bug_status=CONFIRMED) + +## Description + +
*This description has been generated by an LLM AI system and cannot be relied on to be fully correct.* +*Once it has been checked, then this comment will be deleted* +
diff --git a/contriborbase b/contriborbase new file mode 100644 index 0000000..9b7fd51 --- /dev/null +++ b/contriborbase @@ -0,0 +1 @@ +contribs10 diff --git a/createlinks b/createlinks new file mode 100644 index 0000000..a17271d --- /dev/null +++ b/createlinks @@ -0,0 +1,59 @@ +#! /usr/bin/perl -w + +use esmith::Build::CreateLinks qw(:all); + +#################### +# links to add + +# templates to expand + templates2events("/etc/e-smith/sql/init/80bandwidthd", qw( conf-bandwidthd bootstrap-console-save post-upgrade)); + templates2events("/etc/bandwidthd.conf", qw( conf-bandwidthd bootstrap-console-save post-upgrade)); + templates2events("/var/www/bandwidthd/phphtdocs/config.conf", qw( conf-bandwidthd bootstrap-console-save post-upgrade)); + templates2events("/etc/httpd/conf/httpd.conf", qw( conf-bandwidthd )); + +# services to launch on event + safe_symlink("restart", "root/etc/e-smith/events/conf-bandwidthd/services2adjust/bandwidthd"); + safe_symlink("restart", "root/etc/e-smith/events/conf-bandwidthd/services2adjust/httpd-e-smith"); + safe_symlink("restart", "root/etc/e-smith/events/conf-bandwidthd/services2adjust/mysql.init"); + safe_symlink("reload-or-restart", "root/etc/e-smith/events/conf-bandwidthd/services2adjust/php74-php-fpm"); + +safe_symlink("/etc/e-smith/templates-default/template-begin-php", "root/etc/e-smith/templates/var/www/bandwidthd/phphtdocs/config.conf/template-begin"); +safe_symlink("/etc/e-smith/templates-default/template-end-php", "root/etc/e-smith/templates/var/www/bandwidthd/phphtdocs/config.conf/template-end"); + +#Server manager link +#safe_symlink("../../../functions/wrapper", "root/etc/e-smith/web/panels/manager/cgi-bin/bandwidthd"); +panel_link("bandwidthd","manager"); + +# our event specific for updating with yum without reboot +$event = "smeserver-bandwidthd-update"; +#add here the path to your templates needed to expand +#see the /etc/systemd/system-preset/49-koozali.preset should be present for systemd integration on all you yum update event + +foreach my $file (qw( + /etc/systemd/system-preset/49-koozali.preset + /etc/e-smith/sql/init/80bandwidthd + /etc/bandwidthd.conf + /var/www/bandwidthd/phphtdocs/config.conf + /etc/httpd/conf/httpd.conf +)) +{ + templates2events( $file, $event ); +} + +#action needed in case we have a systemd unit +event_link("systemd-default", $event, "10"); +event_link("systemd-reload", $event, "50"); + +#action specific to this package +#event_link("conf-timezone", $event, "30"); +#services we need to restart +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/bandwidthd"); +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/httpd-e-smith"); +safe_symlink("restart", "root/etc/e-smith/events/$event/services2adjust/mysql.init"); +safe_symlink("reload-or-restart", "root/etc/e-smith/events/$event/services2adjust/php74-php-fpm"); + + +use esmith::Build::Backup qw(:all); +backup_includes("smeserver-bandwidthd", qw( +/var/www/bandwidthd/ +)); diff --git a/root/etc/cron.d/bandwidthd_mysql_purge b/root/etc/cron.d/bandwidthd_mysql_purge new file mode 100644 index 0000000..92db778 --- /dev/null +++ b/root/etc/cron.d/bandwidthd_mysql_purge @@ -0,0 +1 @@ +5 5 * * 4 root /bin/sh /usr/share/doc/bandwidthd-2.0.1.1/phphtdocs/bd_mysql_purge.sh |mysql `/sbin/e-smith/db configuration getprop bandwidthd DbName`|grep -vE '(Msg_text|already up to date|status.*OK)' diff --git a/root/etc/cron.d/bandwidthd_rotate b/root/etc/cron.d/bandwidthd_rotate new file mode 100644 index 0000000..5f9b2e4 --- /dev/null +++ b/root/etc/cron.d/bandwidthd_rotate @@ -0,0 +1 @@ +0 0 * * * root /bin/kill -HUP `cat /var/run/bandwidthd.pid` diff --git a/root/etc/e-smith/db/accounts/defaults/bandwidthd/type b/root/etc/e-smith/db/accounts/defaults/bandwidthd/type new file mode 100644 index 0000000..4aa6664 --- /dev/null +++ b/root/etc/e-smith/db/accounts/defaults/bandwidthd/type @@ -0,0 +1 @@ +reserved \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbName b/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbName new file mode 100644 index 0000000..55d39f6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbName @@ -0,0 +1 @@ +bandwidthd \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbUser b/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbUser new file mode 100644 index 0000000..55d39f6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/DbUser @@ -0,0 +1 @@ +bandwidthd \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/Name b/root/etc/e-smith/db/configuration/defaults/bandwidthd/Name new file mode 100644 index 0000000..55d39f6 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/Name @@ -0,0 +1 @@ +bandwidthd \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/status b/root/etc/e-smith/db/configuration/defaults/bandwidthd/status new file mode 100644 index 0000000..26ed6c9 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/status @@ -0,0 +1 @@ +enabled \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/type b/root/etc/e-smith/db/configuration/defaults/bandwidthd/type new file mode 100644 index 0000000..ce93fac --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/type @@ -0,0 +1 @@ +service \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/defaults/bandwidthd/webaccess b/root/etc/e-smith/db/configuration/defaults/bandwidthd/webaccess new file mode 100644 index 0000000..c8c6761 --- /dev/null +++ b/root/etc/e-smith/db/configuration/defaults/bandwidthd/webaccess @@ -0,0 +1 @@ +private \ No newline at end of file diff --git a/root/etc/e-smith/db/configuration/migrate/80bandwidthd b/root/etc/e-smith/db/configuration/migrate/80bandwidthd new file mode 100644 index 0000000..a209018 --- /dev/null +++ b/root/etc/e-smith/db/configuration/migrate/80bandwidthd @@ -0,0 +1,16 @@ +{ + use MIME::Base64 qw(encode_base64); + + my $rec = $DB->get('bandwidthd') || $DB->new_record('bandwidthd', {type => 'service'}); + + if (my $grapCutofff = $DB->get_prop_and_delete('bandwidthd', 'grapCutofff')) { + $rec->merge_props('grapCutoff', $grapCutofff); + } + + + my $pw = $rec->prop('DbPassword'); + return "" if $pw; + $pw = MIME::Base64::encode(int( (1000000000000000) * rand() )); + chomp($pw); + $rec->set_prop('DbPassword', "$pw" ); +} diff --git a/root/etc/e-smith/events/actions/bandwidthd-enable b/root/etc/e-smith/events/actions/bandwidthd-enable new file mode 100644 index 0000000..1065a18 --- /dev/null +++ b/root/etc/e-smith/events/actions/bandwidthd-enable @@ -0,0 +1,2 @@ +#/bin/sh +systemctl enable bandwidthd.service diff --git a/root/etc/e-smith/events/actions/bandwidthd-start b/root/etc/e-smith/events/actions/bandwidthd-start new file mode 100644 index 0000000..7066606 --- /dev/null +++ b/root/etc/e-smith/events/actions/bandwidthd-start @@ -0,0 +1,2 @@ +#!/bin/sh +systemctl start bandwidthd.service diff --git a/root/etc/e-smith/templates.metadata/etc/bandwidthd.conf b/root/etc/e-smith/templates.metadata/etc/bandwidthd.conf new file mode 100644 index 0000000..28fe368 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/bandwidthd.conf @@ -0,0 +1,3 @@ +PERMS="0640" +UID="root" +GID="www" diff --git a/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/80bandwidthd b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/80bandwidthd new file mode 100644 index 0000000..52d0ffa --- /dev/null +++ b/root/etc/e-smith/templates.metadata/etc/e-smith/sql/init/80bandwidthd @@ -0,0 +1 @@ +PERMS=0750 \ No newline at end of file diff --git a/root/etc/e-smith/templates.metadata/var/www/bandwidthd/phphtdocs/config.conf b/root/etc/e-smith/templates.metadata/var/www/bandwidthd/phphtdocs/config.conf new file mode 100644 index 0000000..aa3a0c3 --- /dev/null +++ b/root/etc/e-smith/templates.metadata/var/www/bandwidthd/phphtdocs/config.conf @@ -0,0 +1,3 @@ +PERMS="0640" +UID="admin" +GID="www" diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/05header b/root/etc/e-smith/templates/etc/bandwidthd.conf/05header new file mode 100644 index 0000000..a10c55b --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/05header @@ -0,0 +1,7 @@ +#################################################### +# Bandwidthd.conf +# +# Commented out options are here to provide +# documentation and represent defaults + + diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/07subnet b/root/etc/e-smith/templates/etc/bandwidthd.conf/07subnet new file mode 100644 index 0000000..a217f54 --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/07subnet @@ -0,0 +1,73 @@ +# Subnets to collect statistics on. Traffic that +# matches none of these subnets will be ignored. +# Syntax is either IP Subnet Mask or CIDR +{ +# here we add list of local networks + use esmith::NetworksDB; + + my $ndb = esmith::NetworksDB->open_ro(); + + $localAccess = $ndb->local_access_spec(); + $localAccess =~ s/ /,/g; + $localAccess =~ s:/: :g; + my @LocalAccess = split(/,/, $localAccess); + + foreach $rec (@LocalAccess) + { + next if $rec eq "127.0.0.1"; + $rec= ($rec=~ /[.\d]+ [.\d]+/ )? $rec : "$rec 255.255.255.255"; + $OUT .= "subnet $rec \n"; + } + + #$OUT .= "subnet $localAccess \n"; + +# subnet for external access + + my $validFrom = ${'httpd-admin'}{'ValidFrom'} || "disabled"; + if ($validFrom ne "disabled") + { + #$validFrom =~ s/,/ /g; + $validFrom =~ s:/: :g; + #$externalSSLAccess = $validFrom; + my @externalSSLAccess = split(/,/, $validFrom); + + foreach $rec (@externalSSLAccess) + { + $OUT .= "subnet $rec \n"; + + } + + } + + +# subnet of external interface + + my $externalNet = ${'ExternalInterface'}{'IPAddress'}; + if (defined $externalNet ) + { + #$externalNet =~ s/[0-9]+$)/0/g; + $OUT .= "subnet ". ${'ExternalInterface'}{'IPAddress'} ." ". ${'ExternalInterface'}{'Netmask'} ." \n"; + } + +# subnet of adsl peer if(bandwidthd=service|remotePeers|enabled) + + +# also manually added (bandwidthd=service|subnet|172.16.0.0/12,192.168.0.0/16) + my $subnet = $bandwidthd{'subnet'} || "disabled"; + if ($subnet ne "disabled") + { + #$validFrom =~ s/,/ /g; + #$subnet =~ s:/: :g;# here we ask to have a syntax with /24 so keeping the / + #$externalSSLAccess = $validFrom; + @externalSSLAccess = split(/,/, $subnet); + + foreach $rec (@externalSSLAccess) + { + $OUT .= "subnet $rec \n"; + + } + + } + + +} diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/08device b/root/etc/e-smith/templates/etc/bandwidthd.conf/08device new file mode 100644 index 0000000..0646e84 --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/08device @@ -0,0 +1,11 @@ + +# Device to listen on +# Bandwidthd listens on the first device it detects +# by default. Run "bandwidthd -l" for a list of +# devices. +#dev "eth0" +{ +# dev "any" unless $device + my $device = $bandwidthd{'device'} ||"any"; + $OUT .= "dev \"$device\"\n"; +} diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/09options b/root/etc/e-smith/templates/etc/bandwidthd.conf/09options new file mode 100644 index 0000000..874f701 --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/09options @@ -0,0 +1,72 @@ +################################################### +# Options that don't usually get changed + +# An interval is 2.5 minutes, this is how many +# intervals to skip before doing a graphing run +#skip_intervals 0 +{ + my $interval = $bandwidthd{'skipInterval'} || "0"; + $OUT .= "skip_intervals $interval\n" + +} + +# Graph cutoff is how many k must be transfered by an +# ip before we bother to graph it +#graph_cutoff 1024 +{ + my $cutoff = $bandwidthd{'grapCutoff'} || "1024"; + $OUT .= "graph_cutoff $cutoff\n" + +} + +#Put interface in promiscuous mode to score to traffic +#that may not be routing through the host machine. +#promiscuous true +{ + my $promiscuous = $bandwidthd{'promiscuous'} || "false"; + $OUT .= "promiscuous $promiscuous\n" + +} + +#Log data to cdf file htdocs/log.cdf +#output_cdf false +{ + my $output_cdf = $bandwidthd{'output_cdf'} || "false"; + $OUT .= "output_cdf $output_cdf\n" + +} + +#Read back the cdf file on startup +#recover_cdf false +{ + my $recover_cdf = $bandwidthd{'recover_cdf'} || "false"; + $OUT .= "recover_cdf $recover_cdf\n" + +} + +#Libpcap format filter string used to control what bandwidthd see's +#Please always include "ip" in the string to avoid strange problems +#filter "ip" + +### use a template custom for this one ! + +#Draw Graphs - This default to true to graph the traffic bandwidthd is recording +#Usually set this to false if you only want cdf output or +#you are using the database output option. Bandwidthd will use very little +#ram and cpu if this is set to false. +#graph true +{ + my $graph = $bandwidthd{'graph'} || "true"; + $OUT .= "graph $graph\n" + +} + + +#Set META REFRESH seconds (default 150, use 0 to disable). +#meta_refresh 150 +{ + my $meta_refresh = $bandwidthd{'meta_refresh'} || "150"; + $OUT .= "meta_refresh $meta_refresh\n" + +} + diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/10sensorName b/root/etc/e-smith/templates/etc/bandwidthd.conf/10sensorName new file mode 100644 index 0000000..fa45f9d --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/10sensorName @@ -0,0 +1,8 @@ +# Arbitrary sensor name, I recommend the sensors fully qualified domain +# name +#sensor_id "sensor1" +{ + my $sensorname = "$SystemName.$DomainName"; + my $sensorid = $bandwidthd{'sensor'} || $sensorname ; + $OUT .= "sensor_id \"$sensorid\"\n"; +} diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/15DBtype b/root/etc/e-smith/templates/etc/bandwidthd.conf/15DBtype new file mode 100644 index 0000000..ab1b48c --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/15DBtype @@ -0,0 +1,7 @@ +# Database type, possible values, pgsql, mysql or none +#output_database mysql +{ + my $dbtype = $bandwidthd{'DbType'} || "mysql"; + $OUT .= "output_database $dbtype\n"; + +} diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/17pgsql b/root/etc/e-smith/templates/etc/bandwidthd.conf/17pgsql new file mode 100644 index 0000000..bd43b00 --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/17pgsql @@ -0,0 +1,15 @@ +# PostgreSQL +# Standard postgres connect string, just like php, see postgres docs for +# details +#pgsql_connect_string "user = someuser dbname = mydb host = databaseserver.com" + +{ + $OUT .="\n"; + my $dbtype = $bandwidthd{'DbType'} || "mysql"; + my $dbhost = $bandwidthd{'Dbhost'} || "localhost"; + + $OUT .= "pgsql_connect_string \"user = ".$bandwidthd{'DbUser'}." password = ". $bandwidthd{'DbPassword'} ." dbname = ".$bandwidthd{'DbName'}." host = $dbhost\";\n" +unless $dbtype eq "mysql"; + +} + diff --git a/root/etc/e-smith/templates/etc/bandwidthd.conf/20mysql b/root/etc/e-smith/templates/etc/bandwidthd.conf/20mysql new file mode 100644 index 0000000..2fd7d94 --- /dev/null +++ b/root/etc/e-smith/templates/etc/bandwidthd.conf/20mysql @@ -0,0 +1,12 @@ +# SME Server Settings MYSQL DB +# MySQL +{ +my $dbhost = $bandwidthd{'Dbhost'} || "localhost"; +my $dbport = $bandwidthd{'Dbport'} || "0"; + $OUT .= "mysql_host \"". $dbhost ."\"\n"; + $OUT .= "mysql_dbname \"". $bandwidthd{'DbName'} ."\"\n"; + $OUT .= "mysql_user \"". $bandwidthd{'DbUser'} ."\"\n"; + $OUT .= "mysql_pass \"". $bandwidthd{'DbPassword'} ."\"\n"; + $OUT .= "# Port 0 means, that the default port is used\n"; + $OUT .= "mysql_port ". $dbport ."\n"; +} diff --git a/root/etc/e-smith/templates/etc/e-smith/sql/init/80bandwidthd b/root/etc/e-smith/templates/etc/e-smith/sql/init/80bandwidthd new file mode 100644 index 0000000..950cbb4 --- /dev/null +++ b/root/etc/e-smith/templates/etc/e-smith/sql/init/80bandwidthd @@ -0,0 +1,21 @@ +{ + my $db = $bandwidthd{DbName} || 'bandwidthd'; + my $user = $bandwidthd{DbUser} || 'bandwidthd'; + my $pass = $bandwidthd{DbPassword} || 'changemebandwidthd'; + $OUT .= <default_dtd('-//W3C//DTD XHTML 1.0 Transitional//EN'); + +print $q->header ('text/html'); +print $q->start_html (-head=>meta({-http_equiv=>'refresh', -content=>$content})); + + + +print $q->end_html; + diff --git a/root/usr/lib/systemd/system/bandwidthd.service.d/50koozali.conf b/root/usr/lib/systemd/system/bandwidthd.service.d/50koozali.conf new file mode 100644 index 0000000..8ff98d3 --- /dev/null +++ b/root/usr/lib/systemd/system/bandwidthd.service.d/50koozali.conf @@ -0,0 +1,8 @@ +[Unit] +After=wan.service +After=networking.service +[Service] +ExecStartPre=-/sbin/e-smith/expand-template /etc/bandwidthd.conf +[Install] +WantedBy=sme-server.target + diff --git a/smeserver-bandwidthd.spec b/smeserver-bandwidthd.spec new file mode 100644 index 0000000..cbf2226 --- /dev/null +++ b/smeserver-bandwidthd.spec @@ -0,0 +1,127 @@ +%define name smeserver-bandwidthd +%define version 2.0.1.2 +%define release 19 +Summary: bandwidthd is a helpdesk system +Name: %{name} +Version: %{version} +Release: %{release}%{?dist} +Distribution: SME Server +License: GNU GPL version 2 +Group: SMEserver/addon +Source: smeserver-bandwidthd-%{version}.tar.xz + +BuildArchitectures: noarch +BuildRoot: /var/tmp/%{name}-%{version}-buildroot +BuildRequires: e-smith-devtools +Requires: e-smith-release >= 10.0 +Requires: e-smith-apache >= 2.6.0-19 +Requires: bandwidthd +AutoReqProv: no + +%description +bandwidthd is an application adapted as a contrib for SMEserver + +%changelog +* Sat Sep 07 2024 cvs2git.sh aka Brian Read 2.0.1.2-19.sme +- Roll up patches and move to git repo [SME: 12338] + +* Sat Sep 07 2024 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Tue May 28 2024 Jean-Philippe Pialasse 2.0.1.2-18.sme +- expand config and restart on ip-up event [SME: 12697] + also add external Gateway to monitor + +* Tue Dec 27 2022 Jean-Philippe Pialasse 2.0.1.2-17.sme +- fix Can't modify constant item in scalar assignment [SME: 12292] + +* Fri Dec 02 2022 Jean-Philippe Pialasse 2.0.1.2-16.sme +- fix preset disabled [SME: 12251] + +* Sat Jul 30 2022 Brian Read 2.0.1.2-15.sme +- Re-build and link to latest devtools [SME: 11997] + +* Mon Jul 25 2022 Jean-Philippe Pialasse 2.0.1.2-14.sme +- add to core backup [SME: 11046] +- access syntax for httpd 2.4 [SME: 12037] + +* Wed Jun 29 2022 Jean-Philippe Pialasse 2.0.1.2-13.sme +- Re-build and link to latest devtools typo for grapCutofff [SME: 11046] +- /etc/bandwidthd.conf to 0664 [SME: 11046] + +* Sun Jun 06 2021 Jean-Philippe Pialasse 2.0.1.2-12.sme +- add php74-php-fpm reload-or-restart [SME: 11046] + +* Tue Feb 02 2021 Brian Read 2.0.1.2-11.sme +- Update-Creatlinks-with-systemd-stuff [SME: 11046] + +* Tue Feb 02 2021 BogusDateBot +- Eliminated rpmbuild "bogus date" warnings due to inconsistent weekday, + by assuming the date is correct and changing the weekday. + +* Mon Nov 30 2020 Brian Read 2.0.1.2-10.sme +- Set $version in httpd.conf [SME: 11046] + +* Fri Nov 27 2020 Brian Read 2.0.1.2-9.sme +- Update createlinks for systemd startup [SME: 11046] +- Update httpd with extra loadmodules + +* Tue Oct 20 2020 Brian Read 2.0.1.2-8.sme +- Initial import into SME10 tree- [SME: 11046] +- Add in link to createlinks to wrapper for Server Manager panel +- Fix up httpd.conf template to call php-fwp + +* Sat Dec 17 2016 Jean-Philipe Pialasse 2.0.1.2-7.sme +- Re-build and link to latest devtools [SME: 11997] + +* Thu Dec 15 2016 Jean-Philipe Pialasse 2.0.1.2-6.sme +- Re-build and link to latest devtools one more time too verbose cronjob and unique IP networks [SME: 8536] + +* Tue Nov 10 2015 JP Pialasse 2.0.1.2-5.sme + Mon Nov 10 2015 --> Mon Nov 09 2015 or Tue Nov 10 2015 or Mon Nov 16 2015 or .... +- Re-build and link to latest devtoolsed cron too verbose [SME: 8536] +- Re-build and link to latest devtoolsed wont restart with single IP network [SME: 8524] + +* Sat Sep 26 2015 stephane de Labrusse 2.0.1.2-2.sme +- removed typo [SME: 8116] +- Added smeserver-bandwidthd-2.0.1.2.cronmysql.patch + +* Mon Jun 16 2014 JP Pialasse 2.0.1.2-1.sme +- initial import to SME9 contribs + +* Mon Dec 30 2013 JP Pialasse 2.0.1.1-6.sme +- add require SSL [SME: 8099] + +* Sun Dec 29 2013 JP Pialasse 2.0.1.1-4.sme +- Re-build and link to latest devtools missing mysql.init +- Re-build and link to latest devtools http auth error + +* Fri Dec 27 2013 JP Pialasse 2.0.1.1-2.sme +- few enhancement and bug fixing +- added link in manager + +* Thu Dec 26 2013 CONTRIB MAKER 2.0.1.1-1.sme +- initial release +- builds from unchanged .tar.gz + +%prep +%setup + +%build +perl createlinks + +%install +rm -rf $RPM_BUILD_ROOT +(cd root ; find . -depth -print | cpio -dump $RPM_BUILD_ROOT) +rm -f %{name}-%{version}-filelist +/sbin/e-smith/genfilelist $RPM_BUILD_ROOT \ + > %{name}-%{version}-filelist + +%clean +rm -rf $RPM_BUILD_ROOT + +%files -f %{name}-%{version}-filelist +%defattr(-,root,root) + +