react-project/bin/gen-subject-alternatives.rb
Eliezer Croitoru 1058f74a2f 2
2024-04-09 09:30:04 +03:00

45 lines
811 B
Ruby

#!/usr/bin/env ruby
def read_file(file_name)
File.readlines(file_name).map(&:strip).reject(&:empty?)
end
def generate_san_config(ips, domains, emails)
entries = []
ips.each_with_index do |ip, i|
entries << "IP.#{i} = #{ip}"
end
domains.each_with_index do |domain, i|
entries << "DNS.#{i} = #{domain}"
end
emails.each_with_index do |email, i|
entries << "email.#{i} = #{email}"
end
entries.join("\n")
end
def main
ip_file = "vars/ips"
domain_file = "vars/domains"
email_file = "vars/emails"
ips = read_file(ip_file)
domains = read_file(domain_file)
emails = read_file(email_file)
return if ips.empty? && domains.empty? && emails.empty?
san_config = generate_san_config(ips, domains, emails)
puts san_config
end
if __FILE__ == $PROGRAM_NAME
main
end