Sha256: a074e7dba16202cf1088ea9bdc16ac0160053baf264bae09668b54ee0881c767

Contents?: true

Size: 543 Bytes

Versions: 3

Compression:

Stored size: 543 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} iburst\n" }
      File.write(@conf, data)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
linux_admin-0.18.0 lib/linux_admin/chrony.rb
linux_admin-0.17.0 lib/linux_admin/chrony.rb
linux_admin-0.16.0 lib/linux_admin/chrony.rb