mirror of
https://github.com/internetee/registry.git
synced 2025-07-23 19:20:37 +02:00
Add whenever and zonefile methods
This commit is contained in:
parent
4e8b100f5c
commit
603cfb61ef
7 changed files with 56 additions and 1 deletions
|
@ -1,6 +1,22 @@
|
|||
class ZonefileSetting < ActiveRecord::Base
|
||||
validates :origin, :ttl, :refresh, :retry, :expire, :minimum_ttl, :email, presence: true
|
||||
validates :ttl, :refresh, :retry, :expire, :minimum_ttl, numericality: { only_integer: true }
|
||||
|
||||
def self.generate_zonefiles
|
||||
pluck(:origin).each do |origin|
|
||||
generate_zonefile(origin)
|
||||
end
|
||||
end
|
||||
|
||||
def self.generate_zonefile(origin)
|
||||
zf = ActiveRecord::Base.connection.execute(
|
||||
"select generate_zonefile('#{origin}')"
|
||||
)[0]['generate_zonefile']
|
||||
|
||||
filename = "#{origin}.zone"
|
||||
File.open("#{APP_CONFIG['zonefile_export_dir']}/#{filename}", 'w') { |f| f.write(zf) }
|
||||
end
|
||||
|
||||
def to_s
|
||||
origin
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue