Index: tools/g_list.pl
===================================================================
--- tools/g_list.pl	(revision 4079)
+++ tools/g_list.pl	(revision 4081)
@@ -1,41 +1,36 @@
-#! /usr/bin/perl -w
+#!/usr/bin/perl -w
 #
 #
 #
 
-# eerst even een subje om ervoor te zorgen dat de hostname + file bekend
-# is
-$filelist[0]="txtconfig";
-$filelist[1]="dhcpd.conf";
-$filelist[2]="rc.local";
-$filelist[3]="rc.node.local";
-$filelist[4]="resolv.conf";
-$filelist[5]="named.conf";
-$filelist[6]="snmpd.local.conf";
-
-$request=$ENV{'REQUEST_URI'};
-if ($request=~/cgi-bin\/g_list.pl\/(.*)$/) {
-  ($hostname,$file)=split(/\//,$1);
-  $title="$hostname $file";
-}
-else {
-  $title="listing";
-};
+
+#filelist
+my @filelist = ();
+$filelist[0]="dhcpd.conf";
+$filelist[1]="rc.local";
+$filelist[2]="rc.node.local";
+$filelist[3]="resolv.conf";
+$filelist[4]="named.conf";
+$filelist[5]="snmpd.local.conf";
+$filelist[6]="txtconfig";
 
 #(inter)net env
-$cgi_dir="$hostname/cgi-bin";
-$source="$cgi_dir/g_list.pl";
+my $hostname=`hostname`;
+my $cgi_dir="$hostname/cgi-bin";
+my $source="$cgi_dir/g_list.pl";
 
 #path variablen
-$home="/home/rick/svn/genesis/";
-$ndir="$home/nodes";
-$toolfile="$home/tools/wleiden.pl";
+my $home="/home/rick/svn/genesis";
+my $ndir="$home/nodes";
+my $toolfile="$home/tools/wleiden.pl";
 
 #exec vars
-$svn='/usr/local/bin/svn';
-$html=1;
-
-$functions_only=1;
-do $toolfile || die;
+my $svn="/usr/local/bin/svn";
+
+######################## END OF CONFIG ##########################
+my $html=1;
+
+#laden van tool file
+do($toolfile) || die("Cann't open $toolfile");
 
 #gebruik van simple subje om ervoor te zorgen dat de print netjes in het
@@ -46,6 +41,17 @@
 
 
-
-
+#REQUEST parsen
+$request=$ENV{'REQUEST_URI'};
+if ($request=~/cgi-bin\/g_list.pl\/(.*)$/) {
+  ($node,$file)=split(/\//,$1);
+  $title="$node $file";
+}
+else {
+  $title="listing";
+};
+
+
+#controleer wat de browser is
+#en zorgen dan er de nodige tags geprint worden
 $browser=$ENV{'HTTP_USER_AGENT'};
 if ($browser=~/curl|wget|fetch/i) {
@@ -63,5 +69,6 @@
 
 
-if ($hostname eq '') {
+#als geen node gespecificeerd dan kijken of svn geupdate is gevraagd
+if ($node eq '') {
   if ($ENV{"QUERY_STRING"}=~/update/i) {
     select(STDERR); $| = 1;     # make unbuffered
@@ -81,15 +88,6 @@
 }
 else {
-  $dir="$ndir/$hostname";
-  if (! -d $dir ) {
-    if ($HTML) {
-      print "<H1>Host $hostname not found: $dir</H1><P>\n";
-    }
-    else {
-      print "Host $hostname not found: $dir\n";
-    };
-  }
-  elsif ($file eq '') {
-    foreach $file (@filelist) {
+  if ($file eq '') {
+    foreach $file ( sort @filelist) {
       if ($HTML) {
         print "$file<BR>\n";
@@ -103,11 +101,8 @@
     g_print($hostname);
   }
-  elsif ($file eq 'txtconfig') {
-    $HTML=0;g_print($hostname);
-  }
   else {
-    foreach my $tmpFile (@filelist) {
+    foreach my $tmpFile ( sort @filelist) {
       if( $file eq $tmpFile ) {
-        g_generate($file,$hostname);
+        g_generate($file);
       };
     };
@@ -115,5 +110,5 @@
 };
 
-
+#plaats de sluit HTML tags
 if ($HTML) {
   print <<EOF;
@@ -123,4 +118,6 @@
 }
 
+
+#Het opbouwen van het begin scherm
 sub g_list {
   if ($HTML) {
@@ -151,5 +148,5 @@
     else {
       printline("<TR><TD><A HREF=g_list.pl/$hostname/config>$hostname</A></TD>");
-      foreach $file (@filelist) {
+      foreach $file (sort @filelist) {
         printline("<TD><A HREF=g_list.pl/$hostname/$file>$file</A></TD>\n");
       };
@@ -161,4 +158,5 @@
 
 
+#ophalen svn versie
 sub svn_version {
   local($file,$char)=@_;
@@ -172,156 +170,139 @@
 
 
+
+#netjes de configuratie printen
 sub g_print {
-  local($hostname)=@_;
-  $config="$ndir/$hostname/wleiden.conf";
-
-  if (! $HTML) {
-    print svn_version($config,'#');
-    open (CFG,$config) || die;
-    while (<CFG>) {print $_;}
-    close(CFG);
+  my $config="$ndir/$node/wleiden.conf";
+  parse_config($config);
+    
+ printline("<H1>Genesis configuratie voor: $node</H1><P>");
+ printline("<PRE>" . svn_version($config) . "</PRE><P>");
+
+
+ my $TP='';
+ if ($tproxy !~ m/no/i) {
+   $TP .= "\n";
+   $TP .= "Tproxy on cidr range $tproxy";
+   $TP .= "<b>WARNING - specification propably wrong - should be a cidr</b>"
+   unless $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/;
+ };
+
+ printline("<TABLE BORDER=1><TR><TD COLSPAN=4><PRE>");
+ printline("master_ip=$master_ip");
+ printline("AGGREGATE=$AGGREGATE");
+ printline("");
+ printline("gw_open=$gw_open");
+ printline("nodetype=$nodetype");
+ printline("nodename=$nodename");
+ printline("");
+ printline("NS_forward=$NS_forward");
+ printline("NS_resolv=$NS_resolv");
+ printline("");
+ printline("location=$location");
+ printline("DISK=$DISK");
+ printline("");
+ printline("X=$X");
+ printline("Y=$Y");
+ printline("");
+ printline("OS=$OS");
+ printline("");
+ printline("$TP");
+ printline("</PRE></TD></TR>");
+
+ foreach $if (sort keys %config) {
+   if ($if=~/^(.*):\d+/) {
+     $subs{$1}++;
+   };
+ };
+
+ foreach $if (sort keys %config) {
+   if ($if=~/^([^:]+)/) {
+     $mymain=$1;
+   }
+   else {
+     $mymain='';
+   };
+   
+   if ($if!~/:\d+/) {
+     $main=1;$cc='66'
+   }
+   else {
+     $main=0;
+     $cc='cc';
+   };
+   
+   if (! ($ip=$IP{$if})) {
+     $ip='dhcp?';
+   };
+   if ($TYPE{$if}=~/wireless/) {
+     $color="#${cc}FFFF";
+   };
+   if ($TYPE{$if}=~/ethernet/) {
+     $color="#FFFF${cc}";
+   };
+   
+   $cfg=$config{$if};
+   $cfg=~s/(.*KEY.*=).*/${1}***********/;
+   $cfg=~s/(.*PWD.*=).*/${1}***********/;
+   $cfg=~s/(.*CODE.*=).*/${1}***********/;
+   $cfg=~s/(.*PASS.*=).*/${1}***********/;
+
+   if ($main) {
+     printf "<TR bgcolor=$color><TD ROWSPAN=%d VALIGN=TOP><B>$if</TD>\n",(1+$subs{$if})*3,$subs{$if};
+     $c=4;
+   }
+   else {
+     $c=3;
+     print "<TR bgcolor=$color>";
+   };
+   $cfg=~s/</&lt;/gi;
+   $cfg=~s/>/&gt;/gi;
+
+   printline("<TD>$if</TD><TD><B>$ip</TD><TD>$DESC{$if}($SDESC{$if})</TD>");
+   printline("<TR><TD COLSPAN=$c><PRE>");
+   printline("$cfg");
+   printline("</PRE></TD>");
+   printline("<TR><TD COLSPAN=$c>&nbsp;</TD>");
+ };
+ printline("</TABLE>");
+};
+
+
+
+#Generen config
+sub g_generate {
+  my $file=$_[0];
+  $config="$ndir/$node/wleiden.conf";
+  $svn_versiont=svn_version($toolfile,$char);
+  $svn_versionc=svn_version($config,$char);
+
+  if ($svn_versiont=~/Last Changed Rev: (\d+)/) {
+    $tool_rev=$1;
+  };
+  if ($svn_versionc=~/Last Changed Rev: (\d+)/) {
+  $config_rev=$1;
+  };
+
+  if ($tool_rev >= $config_rev) {
+    $svn_version=$svn_versiont . $svn_versionc;
   }
   else {
-    printline("<H1>Genesis configuratie voor: $hostname</H1><P>");
-    printline("<PRE>" . svn_version($config) . "</PRE><P>");
-
-    do($config) || die;
-    parse_config();
-
-    $TP='';
-    if ($tproxy !~ m/no/i) {
-      $TP .= "\n";
-      $TP .= "Tproxy on cidr range $tproxy";
-      $TP .= "<b>WARNING - specification propably wrong - should be a cidr</b>"
-      unless $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/;
-    };
-
-    printline("<TABLE BORDER=1><TR><TD COLSPAN=4><PRE>");
-    printline("master_ip=$master_ip");
-    printline("AGGREGATE=$AGGREGATE");
-    printline("");
-    printline("gw_open=$gw_open");
-    printline("nodetype=$nodetype");
-    printline("nodename=$nodename");
-    printline("");
-    printline("NS_forward=$NS_forward");
-    printline("NS_resolv=$NS_resolv");
-    printline("");
-    printline("location=$location");
-    printline("DISK=$DISK");
-    printline("");
-    printline("X=$X");
-    printline("Y=$Y");
-    printline("");
-    printline("OS=$OS");
-    printline("");
-    printline("$TP");
-    printline("</PRE></TD></TR>");
-
-    foreach $if (sort keys %config) {
-      if ($if=~/^(.*):\d+/) {
-        $subs{$1}++;
-      };
-    };
-
-    foreach $if (sort keys %config) {
-      if ($if=~/^([^:]+)/) {
-        $mymain=$1;
-      }
-      else {
-        $mymain='';
-      };
-      
-      if ($if!~/:\d+/) {
-        $main=1;$cc='66'
-      }
-      else {
-        $main=0;
-        $cc='cc';
-      };
-      
-      if (! ($ip=$IP{$if})) {
-        $ip='dhcp?';
-      };
-      if ($TYPE{$if}=~/wireless/) {
-        $color="#${cc}FFFF";
-      };
-      if ($TYPE{$if}=~/ethernet/) {
-        $color="#FFFF${cc}";
-      };
-      
-      $cfg=$config{$if};
-      $cfg=~s/(.*KEY.*=).*/${1}***********/;
-      $cfg=~s/(.*PWD.*=).*/${1}***********/;
-      $cfg=~s/(.*CODE.*=).*/${1}***********/;
-      $cfg=~s/(.*PASS.*=).*/${1}***********/;
-
-      if ($main) {
-        printf "<TR bgcolor=$color><TD ROWSPAN=%d VALIGN=TOP><B>$if</TD>\n",(1+$subs{$if})*3,$subs{$if};
-        $c=4;
-      }
-      else {
-        $c=3;
-        print "<TR bgcolor=$color>";
-      };
-      $cfg=~s/</&lt;/gi;
-      $cfg=~s/>/&gt;/gi;
-
-      printline("<TD>$if</TD><TD><B>$ip</TD><TD>$DESC{$if}($SDESC{$if})</TD>");
-      printline("<TR><TD COLSPAN=$c><PRE>");
-      printline("$cfg");
-      printline("</PRE></TD>");
-      printline("<TR><TD COLSPAN=$c>&nbsp;</TD>");
-    };
-    printline("</TABLE>");
-  };
-};
-
-
-sub g_generate {
-  ($file,$hostname)=@_;
-  $config="$ndir/$hostname/wleiden.conf";
-
-  if (! -r $config) {
-    if ($HTML) {
-      printline("<H1>File $file not found: $config</H1><P>");
-    }
-    else {
-      printline("File $file not found: $config");
-    };
-  } 
+    $svn_version=$svn_versionc;
+  };
+
+  if ($HTML) {
+    printline("<H1>Genesis $file voor: $hostname</H1><P>");
+  };
+
+  parse_config($config);
+  $pr=do_it($file);
+
+
+  if ($HTML) {
+    $pr=~s/</&lt;/gi;
+    printline("<PRE>$pr</PRE>");
+  }
   else {
-    $svn_versiont=svn_version($toolfile,$char);
-    $svn_versionc=svn_version($config,$char);
-
-    if ($svn_versiont=~/Last Changed Rev: (\d+)/) {
-      $tool_rev=$1;
-    };
-    if ($svn_versionc=~/Last Changed Rev: (\d+)/) {
-    $config_rev=$1;
-    };
-
-    if ($tool_rev >= $config_rev) {
-      $svn_version=$svn_versiont . $svn_versionc;
-    }
-    else {
-      $svn_version=$svn_versionc;
-    };
-
-    if ($HTML) {
-      printline("<H1>Genesis $file voor: $hostname</H1><P>");
-    };
-
-    parse_config($config);
-    $pr=do_it($file);
-
-
-    if ($HTML) {
-      $pr=~s/</&lt;/gi;$mrtg=~s/>/&gt;/gi;
-      printline("<PRE>$pr</PRE>");
-    }
-    else {
-      print $pr;
-    };
-  };
-};
+    print $pr;
+  };
+};
Index: tools/wleiden.pl
===================================================================
--- tools/wleiden.pl	(revision 4079)
+++ tools/wleiden.pl	(revision 4081)
@@ -1,7 +1,7 @@
+#!/usr/bin/perl -w
 #
 #
 #  maart 2004 rick@wirelessleiden.nl
 #
-
 
 my $debug=0;
@@ -13,5 +13,4 @@
 
 #variablen
-my $workingfile = "";
 my $time=gmtime();
 my $source=`/bin/hostname -s`;
@@ -20,7 +19,7 @@
 
 #slurp IP berekeningen info
-do ($IP_pmPath) || die ("Cann't open $IP_pmPath");
+do ("$IP_pmPath") || die ("Cann't open $IP_pmPath");
 #slurp dns info
-do ($dnsheader_confPath) || die ("Cann't open $dnsheader_confPath");
+do ("$dnsheader_confPath") || die ("Cann't open $dnsheader_confPath");
 
 
@@ -35,5 +34,4 @@
       if( $1 eq $master_ip ) {
         return(0);
-        break;
       };
     };
@@ -59,10 +57,11 @@
 
 
-
 sub txtconfig {
-  my $output = `cat $workingfile`;
-  return($output);
-};
-
+  my $output = "";
+  foreach $interface (keys %config) {
+    $output .= $config{$interface};
+  };
+  return($output);
+};
 
 
@@ -169,8 +168,7 @@
 
 
-sub rc_conf {
+sub rc_local {
   my $output = genHeader("#");
   my $masterNotUsed = master_ipNotUsed();
-  print $masterNotUsed;
   $output.=
   "hostname=\"$nodetype$nodename.wLeiden.NET\"\n" .
@@ -298,14 +296,14 @@
 
 sub parse_config {
-  $workingfile = $_[0];
+  my $workingfile = $_[0];
   do($workingfile) || die("Cann't open/parse $workingfile");
-  foreach $if (keys %config) {
-    $cfg=$config{$if};
+  foreach my $if (keys %config) {
+    my $cfg=$config{$if};
     while ($cfg) {
       $cfg=~s/^([^\n\r]+)[\r\n]*//m;
-      $line=$1;
+      my $line=$1;
       $line=~s/\s*#.*//;
-      if ((($name,$value)=split(/=/,$line)) eq 2) {
-        $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\"$separator$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
+      if (((my $name, my $value)=split(/=/,$line)) eq 2) {
+        my $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\";$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
         eval($doit);
       };
@@ -324,5 +322,5 @@
 };
 
-if( $debug ) {
+if( exists $ARGV[0] ) {
   if( exists $ARGV[1] ) {
     parse_config($ARGV[0]);
@@ -333,2 +331,4 @@
   };
 };
+
+1;
