#!/usr/bin/perl -w
# clients.migrate - migrate Cistron-style clients file to FreeRADIUS-style clients.conf

sub write_client {
	my ($client, $secret) = @_;
	print "client $client {\n\tsecret = $secret\n\tshortname = $client\n}\n\n"
}

while (<ARGV>) {
	if (/^\s*(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})\s+(\w+)\s*$/) {
		write_client($1, $2);
	} elsif (/^\s*(\w+)\s+(\w+)\s*$/) {
		write_client($1, $2);
	}
}
