Changeset 4103 in genesis for tools/configcleaner.pl
- Timestamp:
- Mar 17, 2005, 8:31:19 PM (20 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
tools/configcleaner.pl
r4092 r4103 10 10 #maak een mooi systeem met hash aanroepen om snel gegevens te verwerken 11 11 sub parse_config { 12 13 14 15 16 17 18 19 20 21 22 23 12 foreach my $id (sort keys %config) { 13 my $rawData = $config{$id}; 14 $rawData =~ s/#.*\n/\n/g; #wegslopen comments 15 $rawData =~ s/\s*[\r,\n]+\s*/:::/g; #spaties+enter+spaties vervangen door ::: 16 $rawData =~ s/^::://; #::: aan het begin weghalen 17 $rawData =~ s/:::$//; #::: aan het eind weghalen 18 my @configArray = split( /:::/, $rawData); #array er van maken 19 foreach $line (@configArray) { 20 (my $name, my $value) = split( /\=/, $line); 21 $$name{$id} = $value; 22 } 23 } 24 24 } 25 25 26 26 27 27 sub genericConfig { 28 29 30 28 my $configfile = $_[0]; 29 open( CONF, "> $configfile"); 30 print CONF <<EOP; 31 31 # 32 32 # Config cleaned up bij configcleaner … … 45 45 \$OS='$OS'; 46 46 47 \$tproxy='$tproxy'; 47 48 EOP 48 49 50 51 52 53 49 50 if(! $static_dhcp[0] eq "" ) { 51 for( my $ctr=0; $ctr < scalar(@static_dhcp); $ctr++ ) { 52 print CONF "\$dhcp_static[$ctr]='$static_dhcp[$ctr]';" . "\n"; 53 } 54 } 54 55 55 56 57 58 59 56 foreach my $key (sort keys %config) { 57 my $keyTerminator = $key; 58 $keyTerminator =~ tr/a-z/A-Z/; 59 $keyTerminator =~ s/://; 60 print CONF <<EOP; 60 61 61 62 \$config{'$key'}=sprintf <<$keyTerminator; … … 64 65 EOP 65 66 66 67 67 if( lc($TYPE{$key}) eq "wireless" ) { 68 print CONF <<EOP; 68 69 MODE=$MODE{$key} 69 70 ESSID=$ESSID{$key} 70 71 CHANNEL=$CHANNEL{$key} 71 72 EOP 72 73 } 73 74 74 75 print CONF <<EOP; 75 76 SPEED=$SPEED{$key} 76 77 … … 82 83 EOP 83 84 84 85 85 if( lc($TYPE{$key}) eq "wireless" ) { 86 print CONF <<EOP; 86 87 87 88 POLAR=$POLAR{$key} … … 92 93 HEIGHT=$HEIGTH{$key} 93 94 EOP 94 95 96 97 98 95 } 96 print CONF "$keyTerminator" . "\n"; 97 } 98 print CONF "\n" . "# End of Config File" . "\n"; 99 close ( CONF ); 99 100 } 100 101 101 102 102 103 foreach my $file (@ARGV) { 103 104 105 106 107 108 109 110 111 112 104 if($debug) { 105 $file_output = "test.conf"; 106 } 107 else 108 {$file_output = $file; 109 } 110 print "Working on $file...\n"; 111 @$_ = [] foreach qw(static_dhcp); 112 $static_dhcp[0]=""; 113 $$_ = "" foreach qw(location master_ip gw_open nodetype nodename 113 114 OS status X Y N E OS DISK AGGREGATE); 114 115 %$_ = () foreach qw(config TYPE IP DESC SDESC SPEED DHCP DHCP_STATIC 115 116 OSPF_BROADCAST OSPF_NEIGHBORS MODE ESSID CHANNEL 116 117 POLAR ANTENNA GAIN DIRECTION BEAMWIDTH CABLE 117 118 HEIGHT ROUTE); 118 119 120 121 122 123 124 119 do($file) || die("Cann't open file"); 120 print "\t Parsing config..."; 121 parse_config; 122 print "DONE\n"; 123 print "\t Applying generic rules ..."; 124 genericConfig($file_output); 125 print "DONE\n"; 125 126 } 126 127
Note:
See TracChangeset
for help on using the changeset viewer.