communigate provisioning phase 2: add svc_domain.trailer -> communigate TrailerText...
[freeside.git] / bin / generate-raddb
1 #!/usr/bin/perl
2
3 # usage: generate-raddb radius-server/raddb/dictionary* >raddb.pm
4 #  i.e.: generate-raddb ~/freeradius/freeradius-1.0.5/share/dictionary* ~/wirelessoceans/dictionary.ip3networks ~/wtxs/dictionary.mot.canopy >raddb.pm.new
5 print <<END;
6 package FS::raddb;
7 use vars qw(%attrib);
8
9 %attrib = (
10 END
11
12 while (<>) {
13   next if /^(#|\s*$|\$INCLUDE\s+)/;
14   next if /^(VALUE|VENDOR|BEGIN\-VENDOR|END\-VENDOR)\s+/;
15   /^(ATTRIBUTE|ATTRIB_NMC)\s+([\w\-\/]+)\s+/ or die $_;
16   $attrib = $2;
17   $dbname = lc($2);
18   $dbname =~ s/[\-\/]/_/g;
19   $dbname = substr($dbname,0,24);
20   while ( exists $hash{$dbname} ) {
21     #warn $dbname;
22     $dbname =~ s/(.)$//;
23     my $w = $1;
24     $w =~ tr/_a-z0-9/a-z0-9_/;
25     $dbname = "$dbname$w";
26   }
27   $hash{$dbname} = $attrib;
28   #print "$2\n";
29 }
30
31 foreach ( sort keys %hash ) {
32 #  print "$_\n" if length($_)>24;
33 #  print substr($_,0,24),"\n" if length($_)>24; 
34 #  $max = length($_) if length($_)>$max;
35 # have to fudge things since everything >24 is *not* unique
36
37   #print "  '". substr($_,0,24). "' => '$hash{$_}',\n";
38   print "  '$_' ". ( " " x (24-length($_) ) ). "=> '$hash{$_}',\n";
39 }
40
41 print <<END;
42
43   #NETC.NET.AU (RADIATOR?)
44   'authentication_type'      => 'Authentication-Type',
45
46   #wtxs (dunno)
47   #'radius_operator'          => 'Radius-Operator',
48
49 );
50
51 1;
52 END
53