aboutsummaryrefslogtreecommitdiffstats
path: root/config/bacula-client
diff options
context:
space:
mode:
authorMárcio Carlos <marcioc.antao@gmail.com>2012-06-29 14:15:16 -0300
committerMárcio Carlos <marcioc.antao@gmail.com>2012-06-29 14:15:16 -0300
commit2f607a2b0ebd177feafd4d353aaf344b8b6a5418 (patch)
tree0d7aa99cc4991d4ed677781ed0d0492e6696af21 /config/bacula-client
parent5cc0d3ffc77909ed2810e2706fae97f48343b40e (diff)
downloadpfsense-packages-2f607a2b0ebd177feafd4d353aaf344b8b6a5418.tar.gz
pfsense-packages-2f607a2b0ebd177feafd4d353aaf344b8b6a5418.tar.bz2
pfsense-packages-2f607a2b0ebd177feafd4d353aaf344b8b6a5418.zip
Update master
Diffstat (limited to 'config/bacula-client')
-rw-r--r--config/bacula-client/bacula-client.inc112
1 files changed, 48 insertions, 64 deletions
diff --git a/config/bacula-client/bacula-client.inc b/config/bacula-client/bacula-client.inc
index 7cb27b1f..fd6e2d65 100644
--- a/config/bacula-client/bacula-client.inc
+++ b/config/bacula-client/bacula-client.inc
@@ -1,6 +1,6 @@
<?php
-* ========================================================================== */
+/* ========================================================================== */
/*
bacula-client.inc
part of pfSense (http://www.pfSense.com)
@@ -38,43 +38,20 @@
require_once("config.inc");
require_once("util.inc");
-function restart_bacula-client(){
- //backup /usr/local/etc/bacula-fd.conf before any change
- $etc_bacula-client=" /usr/local/etc/bacula-fd.conf";
- $pfsense_version=preg_replace("/\s/","",file_get_contents("/etc/version"));
- if (!file_exists('/root/'.$pfsense_version.'.bacula-fd.backup')){
- copy ($etc_bacula-client,'/root/'.$pfsense_version.'.bacula-fd.backup');
- }
-
- //patch /usr/local/etc/bacula-fd.conf if need
- $sshd_file=file($etc_bacula-client);
- $sshd_new_file="";
- foreach ($sshd_file as $line){
- if (preg_match('/sshconf .= "Port/',$line)){
- $sshd_new_file.= $line;
- $sshd_new_file.= "\t".'if(file_exists("/etc/ssh/sshd_extra")){$sshconf.=file_get_contents("/etc/ssh/sshd_extra");}'."\n";
- }
- elseif(!preg_match('/sshd_extra/',$line)){
- $sshd_new_file.= $line;
- }
- }
- file_put_contents($etc_sshd,$sshd_new_file,LOCK_EX);
- mwexec_bg($etc_sshd);
- }
-
-function bacula-client_custom_php_install_command(){
+function baculaclient_custom_php_install_command(){
global $g, $config;
- conf_mount_rw();
- $fd = fopen("/usr/local/etc/rc.d/bacula-fd", "w");
+ conf_mount_rw();
+ unlink_if_exists("/usr/local/etc/rc.d/bacula-fd");
+ $fd = fopen("/usr/local/etc/rc.d/bacula-client.sh", "w");
if(!$fd) {
- log_error("Could not open /usr/local/etc/rc.d/bacula-fd for writing.");
+ log_error("Could not open /usr/local/etc/rc.d/bacula-client.sh for writing.");
return;
}
- // Ensure svscan.sh has a+rx
- exec("chmod a+rx /usr/local/etc/rc.d/bacula-fd");
+ // Ensure bacula-fd has a+rx
+ exec("chmod a+rx /usr/local/etc/rc.d/bacula-client.sh");
- $bacula-fd = <<<EOD
+ $baculafd = <<<EOD
#!/bin/sh
#
# $FreeBSD: ports/sysutils/bacula-server/files/bacula-fd.in,v 1.7 2012/01/14 08:56:57 dougb Exp $
@@ -99,22 +76,26 @@ command=/usr/local/sbin/bacula-fd
load_rc_config $name
-: ${bacula_fd_enable="YES"}
-: ${bacula_fd_flags=" -u root -g wheel -v -c /usr/local/etc/bacula-fd.conf"}
-: ${bacula_fd_pidfile="/var/run/bacula-fd.9102.pid"}
+: \${bacula_fd_enable="YES"}
+: \${bacula_fd_flags=" -u root -g wheel -v -c /usr/local/etc/bacula-fd.conf"}
+: \${bacula_fd_pidfile="/var/run/bacula-fd.9102.pid"}
-pidfile="${bacula_fd_pidfile}"
+pidfile="\${bacula_fd_pidfile}"
-run_rc_command "$1"
+run_rc_command "\$1"
EOD;
- fwrite($fd, $bacula-fd);
+ fwrite($fd, $baculafd);
fclose($fd);
conf_mount_ro();
+ if (!is_array($config['installedpackages']['baculaclient'])) {
+ $config['installedpackages']['baculaclient']['config'][0]['ports'] = "9102";
+ $config['installedpackages']['baculaclient']['config'][0]['jobs'] = "20";
}
+}
-function bacula-client_custom_php_deinstall_command(){
+function baculaclient_custom_php_deinstall_command(){
global $g, $config;
conf_mount_rw();
@@ -123,56 +104,59 @@ function bacula-client_custom_php_deinstall_command(){
unlink_if_exists("/usr/local/etc/bacula-fd.conf");
// 2. Re-run sshd config generation script
- exec("/usr/local/etc/rc.d/bacula-fd stop");
-
+ exec("/usr/local/etc/rc.d/bacula-client.sh stop");
conf_mount_ro();
- }
+
+}
-function bacula-client_custom_php_write_config(){
+function baculaclient_custom_php_write_config(){
global $g, $config;
+ exec("/usr/local/etc/rc.d/bacula-client.sh stop");
$fd = fopen("/usr/local/etc/bacula-fd.conf", "w");
if(!$fd) {
log_error("Could not open /usr/local/etc/bacula-fd.conf for writing.");
return;
}
- if (is_array($config['installedpackages']['bacula-client']['config'])){
+ if (is_array($config['installedpackages']['baculaclient']['config'])){
// Mount Read-write
conf_mount_rw();
// Make Head
- $baculaclient_conf .= <<<EOD
- #
- # Default Bacula File Daemon Configuration file
- #
+ /*
+ $baculaclient_conf = <<<EOD
+ # Bacula File Daemon Configuration file
# For Bacula release 5.2.6 (21 February 2012) -- pfsense 2.0.x
- #
# There is not much to change here except perhaps the
- #
# List Directors who are permitted to contact this File daemon
- #
EOD;
+ */
// Read config
- foreach ($config['installedpackages']['bacula-client']['config'] as $baculaclient){
- foreach ($baculaclient['row'] as $bc){
+ foreach ($config['installedpackages']['baculaclient']['config'][0]['row'] as $bc) {
// create Director
- if $bc['type'] < 2
- $baculaclient_conf .= "Director { \n\t Name = $bc['director']-dir #$bc['description']\n\t Password = ".'"'.$bc['password'].'"'."\n}\n";
- if $bc['type'] > 0
- $baculaclient_conf .= "Director { \n\t Name = $bc['director']-mon #$bc['description']\n\t Password = ".'"'.$bc['password'].'"'."\n\t Monitor = yes\n}\n";
- if $bc['type'] = 1
- $LocalDirector = $bc['director']
- }
+ if (strcmp($bc['type'],"0")) {
+ $baculaclient_conf .= "Director { \n\t Name = ".$bc['director']."-dir #".$bc['description']."\n\t Password = ".'"'.$bc['password'].'"'."\n}\n";
+ }
+ if (strcmp($bc['type'],"2")){
+ $baculaclient_conf .= "Director { \n\t Name = ".$bc['director']."-mon #".$bc['description']."\n\t Password = ".'"'.$bc['password'].'"'."\n\t Monitor = yes\n}\n";
+ }
+ if (strcmp($bc['type'],"1")){
+ $baculaclient_conf .= "Director { \n\t Name = ".$bc['director']."-dir #".$bc['description']."\n\t Password = ".'"'.$bc['password'].'"'."\n}\n";
+ $baculaclient_conf .= "Director { \n\t Name = ".$bc['director']."-mon #".$bc['description']."\n\t Password = ".'"'.$bc['password'].'"'."\n\t Monitor = yes\n}\n";
+ $LocalDirector = $bc['director'];
+ }
}
+
// create Messages
$baculaclient_conf .= "Messages { \n\t Name = Standard \n\t director = ".$LocalDirector."-dir = all, !skipped, !restored\n\t \n}\n";
// create FielDaemon
- $port = $config['installedpackages']['bacula-client']['config'][0]['port'];
- $dir = $config['installedpackages']['bacula-client']['config'][0]['dir'];
- $jobs = $config['installedpackages']['bacula-client']['config'][0]['jobs']
- $baculaclient_conf .= "FileDaemon { \n\t Name = $filedaemon-fd #\n\t FDport = $port\n\t WorkingDirectory = $dir\n\t Maximun Concurrent Jobs = $jobs\n \n}\n";
+ $port = $config['installedpackages']['baculaclient']['config'][0]['port'];
+ $jobs = $config['installedpackages']['baculaclient']['config'][0]['jobs'];
+ $baculaclient_conf .= "FileDaemon { \n\t Name = ".$filedaemon."-fd #\n\t FDport = ".$port."\n\t WorkingDirectory = /var/db/bacula\n\t Pid Directory = /var/run\n\t Maximun Concurrent Jobs = ".$jobs."\n \n}\n";
fwrite($fd, $baculaclient_conf);
fclose($fd);
}
+
+ exec("/usr/local/etc/rc.d/bacula-client.sh start");
}
// Mount Read-only