Class: ZabbixVhost::Config
- Inherits:
-
Object
- Object
- ZabbixVhost::Config
- Defined in:
- lib/zabbix_vhost/config.rb
Instance Attribute Summary collapse
-
#file_path ⇒ Object
Returns the value of attribute file_path.
-
#server_alias ⇒ Object
readonly
Returns the value of attribute server_alias.
-
#server_name ⇒ Object
readonly
Returns the value of attribute server_name.
Class Method Summary collapse
- .dir_reader(path) ⇒ Object
-
.find_in_dir(path, domain) ⇒ Object
Cerca il dominio all’interno della cartella.
Instance Method Summary collapse
-
#initialize(f) ⇒ Config
constructor
A new instance of Config.
- #parse ⇒ Object
- #ssl_active ⇒ Object
- #ssl_issuer ⇒ Object
- #ssl_until_days ⇒ Object
Constructor Details
#initialize(f) ⇒ Config
8 9 10 11 12 13 14 15 16 |
# File 'lib/zabbix_vhost/config.rb', line 8 def initialize(f) @file_path = f @server_alias = [] @server_name = nil @ssl_active = nil parse end |
Instance Attribute Details
#file_path ⇒ Object
Returns the value of attribute file_path.
4 5 6 |
# File 'lib/zabbix_vhost/config.rb', line 4 def file_path @file_path end |
#server_alias ⇒ Object (readonly)
Returns the value of attribute server_alias.
6 7 8 |
# File 'lib/zabbix_vhost/config.rb', line 6 def server_alias @server_alias end |
#server_name ⇒ Object (readonly)
Returns the value of attribute server_name.
6 7 8 |
# File 'lib/zabbix_vhost/config.rb', line 6 def server_name @server_name end |
Class Method Details
.dir_reader(path) ⇒ Object
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/zabbix_vhost/config.rb', line 37 def self.dir_reader(path) configuration_files = Dir.glob("#{path}/*") configurations = [] configuration_files.each do |f| if File.file?(f) cfg = self.new(f) configurations << cfg end end configurations end |
.find_in_dir(path, domain) ⇒ Object
Cerca il dominio all’interno della cartella
56 57 58 |
# File 'lib/zabbix_vhost/config.rb', line 56 def self.find_in_dir(path, domain) dir_reader(path).select {|c| c.server_name == domain}.first end |
Instance Method Details
#parse ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/zabbix_vhost/config.rb', line 18 def parse @config_content = File.read(@file_path) ## Controlliamo se siamo in apache if_apache do @server_name = @config_content.match(/^\s*ServerName (?<server_name>.*)/)[:server_name] if @config_content.match(/^\s*ServerAlias/) @server_alias = @config_content.match(/^\s*ServerAlias (?<names>.*)/)[:names].split(" ") end @ssl_active = !@config_content.match(/443/).nil? end if @ssl_active @ssl_data = read_ssl_data end end |
#ssl_active ⇒ Object
63 64 65 |
# File 'lib/zabbix_vhost/config.rb', line 63 def ssl_active @ssl_active ? 1 : 0 end |
#ssl_issuer ⇒ Object
72 73 74 75 |
# File 'lib/zabbix_vhost/config.rb', line 72 def ssl_issuer return nil unless @ssl_data @ssl_data[:issuer] end |
#ssl_until_days ⇒ Object
67 68 69 70 |
# File 'lib/zabbix_vhost/config.rb', line 67 def ssl_until_days return nil unless @ssl_data @ssl_data[:days_until] end |