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-12-02 09:28:35 +01:00
|
|
|
puts " #{Time.now}"
|
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-12-02 09:26:31 +01:00
|
|
|
check_hostname(value, output: output, todo: todo)
|
2022-12-01 15:09:51 +01:00
|
|
|
|
2022-11-25 15:17:56 +01:00
|
|
|
unless value['todo'].nil?
|
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?
|
2022-12-02 09:26:31 +01:00
|
|
|
puts "==> [Hetzner #{value['hetzner'].upcase}] #{key}"
|
2022-11-25 15:47:56 +01:00
|
|
|
puts output.join("\n")
|
|
|
|
end
|
2022-11-25 15:17:56 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2022-12-02 09:26:31 +01:00
|
|
|
def show_urls
|
2022-11-25 15:17:56 +01:00
|
|
|
@services.each_pair do |key, value|
|
|
|
|
puts "#{key.rjust(16)} : #{value['hostname']}"
|
|
|
|
end
|
|
|
|
end
|
2022-12-02 09:26:31 +01:00
|
|
|
|
|
|
|
private
|
|
|
|
|
|
|
|
def check_hostname(value, output:, 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
|
|
|
|
end
|
2022-11-25 15:17:56 +01:00
|
|
|
end
|