From 7259c46a09eef28a3a145a94b660ed2a7f35dc03 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 14 Aug 2015 00:57:15 +0200 Subject: bacula-client - code style fixes - Fix copyright header and indentation - Fix permissions - Remove unused tags - Sanitize version - Improve some descriptions --- config/bacula-client/bacula-client.xml | 115 ++++++++++++++++----------------- 1 file changed, 54 insertions(+), 61 deletions(-) (limited to 'config') diff --git a/config/bacula-client/bacula-client.xml b/config/bacula-client/bacula-client.xml index 65b5231e..ce07e77e 100644 --- a/config/bacula-client/bacula-client.xml +++ b/config/bacula-client/bacula-client.xml @@ -1,81 +1,77 @@ + + - - +. - All rights reserved. - */ -/* ========================================================================== */ + bacula-client.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) Marcio Carlos Braga Antao + Copyright (C) 2012 Marcello Coutinho + Copyright (C) 2015 ESF, LLC + All rights reserved. +*/ +/* ====================================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -/* ========================================================================== */ - ]]> - - Client Install for Bacula 5.2.6 Backup - Bacula Server Installed in or network - Currently there are no FAQ items provided. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + + Bacula Server Installed on your network. baculaclient - 5.2.6 - Bacula-Client: Setting - /pkg.php?xml=bacula-client.xml + 1.0.8 + Bacula Client: Settings + /pkg.php?xml=bacula-client.xml /usr/local/pkg/bacula-client.inc installedpackages->package->baculaclient /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/bacula-client/bacula-client.inc /usr/local/pkg/ - 0755 https://packages.pfsense.org/packages/config/bacula-client/bacula-client_fd.xml /usr/local/www/ - 0755 https://packages.pfsense.org/packages/config/bacula-client/bacula-client_view_config.php - Bacula-client - bacula backup client + Bacula Client + Bacula Backup Client
Services
bacula-client.xml
bacula-fd.sh - Bacula-client + bacula-client bacula-fd - bacula backup client + Bacula Backup Client @@ -104,20 +100,20 @@ Description description - + listtopic directors Directors - + Director Name director input 60 - Name of director + Enter name for the Director. @@ -132,7 +128,7 @@ password password 30 - + Enter password used for Director access. Director type @@ -143,20 +139,17 @@ - Director Type. You need at least one local director. + + + NOTE: You need at least one local Director. + ]]> + baculaclient_custom_php_install_command(); - - - - - - - - baculaclient_custom_php_write_config(); -- cgit v1.2.3 From e1af8feedae122cd058fbc0528b19ac684438d9c Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 14 Aug 2015 00:59:31 +0200 Subject: bacula-client - code style fixes - Fix copyright header and indentation - Remove unused tags - Sanitize version - Improve some descriptions --- config/bacula-client/bacula-client_fd.xml | 96 ++++++++++++++----------------- 1 file changed, 43 insertions(+), 53 deletions(-) (limited to 'config') diff --git a/config/bacula-client/bacula-client_fd.xml b/config/bacula-client/bacula-client_fd.xml index 08a64ea1..aed6d7b6 100644 --- a/config/bacula-client/bacula-client_fd.xml +++ b/config/bacula-client/bacula-client_fd.xml @@ -1,53 +1,52 @@ + + - - +. - All rights reserved. - */ -/* ========================================================================== */ + bacula-client.xml + part of pfSense (https://www.pfSense.org/) + Copyright (C) Marcio Carlos Braga Antao + Copyright (C) 2012 Marcello Coutinho + Copyright (C) 2015 ESF, LLC + All rights reserved. +*/ +/* ====================================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. - 1. Redistributions of source code must retain the above copyright notice, - this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. - 2. Redistributions in binary form must reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -/* ========================================================================== */ - ]]> - - Client Install for Bacula 5.2.6 Backup - Bacula Server Installed in or network - Currently there are no FAQ items provided. + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +/* ====================================================================================== */ + ]]> + + Bacula Server Installed on your network. baculaclientfd - 5.2.6 - Bacula-Client: FileDaemon Setting - /pkg_edit.php?xml=bacula-client_fd.xml + 1.0.8 + Bacula Client: FileDaemon Settings + /pkg_edit.php?xml=bacula-client_fd.xml /usr/local/pkg/bacula-client.inc installedpackages->package->baculaclient @@ -76,7 +75,7 @@ port input 4 - Port for a File Daemon. Default : 9102 + Port for a File Daemon. (Default: 9102) @@ -85,23 +84,14 @@ input 3 - Maximum Concurrent Jobs. Default : 20 + Maximum Concurrent Jobs. (Default: 20) - baculaclient_custom_php_install_command(); - - - - - - - - - baculaclient_custom_php_write_config(); + baculaclient_custom_php_write_config(); -- cgit v1.2.3 From e99476963d9274b5eb56c483b68034c81855303e Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 14 Aug 2015 01:09:49 +0200 Subject: bacula-client - code style fixes - Fix copyright header and indentation - Fix pfSense version checks - Fix permissions - Code style and indentation fixes - Remove unused global vars declaration - User stop_service() and restart_service() - Make sure that at least one local Director is configured before trying to start the service, otherwise it fails (see e.g. https://forum.pfsense.org/index.php?topic=97934.0) --- config/bacula-client/bacula-client.inc | 182 ++++++++++++++++----------------- 1 file changed, 86 insertions(+), 96 deletions(-) (limited to 'config') diff --git a/config/bacula-client/bacula-client.inc b/config/bacula-client/bacula-client.inc index 8a04d55b..07be3067 100644 --- a/config/bacula-client/bacula-client.inc +++ b/config/bacula-client/bacula-client.inc @@ -1,128 +1,118 @@ . - All rights reserved. - */ -/* ========================================================================== */ /* - Redistribution and use in source and binary forms, with or without - modification, are permitted provided that the following conditions are met: - - 1. Redistributions of source code MUST retain the above copyright notice, - this list of conditions and the following disclaimer. - - 2. Redistributions in binary form MUST reproduce the above copyright - notice, this list of conditions and the following disclaimer in the - documentation and/or other materials provided with the distribution. - - THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, - INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY - AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, - OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - POSSIBILITY OF SUCH DAMAGE. - */ -/* ========================================================================== */ - require_once("config.inc"); - require_once("util.inc"); - - $pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version > 2.0) + bacula-client.inc + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Marcio Carlos Braga Antao + Copyright (C) 2012-2013 Marcello Coutinho + Copyright (C) 2015 ESF, LLC + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + + 1. Redistributions of source code must retain the above copyright notice, + this list of conditions and the following disclaimer. + + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, + OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. +*/ +require_once("config.inc"); +require_once("util.inc"); + +$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { define('BACULA_LOCALBASE', '/usr/pbi/bacula-' . php_uname("m")); -else +} else { define('BACULA_LOCALBASE','/usr/local'); - +} define('BACULA_STARTUP_SCRIPT', '/usr/local/etc/rc.d/bacula-fd.sh'); -function baculaclient_custom_php_install_command(){ - global $g, $config; +function baculaclient_custom_php_install_command() { baculaclient_custom_php_write_config(); } function baculaclient_custom_php_deinstall_command(){ - global $g, $config; - conf_mount_rw(); - // 1. Delete our config file - unlink_if_exists(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf"); + // Delete our config file + unlink_if_exists(BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf"); + // Stop service and delete our rc file + stop_service("bacula-client"); + unlink_if_exists(BACULA_STARTUP_SCRIPT); - // 2. Re-run sshd config generation script - exec(BACULA_STARTUP_SCRIPT . " stop"); conf_mount_ro(); } function baculaclient_custom_php_write_config(){ - global $g, $config; + global $config, $LocalDirector; conf_mount_rw(); - //check config_file - $startup_file=BACULA_LOCALBASE . "/etc/rc.d/bacula-fd"; - if (file_exists($startup_file)){ - $startup_script=file_get_contents($startup_file); - $startup_script=preg_replace("/NO/","YES",$startup_script); - $startup_script=preg_replace("@/usr/local/etc/bacula-fd.conf@",BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$startup_script); - $startup_script=preg_replace("@/usr/local/etc/bacula/bacula-fd.conf@",BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$startup_script); - file_put_contents(BACULA_STARTUP_SCRIPT,$startup_script,LOCK_EX); - // Ensure bacula-fd has a+rx - exec("chmod a+rx " . BACULA_STARTUP_SCRIPT); - } - //check config - if (is_array($config['installedpackages']['baculaclient']['config'])){ + // Check config_file + $startup_file = BACULA_LOCALBASE . "/etc/rc.d/bacula-fd"; + if (file_exists($startup_file)) { + $startup_script = file_get_contents($startup_file); + $startup_script = preg_replace("/NO/","YES", $startup_script); + $startup_script = preg_replace("@/usr/local/etc/bacula-fd.conf@", BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $startup_script); + $startup_script = preg_replace("@/usr/local/etc/bacula/bacula-fd.conf@", BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $startup_script); + file_put_contents(BACULA_STARTUP_SCRIPT, $startup_script, LOCK_EX); + // Ensure bacula-fd is executable + chmod(BACULA_STARTUP_SCRIPT, 0755); + } + + // Check config + if (is_array($config['installedpackages']['baculaclient']['config'])) { $baculaclient_conf=""; foreach ($config['installedpackages']['baculaclient']['config'] as $bc) { - // create Director - switch ($bc['type']){ - case "Director": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; - Break; - case "Monitor": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; - break; - case "Local": - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; - $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; - $LocalDirector = $bc['director']; - } - + // Create Director + switch ($bc['type']) { + case "Director": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; + break; + case "Monitor": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; + break; + case "Local": + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-dir #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n}\n"; + $baculaclient_conf .= "Director { \n\tName = {$bc['director']}-mon #{$bc['description']}\n\tPassword = \"{$bc['password']}\"\n\tMonitor = yes\n}\n"; + $LocalDirector = $bc['director']; } - // create Messages + } + + // Create Messages if (!empty($LocalDirector)) { $baculaclient_conf .= "Messages { \n\tName = Standard \n\tdirector = {$LocalDirector}-dir = all, !skipped, !restored\n}\n"; } - // create FielDaemon - - if (is_array($config['installedpackages']['baculaclientfd']['config'])){ - $port = $config['installedpackages']['baculaclientfd']['config'][0]['port']; - $jobs = $config['installedpackages']['baculaclientfd']['config'][0]['jobs']; - } - else{ - $port="9102"; - $jobs="20"; - } + // Create FileDaemon + if (is_array($config['installedpackages']['baculaclientfd']['config'])) { + $port = $config['installedpackages']['baculaclientfd']['config'][0]['port'] ?: '9102'; + $jobs = $config['installedpackages']['baculaclientfd']['config'][0]['jobs'] ?: '20'; + } if (!empty($LocalDirector)) { $baculaclient_conf .= "FileDaemon { \n\tName = {$LocalDirector}-fd #\n\tFDport = {$port}\n\tWorkingDirectory = /var/db/bacula\n\tPid Directory = /var/run\n\tMaximum Concurrent Jobs = {$jobs}\n}\n"; } - file_put_contents(BACULA_LOCALBASE."/etc/bacula/bacula-fd.conf",$baculaclient_conf,LOCK_EX); - exec(BACULA_STARTUP_SCRIPT . " restart"); - // Mount Read-only - conf_mount_ro(); + // Write config file and start service + file_put_contents(BACULA_LOCALBASE . "/etc/bacula/bacula-fd.conf", $baculaclient_conf, LOCK_EX); + if (!empty($LocalDirector)) { + restart_service("bacula-client"); + } else { + log_error("[bacula-client] You need at least one local Director in order to run bacula-client."); } - } - ?> + conf_mount_ro(); + } +} +?> -- cgit v1.2.3 From 3c5c7132c4992f3dbc7df129ffc75f0c1ddc3487 Mon Sep 17 00:00:00 2001 From: doktornotor Date: Fri, 14 Aug 2015 01:14:28 +0200 Subject: bacula-client - code style fixes - Fix copyright header - Fix pfSense version checks - Nuke obsolete pfSense 1.2.x junk - Code style and indentation --- config/bacula-client/bacula-client_view_config.php | 58 +++++++++------------- 1 file changed, 24 insertions(+), 34 deletions(-) (limited to 'config') diff --git a/config/bacula-client/bacula-client_view_config.php b/config/bacula-client/bacula-client_view_config.php index 28098965..c10a0cda 100644 --- a/config/bacula-client/bacula-client_view_config.php +++ b/config/bacula-client/bacula-client_view_config.php @@ -1,9 +1,9 @@ - Copyright (C) 2012 M�rcio Carlos Ant�o + part of pfSense (https://www.pfSense.org/) + Copyright (C) 2012 Marcio Carlos Braga Antao + Copyright (C) 2015 ESF, LLC All rights reserved. Redistribution and use in source and binary forms, with or without @@ -27,33 +27,26 @@ ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - require("guiconfig.inc"); -$pf_version=substr(trim(file_get_contents("/etc/version")),0,3); -if ($pf_version < 2.0) - $one_two = true; - -if ($pf_version > 2.0) +$$pf_version = substr(trim(file_get_contents("/etc/version")), 0, 3); +if ($pf_version == "2.1" || $pf_version == "2.2") { define('BACULA_LOCALBASE', '/usr/pbi/bacula-' . php_uname("m")); -else +} else { define('BACULA_LOCALBASE','/usr/local'); +} $pgtitle = "Bacula-Client: View Configuration"; include("head.inc"); ?> + - -

- -
-
- - - +
@@ -65,27 +58,24 @@ include("head.inc"); display_top_tabs($tab_array); ?>
-
- - - - -
- -
-
-
+
+ + +
+ +
+
+
+ - \ No newline at end of file + -- cgit v1.2.3