educatic-info/bin/lib/educatic.rb

54 lines
1.3 KiB
Ruby
Raw Normal View History

2022-11-25 15:17:56 +01:00
#!/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
2022-11-25 15:47:56 +01:00
def check
2022-11-25 15:17:56 +01:00
@services.each_pair do |key, value|
2022-11-25 15:47:56 +01:00
output = []
2022-12-01 15:09:51 +01:00
todo = value['todo'] || []
2022-11-25 15:47:56 +01:00
2022-11-25 15:17:56 +01:00
cmd = "host #{value['ip']}| grep #{value['hostname']}| wc -l"
counter = %x[#{cmd}].to_i
if counter.zero?
2022-11-25 15:47:56 +01:00
output << " Check this:"
output << " * hostname = #{value['hostname']}"
output << " * ip = #{value['ip']}"
2022-11-25 15:17:56 +01:00
end
2022-12-01 15:09:51 +01:00
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
2022-11-25 15:17:56 +01:00
unless value['todo'].nil?
2022-11-25 15:47:56 +01:00
output << " TODO:"
2022-12-01 15:09:51 +01:00
todo.each_with_index do |line, index|
2022-11-25 15:47:56 +01:00
output << " #{index + 1}. #{line}"
2022-11-25 15:17:56 +01:00
end
end
2022-11-25 15:47:56 +01:00
unless output.size.zero?
puts "==> #{key} [#{value['hetzner']}]"
puts output.join("\n")
end
2022-11-25 15:17:56 +01:00
end
end
def urls
@services.each_pair do |key, value|
puts "#{key.rjust(16)} : #{value['hostname']}"
end
end
end