#!/usr/bin/env ruby

conf = './conf.d'
begin
    Dir.open(conf).each do |file|
	next if file =~ /^\./
	modified = false
	lines = File.readlines(File.join(conf, file))
	lines.each do |line|
	    if line =~ /^[;#]*username=.*/
		line.gsub!(/username=.*[^\s]/,'username=yourusername')
		printf "#{file}: #{line}"
		modified = true
	    elsif line =~ /^[;#]*password=.*/
		line.gsub!(/password=.*[^\s]/,'password=somesecret')
		printf "#{file}: #{line}"
		modified = true
	    end
	end
	if modified
	    fo = File.open(File.join(conf, file),'w')
	    lines.each do |line|
		fo.printf line
	    end
	end
    end
rescue
    printf "%s: ??\n", File.basename(__FILE__)
    exit 1
end
