Sha256: b6255f7425ef586c240bc65eecbc93662e5aca70336f760d7c55a89c3eacb70f

Contents?: true

Size: 536 Bytes

Versions: 3

Compression:

Stored size: 536 Bytes

Contents

module LinuxAdmin
  class Chrony
    def initialize(conf = "/etc/chrony.conf")
      raise MissingConfigurationFileError, "#{conf} does not exist" unless File.exist?(conf)
      @conf = conf
    end

    def clear_servers
      data = File.read(@conf)
      data.gsub!(/^server\s+.+\n/, "")
      File.write(@conf, data)
    end

    def add_servers(*servers)
      data = File.read(@conf)
      data << "\n" unless data.end_with?("\n")
      servers.each { |s| data << "server #{s}\n" }
      File.write(@conf, data)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
linux_admin-0.15.0 lib/linux_admin/chrony.rb
linux_admin-0.14.0 lib/linux_admin/chrony.rb
linux_admin-0.13.0 lib/linux_admin/chrony.rb