diff options
Diffstat (limited to 'config/bandwidthd/bandwidthd.inc')
-rw-r--r-- | config/bandwidthd/bandwidthd.inc | 36 |
1 files changed, 28 insertions, 8 deletions
diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index 1220e033..7cdc8006 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -40,6 +40,10 @@ switch ($pfs_version) { } // End: Check pfSense version +function is_blank($value) { + return empty($value) && !is_numeric($value); +} + function bandwidthd_install_deinstall() { conf_mount_rw(); config_lock(); @@ -66,8 +70,11 @@ function bandwidthd_install_config() { /* user defined values */ $bandwidthd_config = $config['installedpackages']['bandwidthd']['config'][0]; $meta_refresh = $bandwidthd_config['meta_refresh']; - if ($meta_refresh) + if (is_numeric($meta_refresh)) $meta_refresh = "meta_refresh $meta_refresh\n"; + else + $meta_refresh = ""; + $graph = $bandwidthd_config['drawgraphs']; if ($graph) $graph = "graph true\n"; @@ -75,11 +82,17 @@ function bandwidthd_install_config() { $graph = "graph false\n"; $filter_text = $bandwidthd_config['filter']; - if ($filter_text) + if (!is_blank($filter_text)) $filter_text = "filter $filter_text\n"; + else + $filter_text = ""; + $recover_cdf = $bandwidthd_config['recovercdf']; if ($recover_cdf) $recover_cdf = "recover_cdf true\n"; + else + $recover_cdf = ""; + $output_cdf = $bandwidthd_config['outputcdf']; if ($output_cdf) $output_cdf_string = "output_cdf true\n"; @@ -93,15 +106,15 @@ function bandwidthd_install_config() { $postgresql_password = $bandwidthd_config['postgresqlpassword']; $postgresql_string = ""; if ($output_postgresql) { - if ($postgresql_host && $postgresql_username && $postgresql_database && $postgresql_password) + if (!is_blank($postgresql_host) && !is_blank($postgresql_username) && !is_blank($postgresql_database) && !is_blank($postgresql_password)) $postgresql_string = "pgsql_connect_string \"user = $postgresql_username dbname = $postgresql_database password = $postgresql_password host = $postgresql_host\"\n"; else - log_error("You have to specify the postgreSQL Host, Database, Username and Password. Exiting."); + log_error("bandwidthd: You have to specify the postgreSQL Host, Database, Username and Password. postgreSQL details have been ignored."); } $sensor_id = $bandwidthd_config['sensorid']; - if ($sensor_id) + if (!is_blank($sensor_id)) $sensor_id_string = "sensor_id \"$sensor_id\""; else $sensor_id_string = ""; @@ -113,13 +126,20 @@ function bandwidthd_install_config() { $promiscuous = "promiscuous false\n"; $graph_cutoff = $bandwidthd_config['graphcutoff']; - if ($graph_cutoff) + if (!is_blank($graph_cutoff)) $graph_cutoff = "graph_cutoff $graph_cutoff\n"; + else + $graph_cutoff = ""; + $skip_intervals = $bandwidthd_config['skipintervals']; - if ($skip_intervals) + if ($skip_intervals) { $skip_intervals = "skip_intervals $skip_intervals\n"; + } else { + /* Includes the case where 0 is explicitly specified, which is the default anyway. */ + $skip_intervals = ""; + } - if ($bandwidthd_config['active_interface']){ + if (!is_blank($bandwidthd_config['active_interface'])){ $ifdescrs = array($bandwidthd_config['active_interface']); } else { log_error("You should specify an interface for bandwidthd to listen on. Exiting."); |