educatic-info/bin/lib/educatic.rb

54 lines
1.3 KiB
Ruby

#!/usr/bin/env ruby
require "yaml"
require "colorize"
class Educatic
attr_reader :settings
def initialize(filename)
@settings = YAML.load(File.read(filename))
@services = settings["services"]
end
def check
@services.each_pair do |key, value|
output = []
todo = value['todo'] || []
cmd = "host #{value['ip']}| grep #{value['hostname']}| wc -l"
counter = %x[#{cmd}].to_i
if counter.zero?
output << " Check this:"
output << " * hostname = #{value['hostname']}"
output << " * ip = #{value['ip']}"
end
if (value['hostname'].end_with? ".info" or value['hostname'].end_with? "clients.your-server.de")
todo << "Cambiar <#{value['hostname']}> el dominio @txs.es"
end
if value['hostname'].start_with? "staticeducar.info"
todo << "Cambiar <#{value['hostname']}> el dominio @txs.es"
end
unless value['todo'].nil?
output << " TODO:"
todo.each_with_index do |line, index|
output << " #{index + 1}. #{line}"
end
end
unless output.size.zero?
puts "==> #{key} [#{value['hetzner']}]"
puts output.join("\n")
end
end
end
def urls
@services.each_pair do |key, value|
puts "#{key.rjust(16)} : #{value['hostname']}"
end
end
end