diff options
author | phildd <ict.advisor@nepal.inf.org> | 2013-03-01 14:59:48 +0545 |
---|---|---|
committer | phildd <ict.advisor@nepal.inf.org> | 2013-03-01 14:59:48 +0545 |
commit | 65a36bbf84c3401bc79f49290493a0913fdb4936 (patch) | |
tree | e9e3be8ac84b8430217f22a704dd50db00ac72aa /config/bandwidthd | |
parent | 417cf9feaecf2bee6c93307056963de4cbde0325 (diff) | |
download | pfsense-packages-65a36bbf84c3401bc79f49290493a0913fdb4936.tar.gz pfsense-packages-65a36bbf84c3401bc79f49290493a0913fdb4936.tar.bz2 pfsense-packages-65a36bbf84c3401bc79f49290493a0913fdb4936.zip |
bandwidthd for nanobsd
Make bandwidth on nanobsd write graph files and cdf log files to /var/bandwidthd rw memory filesystem, so it can run with /usr mounted read-only
Diffstat (limited to 'config/bandwidthd')
-rw-r--r-- | config/bandwidthd/bandwidthd.inc | 55 |
1 files changed, 43 insertions, 12 deletions
diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index 34532c18..c0115d81 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -54,6 +54,8 @@ function bandwidthd_install_config() { global $config, $g; /* bandwidthd doesn't have a way to pass a custom config path, unfortunately */ + /* the conf file must be ./etc/bandwidthd.conf relative to the current dir */ + $bandwidthd_base_dir = PKG_BANDWIDTHD_BASE; $bandwidthd_config_dir = PKG_BANDWIDTHD_BASE . "/etc"; conf_mount_rw(); @@ -143,7 +145,7 @@ function bandwidthd_install_config() { # This file was automatically generated by the pfSense # package management system. Changing this file # will lead to it being overwritten again when -# the package manage resyncs. +# the package manager resyncs. # #################################################### # Bandwidthd.conf @@ -206,18 +208,47 @@ EOF; fwrite($fd, $config_file); fclose($fd); - /* write out rc.d start/stop file */ - write_rcfile(array( - "file" => "bandwidthd.sh", - "start" => "/usr/local/bandwidthd/bandwidthd {$bandwidthd_config_dir}/bandwidthd.conf", - "stop" => "/usr/bin/killall bandwidthd" - ) - ); + $rc = array(); + $rc['file'] = 'bandwidthd.sh'; + $rc['stop'] = <<<EOD +/usr/bin/killall bandwidthd +EOD; + + if ($g['platform'] == 'nanobsd') { + // On nanobsd, /var/bandwidthd is created. + // In that is a real /var/bandwidth/htdocs, where the graph data is written + // A soft link to the real bandwidth program is made - /var/bandwidthd/bandwidthd + // A soft link to the etc folder with the conf file is made - /var/bandwidthd/etc + // bandwidthd is started from /var/bandwidthd with the current dir /var/bandwidth + // This way, it: + // looks in ./etc for the conf file + // writes graph files in ./htdocs + // writes cdf log files (if selected in the config) to ./ + // All of this is on the /var filesystem, which is a read-write memory disk on nanobsd + $bandwidthd_nano_dir = "/var/bandwidthd"; + $bandwidthd_htdocs_dir = $bandwidthd_nano_dir . "/htdocs"; + $rc['start'] = <<<EOD +/bin/mkdir -p {$bandwidthd_nano_dir} +/bin/mkdir -p {$bandwidthd_htdocs_dir} +/bin/ln -s {$bandwidthd_base_dir}/bandwidthd {$bandwidthd_nano_dir}/bandwidthd +/bin/ln -s {$bandwidthd_config_dir} {$bandwidthd_nano_dir}/etc +cd {$bandwidthd_nano_dir} +{$bandwidthd_nano_dir}/bandwidthd +cd - +EOD; + } else { + $bandwidthd_htdocs_dir = $bandwidthd_base_dir . "/htdocs"; + $rc['start'] = <<<EOD +/usr/local/bandwidthd/bandwidthd +EOD; + } - exec("rm /usr/local/www/bandwidthd"); - exec("/bin/ln -s " . PKG_BANDWIDTHD_BASE . "/htdocs /usr/local/www/bandwidthd"); + /* write out rc.d start/stop file */ + write_rcfile($rc); - exec("echo \"Please start bandwidthd to populate this directory.\" > " . PKG_BANDWIDTHD_BASE . "/htdocs/index.html"); + exec("/bin/rm /usr/local/www/bandwidthd"); + exec("/bin/ln -s " . $bandwidthd_htdocs_dir . " /usr/local/www/bandwidthd"); + exec("echo \"Please start bandwidthd to populate this directory.\" > " . $bandwidthd_htdocs_dir . "/index.html"); conf_mount_ro(); config_unlock(); @@ -227,4 +258,4 @@ EOF; } -?>
\ No newline at end of file +?> |