Class Symbiosis::ConfigFile
In: common/lib/symbiosis/config_file.rb
Parent: Object
Array Utmp EventMachine::Connection ApacheLogger StandardError CrontabFormatError Enumerable IPAddr ::IPAddr Host Range Domain ConfigFile Prosody Tinydns Apache Webalizer Directory IPListDirectory TemplateDirectory Domains Alert Crontab CrontabRecord StateDB Check Runner TCPConnection Test Process BlacklistDB Template Logtail Pattern Ports Blacklist Monitor ConfigFiles Utils Firewall Symbiosis dot/f_0.png

This class is used to make configuration files easier to handle.

The idea is that we write an MD5 sum to the file in a parseable way, and then check that to see if it has changed, or not.

This class is a base that should be absorbed into child classes.

Methods

changed?   domain=   erb   erb=   exists?   generate_config   managed?   new   ok?   outdated?   template=   write  

Classes and Modules

Class Symbiosis::ConfigFile::Eruby

Attributes

comment_char  [R] 
domain  [R] 
filename  [R] 
template  [R] 

Public Class methods

This returns the ERB interpreter class.

Allow the ERB interpreter to be set by any subclass. This allows automatic escaping to be set up, for example.

Sets up a configuration file ‘filename’. The comment character ‘comment_char’ is used before the MD5 sum, and is assumed to be a hash.

Public Instance methods

This tests to see if the configuration has changed. First it checks to see if there is an MD5 sum in the file (defined by filename), and if so, it checks to see if that MD5 sum is correct for that file. If the MD5 sums match, then false is returned, otherwise true.

If no MD5 sum is found, the phrase " DO NOT EDIT THIS FILE - CHANGES WILL BE OVERWRITTEN", prepended by the comment_char is looked for. If that phrase is found, then false is returned.

If neither an MD5 or a warning could be found, then the file is assumed to have changed, so the method returns true.

Set the domain — potentially used in tests later, or in the template. Must be a Symbiosis::Domain.

Test to see if the config file exists

Template the configuration. Adds " Checksum MD5 " and the MD5 hash of the preceding configuration, prepended by comment_char and to the end of the generated config.

This returns true if Symbiosis has managed this file at some point.

See if the generated config is OK. This method always returns true, and thus should be overwritten in any child class.

Does the configuration need updating. It tests to see if the MD5 of the current file, and a new configuration based on templ match.

If no checksum is found in the original file, it returns true.

Set the template filename. Raises Errno::ENOENT if the file does not exist.

Writes the configuration specified by config to the filename specified in the constructor. The opts has takes options for the Symbiosis::Utils#safe_open method.

[Validate]