Page MenuHomeGRNET

No OneTemporary

File Metadata

Created
Wed, Oct 15, 11:26 AM
diff --git a/config/mailer.yml.sample b/config/mailer.yml.sample
index f29392c..93abf7f 100644
--- a/config/mailer.yml.sample
+++ b/config/mailer.yml.sample
@@ -1,9 +1,10 @@
development:
address: smtp.grnet.gr
port: 587
domain: example.com
user_name: sender@archiving.grnet.gr
password: a_pass
authentication: plain
enable_starttls_auto: true
default_sender: sender@archiving.grnet.gr
+ operator_email: admin_receiver@archiving.grnet.gr
diff --git a/lib/configuration/host.rb b/lib/configuration/host.rb
index f370233..764e620 100644
--- a/lib/configuration/host.rb
+++ b/lib/configuration/host.rb
@@ -1,121 +1,124 @@
module Configuration
# Helper module to add configuration getters for Host
module Host
# Constructs the final Bacula configuration for the host by appending configs for
#
# * Client
# * Jobs
# * Schedules
# * Filesets
#
# by calling their `to_bacula_config_array` methods.
#
# @return [Array] containing each element's configuration line by line
def baculize_config
templates = job_templates.includes(:fileset, :schedule)
result = [self] + templates.map {|x| [x, x.fileset, x.schedule] }.flatten.compact.uniq
result.map(&:to_bacula_config_array)
end
# Constructs the final Bacula configuration for the host by appending configs for
#
# * Client
# * Jobs
# * Schedules
# * Filesets
#
# by calling their `to_bacula_config_array` methods.
#
# It hides the password.
#
# @return [Array] containing each element's configuration line by line
def baculize_config_no_pass
baculize_config.join("\n").gsub(/Password = ".*"$/, 'Password = "*************"')
end
# Constructs an array where each element is a line for the Client's bacula config
#
# @return [Array]
def to_bacula_config_array
[
"Client {",
" Name = #{name}",
" Address = #{fqdn}",
" FDPort = #{port}",
" Catalog = #{client_settings[:catalog]}",
" Password = \"#{password}\"",
" File Retention = #{file_retention} #{file_retention_period_type}",
" Job Retention = #{job_retention} #{job_retention_period_type}",
" AutoPrune = #{auto_prune_human}",
"}"
] + message_config
end
# Constructs the messages bacula resource
#
# @return [Array]
def message_config
return [] if email_recipients.empty?
[
"Messages {",
" Name = message_#{name}",
" mailcommand = \"#{mail_command}\"",
" operatorcommand = \"#{operator_command}\"",
" mail = root = all, !skipped",
" operator = root = mount",
" console = all, !skipped, !saved",
" append = \"/var/log/bacula/bacula.log\" = all, !skipped",
" catalog = all",
"}"
]
end
# Fetches the Director resource for the file-deamon configuration
# file
def bacula_fd_director_config
[
'Director {',
" Name = \"#{Archiving.settings[:director_name]}\"",
" Password = \"*********\"",
'}'
].join("\n")
end
# Fetches the FileDeamon resource for the file-deamon configuration
def bacula_fd_filedeamon_config
[
'FileDeamon {',
" Name = #{name}",
" FDport = #{port}",
' WorkingDirectory = /var/lib/bacula',
' Pid Directory = /var/run/bacula',
' Maximum Concurrent Jobs = 10',
' FDAddress = 0.0.0.0',
'}'
].join("\n")
end
private
def mail_command
- "#{mail_general} -u \\\"\[Bacula\]: %t %e of %c %l\\\" -m \\\"Bacula Report %r\\\""
+ "#{mail_general}" <<
+ " -t #{email_recipients.join(' ')}" <<
+ " -u \\\"\[Bacula\]: %t %e of %c %l\\\" -m \\\"Bacula Report\\\""
end
def operator_command
- "#{mail_general} -u \\\"\[Bacula\]: Intervention needed for %j\\\" -m \\\"Intervention needed %r\\\""
+ "#{mail_general}"
+ " -t #{settings[:operator_email]}" <<
+ " -u \\\"\[Bacula\]: Intervention needed for %j\\\" -m \\\"Intervention needed %r\\\""
end
def mail_general
"/usr/bin/sendEmail -f #{settings[:default_sender]}" <<
- " -t #{email_recipients.join(' ')}" <<
" -s #{settings[:address]}:#{settings[:port]}" <<
" -o tls=yes -xu #{settings[:user_name]} -xp #{settings[:password]}"
end
def settings
Archiving.settings[:mail_settings]
end
end
end

Event Timeline