diff options
author | jim-p <jimp@pfsense.org> | 2012-06-23 18:56:39 -0400 |
---|---|---|
committer | jim-p <jimp@pfsense.org> | 2012-06-23 18:56:39 -0400 |
commit | c0b7e2174a95734cb61953bae37f3d99a9864882 (patch) | |
tree | d6619d370bc79c2549963741c038c44c75611bb1 /config | |
parent | 968e56e5088b34bc5df8fad9841ec4f4d82cb996 (diff) | |
download | pfsense-packages-c0b7e2174a95734cb61953bae37f3d99a9864882.tar.gz pfsense-packages-c0b7e2174a95734cb61953bae37f3d99a9864882.tar.bz2 pfsense-packages-c0b7e2174a95734cb61953bae37f3d99a9864882.zip |
Adapt bandwidthd to use the right dir on 2.1, work around the fact that you can't specify a proper custom config path.
Diffstat (limited to 'config')
-rw-r--r-- | config/bandwidthd/bandwidthd.inc | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/config/bandwidthd/bandwidthd.inc b/config/bandwidthd/bandwidthd.inc index 3aa53694..3ef372b1 100644 --- a/config/bandwidthd/bandwidthd.inc +++ b/config/bandwidthd/bandwidthd.inc @@ -28,12 +28,18 @@ POSSIBILITY OF SUCH DAMAGE. */ +if (substr(trim(file_get_contents("/etc/version")),0,3) == "2.1") { + define('PKG_BANDWIDTHD_BASE', '/usr/pbi/bandwidthd-amd64/bandwidthd'); +} else { + define('PKG_BANDWIDTHD_BASE', '/usr/local/bandwidthd'); +} + function bandwidthd_install_deinstall() { conf_mount_rw(); config_lock(); - exec("rm /usr/local/etc/rc.d/bandwidthd*"); - exec("rm -rf /usr/local/bandwidthd*"); - exec("rm /usr/local/www/bandwidthd"); + exec("rm -f /usr/local/etc/rc.d/bandwidthd*"); + exec("rm -rf " . PKG_BANDWIDTHD_BASE . "/htdocs"); + exec("rm -f /usr/local/www/bandwidthd"); conf_mount_ro(); config_unlock(); } @@ -41,6 +47,9 @@ function bandwidthd_install_deinstall() { function bandwidthd_install_config() { global $config, $g; + /* bandwidthd doesn't have a way to pass a custom config path, unfortunately */ + $bandwidthd_config_dir = PKG_BANDWIDTHD_BASE . "/etc"; + conf_mount_rw(); config_lock(); @@ -177,9 +186,9 @@ $meta_refresh EOF; - $fd = fopen("/usr/local/bandwidthd/etc/bandwidthd.conf","w"); + $fd = fopen("{$bandwidthd_config_dir}/bandwidthd.conf","w"); if(!$fd) { - log_error("could not open /usr/local/bandwidthd/etc/bandwidthd.conf for writing"); + log_error("could not open {$bandwidthd_config_dir}/bandwidthd.conf for writing"); exit; } fwrite($fd, $config_file); @@ -188,15 +197,15 @@ EOF; /* write out rc.d start/stop file */ write_rcfile(array( "file" => "bandwidthd.sh", - "start" => "/usr/local/bandwidthd/bandwidthd /usr/local/bandwidthd/etc/bandwidthd.conf", + "start" => "/usr/local/bandwidthd/bandwidthd {$bandwidthd_config_dir}/bandwidthd.conf", "stop" => "/usr/bin/killall bandwidthd" ) ); exec("rm /usr/local/www/bandwidthd"); - exec("/bin/ln -s /usr/local/bandwidthd/htdocs /usr/local/www/bandwidthd"); + exec("/bin/ln -s " . PKG_BANDWIDTHD_BASE . "/htdocs /usr/local/www/bandwidthd"); - exec("echo \"Please start bandwidthd to populate this directory.\" > /usr/local/bandwidthd/htdocs/index.html"); + exec("echo \"Please start bandwidthd to populate this directory.\" > " . PKG_BANDWIDTHD_BASE . "/htdocs/index.html"); conf_mount_ro(); config_unlock(); |