Index: config/iris/node/FreeBSD/7-STABLE/INSTALL.txt
===================================================================
--- config/iris/node/FreeBSD/7-STABLE/INSTALL.txt	(revision 8612)
+++ config/iris/node/FreeBSD/7-STABLE/INSTALL.txt	(revision 8612)
@@ -0,0 +1,63 @@
+!!! BEGIN WARNING !!!
+This script are NOT written to run in a production envirionment,
+people who has access to the subversion genesis directory all allowed to
+put marvilous code in there, which will potentially ruin your machine
+!!! END WARNING !!!!
+
+
+In order to get the genesis webinterface up and running we need to
+configure some bits and pieces:
+* Apache
+* Subversion (in order to update)
+* Perl
+
+So lets get started:
+#Make a working directory and jump to it
+$mkdir /usr/local/www/data/genesis
+$cd /usr/local/www/data/genesis
+
+#Make a checkout of the genesis directory
+$svn co http://svn.wirelessleiden.nl/svn/node-config/genesis .
+#Allow the webserver to update nodes
+$chown -R www:www nodes
+
+#Make local config file
+$mv tools/FreeBSD6_x/genesis.conf.local{.tmpl,}
+
+#Edit the following variables $home, $server, $cgi_dir (and others and
+#needed)
+$vim tools/FreeBSD6_x/genesis.conf.local
+
+Next job, apache configuration
+=== begin httpd.conf ===
+<VirtualHost *:80>
+   ServerName wlconfig
+   ServerAlias wlconfig.wzoeterwoude.net
+   ServerAlias rick.wleiden.net
+   ServerAlias 172.27.129.66
+   DocumentRoot "/usr/local/www/data/genesis"
+
+    ErrorLog "|/usr/local/sbin/rotatelogs \
+    /var/log/httpd/wlconfig.wzoeterwoude.net-error-%Y-%m-%d.log 5M"
+    CustomLog "|/usr/local/sbin/rotatelogs \
+    /var/log/httpd/wlconfig.wzoeterwoude.net-access-%Y-%m-%d.log 5M" combined
+
+
+   DirectoryIndex g_list.pl
+   AddHandler cgi-script .pl
+
+   <Directory "/usr/local/www/data/genesis">
+      Options +ExecCGI
+      AllowOverride None
+      Allow from all
+   </Directory>
+
+</VirtualHost>
+=== begin httpd.conf ===
+
+Restart apache and hit your webbrowser to the configured webpage
+
+Thats all folks :-), questions/problems/suggestions ->
+<beheer@lijst.wirelessleiden.nl> (english/dutch)
+
+/Rick <rick@wirelessleiden.nl>
Index: config/iris/node/FreeBSD/7-STABLE/g_list.pl
===================================================================
--- config/iris/node/FreeBSD/7-STABLE/g_list.pl	(revision 8612)
+++ config/iris/node/FreeBSD/7-STABLE/g_list.pl	(revision 8612)
@@ -0,0 +1,328 @@
+#!/usr/bin/perl
+#
+# Copyright 2005 Stichting Wireless Leiden
+# Rick van der Zwet
+#
+
+# Config located at other file
+my $conf_file="./genesis.conf";
+do($conf_file) || die("Cann't open $conf_file");
+
+
+
+my $HTML=1;
+my @HTTP_BODY = ();
+
+#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
+#programma gestopt kan worden
+sub printline {
+  push(@HTTP_BODY,  "$_[0]\n");
+};
+
+sub filelist {
+  foreach $file ( sort @filelist) {
+    if( $HTML) {
+      printline("$file<BR>");
+    }
+    else {
+      printline($file);
+    };
+  };
+}
+
+sub listnodes {
+  opendir(DIR, $ndir) || die "can't opendir $ndir: $!";
+  @tmpdirs = grep { /^[^\.]/ && -d "$ndir/$_" } readdir(DIR);
+  closedir DIR;
+  foreach $dir (sort @tmpdirs) {
+    no warnings "once";
+    if( not exists($removefromnodelist{$dir}) )
+    {
+      push(@nodelist, $dir);
+    }
+    else
+    {
+    if ( $debug ) { print "'$dir' removed from list\n"; }
+    }
+    use warnings "once";
+  };
+  return @nodelist;
+}
+
+sub nodelist {
+  foreach $node (listnodes( )) {
+    if( $HTML) {
+      printline("$node<BR>");
+    }
+    else {
+      printline("$node\n");
+    };
+  };
+}
+
+#REQUEST parsen
+$request=$ENV{'REQUEST_URI'};
+if( $request=~/.*g_list.pl\/(.*)$/) {
+  ($node,$file)=split(/\//,$1);
+  $title="$node $file";
+  if ( $debug ) { print "Node: $node\n"; }
+  if ( $debug ) { print "File: $file\n"; }
+}
+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) {
+  $HTML=0;
+}
+else {
+  $HTML=1;
+  printline("<HTML>");
+  printline("<TITLE>Genesis $title</TITLE>");
+  printline("<BODY BGcolor=white>");
+};
+
+
+#als geen node gespecificeerd dan kijken of svn geupdate is gevraagd
+if( $node eq '') {
+  if( $ENV{"QUERY_STRING"}=~/update/i) {
+    printline("<PRE>");
+    #select(STDERR); $| = 1;     # make unbuffered
+    #select(STDOUT); $| = 1;     # make unbuffered
+    printline(`$svn update $ndir`);
+    printline("</PRE>");
+    printline("<H2>Done.<H2><P>");
+    printline("Click <A HREF=$source>here</A>");
+    printline("if you're not forwarded automaticly in 5 seconds.<P>");
+    printline("<META HTTP-EQUIV=REFRESH CONTENT=5;URL=$source>");
+  }
+  else {
+   g_list( );
+  }
+}
+elsif( $node eq 'filelist' ) {
+  filelist( );
+}
+elsif( $node eq 'nodelist' ) {
+  nodelist( );
+}
+else {
+  if( $file eq '') {
+      filelist( );
+  }
+  elsif( $file eq 'config') {
+    g_print($hostname);
+  }
+  else {
+    foreach my $tmpFile ( sort @filelist) {
+      if( $file eq $tmpFile ) {
+        g_generate($file);
+      };
+    };
+  };
+};
+
+#plaats de sluit HTML tags
+if( $HTML) {
+  printline("</BODY></HTML>");
+}
+
+$output = join('',@HTTP_BODY);
+print "Content-Length: " . length($output) . " \n";
+print "Content-type: text/html\n\n";
+print $output;
+
+
+#Het opbouwen van het begin scherm
+sub g_list {
+  if( $HTML) {
+    my $svn_version=svn_version("$ndir");
+    if( $svn_version=~/Last Changed Rev: (\d+)/) {
+      $revision=$1;
+    };
+    printline("<H1>Genesis config - last changed rev $revision</H1><P>\n<PRE>");
+    printline("$svn_version");
+    printline("</PRE>");
+    printline("<FORM METHOD=get ACTION=$source>");
+    printline('<INPUT TYPE="submit" NAME="Update" VALUE="Update">');
+    printline("</FORM>");
+    printline("<TABLE BORDER=1>");
+  };
+
+  @dirs = listnodes( );
+  foreach $dir (sort @dirs) {
+    if( $dir=~/attic/ ) {
+      next;
+    };
+    my $node = $dir;
+    if( ! $HTML ) {
+      printline("$node");
+    }
+    else {
+      printline("<TR><TD><A HREF=g_list.pl/$node/config>$node</A></TD>");
+      foreach $file (sort @filelist) {
+        printline("<TD><A HREF=g_list.pl/$node/$file>$file</A></TD>\n");
+      };
+    };
+  };
+  if( $HTML ) {
+    printline("</TABLE><P>");
+  };
+};
+
+
+
+#ophalen svn versie
+sub svn_version {
+  local($file)=@_;
+  local($svn_version);
+  $svn_version=`$svn info $file`;
+  return($svn_version);
+};
+
+
+
+#netjes de configuratie printen
+sub g_print {
+  my $config="$ndir/$node/$configfile";
+  parse_config($config);
+    
+ printline("<H1>Genesis configuratie voor: $node</H1><P>");
+ printline("<PRE>" . svn_version($config) . "</PRE><P>");
+
+
+ no warnings "once";
+ 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) {
+     printline("<TR bgcolor=$color><TD ROWSPAN=%d VALIGN=TOP><B>$if</TD>\n",(1+$subs{$if})*3,$subs{$if});
+     $c=4;
+   }
+   else {
+     $c=3;
+     printline("<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>");
+ no warnings "once";
+};
+
+
+
+#Generen config
+sub g_generate {
+  my $file=$_[0];
+  $config="$ndir/$node/$configfile";
+  $svn_versiont=svn_version($toolfile);
+  $svn_versionc=svn_version($config);
+
+  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;
+    printline("<PRE>$pr</PRE>");
+  } else {
+    @HTTP_BODY = $pr;
+  };
+};
Index: config/iris/node/FreeBSD/7-STABLE/genesis.conf
===================================================================
--- config/iris/node/FreeBSD/7-STABLE/genesis.conf	(revision 8612)
+++ config/iris/node/FreeBSD/7-STABLE/genesis.conf	(revision 8612)
@@ -0,0 +1,67 @@
+#!/usr/bin/perl -w
+use Cwd;
+#
+# Variable file
+
+$NG = 0;
+
+#debugging variable
+$debug=0;
+
+#author credits
+$author="feb 2003 jasper\@WirelessLeiden.NL \| maart 2005/jul 2009 rick\@WirelessLeiden.NL";
+
+#filelist
+@filelist = ();
+$filelist[0]="dhcpd.conf";
+$filelist[1]="rc.node.local";
+$filelist[2]="resolv.conf";
+#$filelist[3]="named.conf";
+$filelist[4]="txtconfig";
+$filelist[5]="authorized_keys";
+$filelist[6]="dnsmasq.conf";
+
+#Ignore this node diretories
+%removefromnodelist = (
+                      'retired' => 'YES',
+                      'obsolete' => 'YES',
+                       );
+
+#(inter)net env
+if( defined $ENV{'SERVER_NAME'} ) {
+  $hostname=$ENV{'SERVER_NAME'};
+}
+else {
+  $hostname=`hostname`;
+};
+
+chomp($hostname);
+$cgi_dir="http://$hostname/freebsd/iris";
+$source="$cgi_dir/g_list.pl";
+
+#path variablen
+$home=getcwd . "/../../";
+$ndir="$home/nodes";
+$toolfile="$home/freebsd/iris/wleiden.pl";
+
+
+#exec vars
+$svn="/usr/local/bin/svn";
+$wicontrol='/usr/sbin/wicontrol';
+
+#naming vars
+$configfile="wleiden.conf";
+
+#module IP.pm
+$IP_pmPath="$home/tools/IP.pm";
+
+#dnsheader.conf
+$dnsheader_confPath="$home/dns/dnsheader.conf";
+
+
+## ssh key variablen ##
+#global ssh_keys
+$global_keyPath="$home/nodes/global_keys";
+#node specific
+$ssh_file='ssh_key'
+
Index: config/iris/node/FreeBSD/7-STABLE/genesis.conf.local.tmpl
===================================================================
--- config/iris/node/FreeBSD/7-STABLE/genesis.conf.local.tmpl	(revision 8612)
+++ config/iris/node/FreeBSD/7-STABLE/genesis.conf.local.tmpl	(revision 8612)
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+#
+# Local variable file
+
+#path variablen
+$home="/usr/local/www/data/genesis";
+$conf_file="$home/tools/FreeBSD6_x/genesis.conf";
+
+
+#(inter)net env
+if( defined $ENV{'SERVER_NAME'} ) {
+  $hostname=$ENV{'SERVER_NAME'};
+}
+else {
+  $hostname=`hostname`;
+};
+
+chomp($hostname);
+$cgi_dir="http://$hostname/freebsd/6.0";
+$source="$cgi_dir/g_list.pl";
+
+#exec vars
+$svn="/usr/local/bin/svn";
+$wicontrol='/usr/sbin/wicontrol';
+
Index: config/iris/node/FreeBSD/7-STABLE/wleiden.pl
===================================================================
--- config/iris/node/FreeBSD/7-STABLE/wleiden.pl	(revision 8612)
+++ config/iris/node/FreeBSD/7-STABLE/wleiden.pl	(revision 8612)
@@ -0,0 +1,361 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2005 Stichting Wireless Leiden
+# maart 2004 rick@wirelessleiden.nl
+#
+
+# Config located at other file
+my $conf_file="./genesis.conf";
+do($conf_file) || die("Cann't open $conf_file");
+################ END OF CONFIG ##########################
+
+#variablen
+my $time=gmtime();
+my $source=`/bin/hostname`;
+chomp($source);
+
+
+#slurp IP berekeningen info
+do ("$IP_pmPath") || die ("Cann't open $IP_pmPath");
+#slurp dns info
+do ("$dnsheader_confPath") || die ("Cann't open $dnsheader_confPath");
+
+
+#zoek uit of het master_ip addr voorkomt in de configs
+#belangrijk van aliassen
+sub master_ipNotUsed {
+  if( $debug ) {
+    print "running master_ipNotUsed...\n";
+  }
+  foreach my $if (keys %config) {
+    if( $IP{$if} =~ /([0-9\.]+).*/ ) {
+      if( $1 eq $master_ip ) {
+        return(0);
+      };
+    };
+  };
+  return(1);
+};
+
+
+
+sub genHeader {
+  my $comment = $_[0];
+  my $output =
+  "$comment This file specific to wireless\n" .
+  "$comment leiden. Please make all changes in Genesis.\n" .
+  "$comment\n" .
+  "$comment Generated by $source\n" .
+  "$comment on $time\n" .
+  "$comment\n" .
+  "$comment  $author\n" .
+  "$comment\n\n\n";
+  return ($output);
+};
+
+
+sub txtconfig {
+  my $output = "";
+  foreach $interface (keys %config) {
+    $output .= $config{$interface};
+  };
+  return($output);
+};
+
+
+sub dnsmasq_conf {
+  my $output = genHeader("#");
+  $output .=
+    "# DHCP server options \n" .
+    "dhcp-authoritative \n" .
+    "dhcp-fqdn \n" .
+    "domain=dhcp.$nodename.$domain. \n" .
+    "domain-needed \n" .
+    "expand-hosts \n" .
+    "\n" .
+    "# Low memory footprint \n" .
+    "cache-size=10000 \n" .
+    "\n";
+
+  foreach my $interface (sort keys %config) {
+    if( $interface =~ /^[a-z]+[0-9]+$/i ) {
+      (my $ip, my $netmask) = split('/', $IP{$interface});
+      my $subnet = IP::toSubnet($netmask);
+      
+      $output .=
+      "## $interface $DESC{$interface}\n";
+      
+      if ( $DHCP{$interface} =~ /[0-9]+\-[0-9]+/i ) {
+        my $dhcp_part = $ip;
+        $dhcp_part =~ s/[0-9]+$//;
+        (my $dhcp_start, my $dhcp_stop) = $DHCP{$interface} =~ /([0-9]+)\-([0-9]+)/i;
+        $dhcp_start = $dhcp_part . $dhcp_start;
+        $dhcp_stop = $dhcp_part . $dhcp_stop;
+        $output .= "dhcp-range=$interface,$dhcp_start,$dhcp_stop,$subnet,24h\n\n";
+      }
+      else {
+       $output .= "# not autoritive \n\n";
+      };
+    };
+  };
+  
+  return($output);
+};
+
+
+sub dhcpd_conf {
+  my $output = genHeader("#");
+  $output .=
+  "option domain-name \"$domain\";\n" .
+  " \n" .
+  "default-lease-time 7200;\n" .
+  "max-lease-time 2592000;\n" .
+  "\n" .
+  "ddns-update-style none;\n" .
+  "\n" .
+  "# Hack for the WET11\n" .
+  "#\n" .
+  "always-broadcast on;\n" .
+  "\n" .
+  "option domain-name-servers ${master_ip};\n" .
+  "\n";
+
+  foreach my $interface (sort keys %config) {
+    if( $interface =~ /^[a-z]+[0-9]+$/i ) {
+      (my $ip, my $netmask) = split('/', $IP{$interface});
+      my $subnet = IP::toSubnet($netmask);
+      my $broadcast = IP::getBroadcastAddr($ip, $subnet);
+      my $network = IP::getNetworkAddr($ip, $subnet);
+      
+      $output .=
+      "# $interface $DESC{$interface}\n";
+      
+      if ( $DHCP{$interface} =~ /[0-9]+\-[0-9]+/i ) {
+        my $dhcp_part = $ip;
+        $dhcp_part =~ s/[0-9]+$//;
+        (my $dhcp_start, my $dhcp_stop) = $DHCP{$interface} =~ /([0-9]+)\-([0-9]+)/i;
+        $dhcp_start = $dhcp_part . $dhcp_start;
+        $dhcp_stop = $dhcp_part . $dhcp_stop;
+        $output .=
+        "subnet $network netmask $subnet {\n" .
+        "  range $dhcp_start $dhcp_stop;\n" .
+        "  option broadcast-address $broadcast;\n" .
+        "  option subnet-mask $subnet;\n" .
+        "  option routers $ip;\n" .
+	$DHCP_STATIC{$if} .
+        "}\n" .
+        "\n";
+      }
+      else {
+       $output .=
+       "subnet $network netmask $subnet {not authoritative; }\n" .
+       "\n";
+      };
+    };
+  };
+  
+  return($output);
+};
+
+sub named_conf {
+  my $output = genHeader("#");
+  $output .=
+  "options {\n" .
+  "  directory \"/etc/namedb\"\;\n" .
+  "  pid-file \"/var/run/named/pid\"\;\n" .
+  "  forwarders {\n";
+  foreach my $forward (@forwarder) {
+    $output .= "$forward;\n";
+  };
+  $output .= 
+  "  };\n" .
+  "};\n" .
+  "\n" .
+  "\n" .
+  "zone \"\.\" {\n" .
+  "  type hint;\n" .
+  "  file \"/etc/namedb/named.root\"\;\n" .
+  "}\;\n" .
+  "\n" .
+  "zone \"0\.0\.127\.IN-ADDR.ARPA\" {\n" .
+  "  type master\;\n" .
+  "  file \"/etc/namedb/master/localhost.rev\"\;\n" .
+  "}\;\n" .
+  "\n" .
+  "zone \"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT\" {\n" .
+  "  type master\;\n" .
+  "  file \"/etc/namedb/master/localhost-v6.rev\"\;\n" .
+  "};\n" .
+  "\n";
+
+
+  foreach my $tmpZone (sort keys %zone) {
+    my $dnsZone = $zone{$tmpZone};
+    $output .= 
+    "zone \"$tmpZone\" {\n" .
+    "  type slave\;\n" .
+    "  file \"slave/slave-$tmpZone\"\;\n" .
+    "  masters {\n";
+    foreach my $tmpIP (sort @$dnsZone) {
+      $output .= "    $tmpIP\;\n";
+    };
+    $output .= 
+    "  };\n" .
+    "};\n" .
+    "\n";
+  };
+  
+  return($output);
+};
+
+
+
+sub rc_node_local {
+  my $output = genHeader("#");
+  my $masterNotUsed = master_ipNotUsed();
+  $output.=
+  "hostname=\"$nodetype$nodename.$domain\"\n" .
+  "location=\"$location\"\n" .
+  "\n";
+
+  if( $tproxy ) {
+    if( $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/ ) {
+      $output .=
+      "# Tproxy is ran on this system\n".
+      "tproxy_enable='YES'\n".
+      "tproxy_range='$tproxy'\n".
+      "\n";
+    }
+    elsif( $tproxy !~ m/no/i ) {
+      $output .= "# WARNING - specification propably wrong - check " .
+      "genesis. It should be a pure CIDR\n";
+    };
+  };
+  
+  $output .= "ifconfig_lo0_alias0=\"inet 172.31.255.1/32\"\n";
+  if( $masterNotUsed ) {
+    $output .= "ifconfig_lo0_alias1=\"inet $master_ip/32\"\n\n";
+  }
+  else {
+    $output .= "#ifconfig_lo0_alias1=\"inet $master_ip/32\"\n\n";
+  };
+
+  foreach my $interface (sort keys %config) {
+    (my $if, my $number) = split(/:/, $interface);
+      if( defined $number ) {
+        $output .= "ifconfig_$if\_alias$number=\"inet $IP{$interface}\"\n";
+      }
+      else {
+        $output .= "ifconfig_$if=\"inet $IP{$interface}";
+        $output .= " $CARD_OPTION{$interface}";
+        if( $TYPE{$if} =~ /wireless/i ) {
+          $output .= " ssid $ESSID{$interface}";
+          if ( $SUBTYPE{$if} =~ /802.11a/i ) {
+            $output .= " mode 11a";
+          } elsif ( $SUBTYPE{$if} =~ /802.11g/i ) {
+            $output .= " mode 11g";
+          } else {
+            # Default output
+            $output .= " mode 11b";
+          }
+
+          if( $MODE{$if}=~/master/i ) {
+            $output .= " channel $CHANNEL{$interface}";
+            $output .= " mediaopt hostap";
+          }
+          else {
+            $output .= "";
+          };
+        };
+        $output .= "\"\n";
+      };
+  };
+  return($output);
+};
+
+
+sub resolv_conf {
+  my $output = genHeader"#";
+
+  $output .= 
+  "search wleiden.net.\n" .
+  "# Try local (cache) first \n" .
+  "nameserver 127.0.0.1\n" .
+  "\n";
+
+  $output .=
+  "# proxies are also nameservers \n" .
+  "nameserver 172.17.8.68    # proxy1\n" .
+  "nameserver 172.17.143.4   # proxy2\n" .
+  "nameserver 172.20.128.98  # proxy3\n" .
+  "nameserver 172.16.2.254   # proxy4\n" .
+  "nameserver 172.19.168.66  # proxy5\n" .
+  "nameserver 172.16.3.146   # proxy6\n" .
+  "nameserver 172.17.16.66   # proxy62\n" .
+  "nameserver 172.22.0.66    # proxy_zwaluw\n";
+
+  return($output);
+};
+
+
+sub parse_config {
+  my $workingfile = $_[0];
+  do($workingfile) || die("Cann't open/parse $workingfile");
+  foreach my $if (keys %config) {
+    my $cfg=$config{$if};
+    while ($cfg) {
+      $cfg=~s/^([^\n\r]+)[\r\n]*//m;
+      my $line=$1;
+      $line=~s/\s*#.*//;
+      if (((my $name, my $value)=split(/=/,$line)) eq 2) {
+        my $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\";$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
+        eval($doit);
+      };
+      $cfg=~s/[\r\n]*$//m;
+    };
+  };
+};
+
+sub authorized_keys {
+  my $output = genHeader("#");
+  if( -e "$global_keyPath" ) {
+    open( GLOBAL, "$global_keyPath" ) || die ("Cann't open $global_keyPath");
+      $output .= join("", <GLOBAL>);
+    close( GLOBAL );
+  }
+  else {
+    $output .= "# No $global_keyPath\n";
+  };
+ 
+  if( -e "$ndir/$nodetype$nodename/$ssh_file" ) {
+    open( NODE, "$ndir/$nodetype$nodename/$ssh_file" ) || die ("Cann't open $home/$nodename/$ssh_file");
+      $output .= join("", <NODE>);
+    close( NODE );
+  }
+  else {
+    $output .= "# No $ndir/$nodetype$nodename/$ssh_file\n";
+  };
+  
+  return($output);
+};
+
+sub do_it {
+  my $file = $_[0];
+  my $body = "";
+  
+  $file =~ s/\./_/g;
+  $body=&$file;
+  return($body);
+};
+
+if( exists $ARGV[0] ) {
+  if( exists $ARGV[1] ) {
+    parse_config($ARGV[0]);
+    print do_it($ARGV[1]);
+  }
+  else {
+    print "Usage `perl wleiden.pl 'inputfile' 'outputfile'`\n";
+  };
+};
+
+1;
Index: config/iris/proxy/FreeBSD/8.0-RELEASE/INSTALL.txt
===================================================================
--- config/iris/proxy/FreeBSD/8.0-RELEASE/INSTALL.txt	(revision 8612)
+++ config/iris/proxy/FreeBSD/8.0-RELEASE/INSTALL.txt	(revision 8612)
@@ -0,0 +1,63 @@
+!!! BEGIN WARNING !!!
+This script are NOT written to run in a production envirionment,
+people who has access to the subversion genesis directory all allowed to
+put marvilous code in there, which will potentially ruin your machine
+!!! END WARNING !!!!
+
+
+In order to get the genesis webinterface up and running we need to
+configure some bits and pieces:
+* Apache
+* Subversion (in order to update)
+* Perl
+
+So lets get started:
+#Make a working directory and jump to it
+$mkdir /usr/local/www/data/genesis
+$cd /usr/local/www/data/genesis
+
+#Make a checkout of the genesis directory
+$svn co http://svn.wirelessleiden.nl/svn/node-config/genesis .
+#Allow the webserver to update nodes
+$chown -R www:www nodes
+
+#Make local config file
+$mv tools/FreeBSD6_x/genesis.conf.local{.tmpl,}
+
+#Edit the following variables $home, $server, $cgi_dir (and others and
+#needed)
+$vim tools/FreeBSD6_x/genesis.conf.local
+
+Next job, apache configuration
+=== begin httpd.conf ===
+<VirtualHost *:80>
+   ServerName wlconfig
+   ServerAlias wlconfig.wzoeterwoude.net
+   ServerAlias rick.wleiden.net
+   ServerAlias 172.27.129.66
+   DocumentRoot "/usr/local/www/data/genesis"
+
+    ErrorLog "|/usr/local/sbin/rotatelogs \
+    /var/log/httpd/wlconfig.wzoeterwoude.net-error-%Y-%m-%d.log 5M"
+    CustomLog "|/usr/local/sbin/rotatelogs \
+    /var/log/httpd/wlconfig.wzoeterwoude.net-access-%Y-%m-%d.log 5M" combined
+
+
+   DirectoryIndex g_list.pl
+   AddHandler cgi-script .pl
+
+   <Directory "/usr/local/www/data/genesis">
+      Options +ExecCGI
+      AllowOverride None
+      Allow from all
+   </Directory>
+
+</VirtualHost>
+=== begin httpd.conf ===
+
+Restart apache and hit your webbrowser to the configured webpage
+
+Thats all folks :-), questions/problems/suggestions ->
+<beheer@lijst.wirelessleiden.nl> (english/dutch)
+
+/Rick <rick@wirelessleiden.nl>
Index: config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl
===================================================================
--- config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl	(revision 8612)
+++ config/iris/proxy/FreeBSD/8.0-RELEASE/g_list.pl	(revision 8612)
@@ -0,0 +1,345 @@
+#!/usr/bin/perl
+#
+# Copyright 2005 Stichting Wireless Leiden
+# Rick van der Zwet
+#
+
+# Config located at other file
+my $conf_file="./genesis.conf";
+do($conf_file) || die("Cann't open $conf_file");
+
+
+
+my $HTML=1;
+my @HTTP_BODY = ();
+
+#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
+#programma gestopt kan worden
+sub printline {
+  push(@HTTP_BODY,  "$_[0]\n");
+};
+
+sub filelist {
+  foreach $file ( sort @filelist) {
+    if( $HTML) {
+      printline("$file<BR>");
+    }
+    else {
+      printline($file);
+    };
+  };
+}
+
+sub listnodes {
+  opendir(DIR, $ndir) || die "can't opendir $ndir: $!";
+  @tmpdirs = grep { /^[^\.]/ && -d "$ndir/$_" } readdir(DIR);
+  closedir DIR;
+  foreach $dir (sort @tmpdirs) {
+    no warnings "once";
+    my $remove = 0;
+    foreach $pattern (@removefromnodelist) {
+      print $pattern;
+       if ($dir =~ /$pattern/i) {
+          $remove = 1;
+          break;
+       }
+    };
+    if( $remove == 0 )
+    {
+      push(@nodelist, $dir);
+    }
+    else
+    {
+    if ( $debug ) { print "'$dir' removed from list\n"; }
+    }
+    use warnings "once";
+  };
+  # Looks like magic, but actually just sorting an array, first based on
+  # the Alpha key and next numerics sort on the numeric port
+  return sort {
+     $a =~ m/^([a-zA-Z]+)([0-9]+)$/; $nameA = $1; $numberA = $2;
+     $b =~ m/^([a-zA-Z]+)([0-9]+)$/; $nameB = $1; $numberB = $2;
+     if ($nameA == $nameB) {
+      $numberA <=> $numberB;
+     } else {
+       $nameA cmp $nameB;
+     } } @nodelist;
+}
+
+sub nodelist {
+  foreach $node (listnodes( )) {
+    if( $HTML) {
+      printline("$node<BR>");
+    }
+    else {
+      printline("$node\n");
+    };
+  };
+}
+
+#REQUEST parsen
+$request=$ENV{'REQUEST_URI'};
+if( $request=~/.*g_list.pl\/(.*)$/) {
+  ($node,$file)=split(/\//,$1);
+  $title="$node $file";
+  if ( $debug ) { print "Node: $node\n"; }
+  if ( $debug ) { print "File: $file\n"; }
+}
+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) {
+  $HTML=0;
+}
+else {
+  $HTML=1;
+  printline("<HTML>");
+  printline("<TITLE>Genesis $title</TITLE>");
+  printline("<BODY BGcolor=white>");
+};
+
+
+#als geen node gespecificeerd dan kijken of svn geupdate is gevraagd
+if( $node eq '') {
+  if( $ENV{"QUERY_STRING"}=~/update/i) {
+    printline("<PRE>");
+    #select(STDERR); $| = 1;     # make unbuffered
+    #select(STDOUT); $| = 1;     # make unbuffered
+    printline(`$svn update $ndir`);
+    printline("</PRE>");
+    printline("<H2>Done.<H2><P>");
+    printline("Click <A HREF=$source>here</A>");
+    printline("if you're not forwarded automaticly in 5 seconds.<P>");
+    printline("<META HTTP-EQUIV=REFRESH CONTENT=5;URL=$source>");
+  }
+  else {
+   g_list( );
+  }
+}
+elsif( $node eq 'filelist' ) {
+  filelist( );
+}
+elsif( $node eq 'nodelist' ) {
+  nodelist( );
+}
+else {
+  if( $file eq '') {
+      filelist( );
+  }
+  elsif( $file eq 'config') {
+    g_print($hostname);
+  }
+  else {
+    foreach my $tmpFile ( sort @filelist) {
+      if( $file eq $tmpFile ) {
+        g_generate($file);
+      };
+    };
+  };
+};
+
+#plaats de sluit HTML tags
+if( $HTML) {
+  printline("</BODY></HTML>");
+}
+
+$output = join('',@HTTP_BODY);
+print "Content-Length: " . length($output) . " \n";
+print "Content-type: text/html\n\n";
+print $output;
+
+
+#Het opbouwen van het begin scherm
+sub g_list {
+  if( $HTML) {
+    my $svn_version=svn_version("$ndir");
+    if( $svn_version=~/Last Changed Rev: (\d+)/) {
+      $revision=$1;
+    };
+    printline("<H1>Genesis config - last changed rev $revision</H1><P>\n<PRE>");
+    printline("$svn_version");
+    printline("</PRE>");
+    printline("<FORM METHOD=get ACTION=$source>");
+    printline('<INPUT TYPE="submit" NAME="Update" VALUE="Update">');
+    printline("</FORM>");
+    printline("<TABLE BORDER=1>");
+  };
+
+  @dirs = listnodes( );
+  foreach $dir (@dirs) {
+    if( $dir=~/attic/ ) {
+      next;
+    };
+    my $node = $dir;
+    if( ! $HTML ) {
+      printline("$node");
+    }
+    else {
+      printline("<TR><TD><A HREF=g_list.pl/$node/config>$node</A></TD>");
+      foreach $file (sort @filelist) {
+        printline("<TD><A HREF=g_list.pl/$node/$file>$file</A></TD>\n");
+      };
+    };
+  };
+  if( $HTML ) {
+    printline("</TABLE><P>");
+  };
+};
+
+
+
+#ophalen svn versie
+sub svn_version {
+  local($file)=@_;
+  local($svn_version);
+  $svn_version=`$svn info $file`;
+  return($svn_version);
+};
+
+
+
+#netjes de configuratie printen
+sub g_print {
+  my $config="$ndir/$node/$configfile";
+  parse_config($config);
+    
+ printline("<H1>Genesis configuratie voor: $node</H1><P>");
+ printline("<PRE>" . svn_version($config) . "</PRE><P>");
+
+
+ no warnings "once";
+ 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) {
+     printline("<TR bgcolor=$color><TD ROWSPAN=%d VALIGN=TOP><B>$if</TD>\n",(1+$subs{$if})*3,$subs{$if});
+     $c=4;
+   }
+   else {
+     $c=3;
+     printline("<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>");
+ no warnings "once";
+};
+
+
+
+#Generen config
+sub g_generate {
+  my $file=$_[0];
+  $config="$ndir/$node/$configfile";
+  $svn_versiont=svn_version($toolfile);
+  $svn_versionc=svn_version($config);
+
+  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;
+    printline("<PRE>$pr</PRE>");
+  } else {
+    @HTTP_BODY = $pr;
+  };
+};
Index: config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf
===================================================================
--- config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf	(revision 8612)
+++ config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf	(revision 8612)
@@ -0,0 +1,61 @@
+#!/usr/bin/perl -w
+use Cwd;
+#
+# Variable file
+
+$NG = 0;
+
+#debugging variable
+$debug=0;
+
+#author credits
+$author="feb 2003 jasper\@WirelessLeiden.NL \| maart 2005/jul 2009 rick\@WirelessLeiden.NL \| jan 2010/jan 2010 richardvm\@WirelessLeiden.nl";
+
+#filelist
+@filelist = ();
+$filelist[0]="rc.conf.local";
+$filelist[1]="resolv.conf";
+$filelist[2]="txtconfig";
+$filelist[3]="authorized_keys";
+
+#Ignore this node diretories
+@removefromnodelist = ('retired','obsolete', '^CNode');
+
+#(inter)net env
+if( defined $ENV{'SERVER_NAME'} ) {
+  $hostname=$ENV{'SERVER_NAME'};
+}
+else {
+  $hostname=`hostname`;
+};
+
+chomp($hostname);
+$cgi_dir="http://$hostname/freebsd/proxy-8.0";
+$source="$cgi_dir/g_list.pl";
+
+#path variablen
+$home=getcwd . "/../../";
+$ndir="$home/nodes";
+$toolfile="$home/freebsd/proxy-8.0/wleiden.pl";
+
+
+#exec vars
+$svn="/usr/local/bin/svn";
+$wicontrol='/usr/sbin/wicontrol';
+
+#naming vars
+$configfile="wleiden.conf";
+
+#module IP.pm
+$IP_pmPath="$home/tools/IP.pm";
+
+#dnsheader.conf
+$dnsheader_confPath="$home/dns/dnsheader.conf";
+
+
+## ssh key variablen ##
+#global ssh_keys
+$global_keyPath="$home/nodes/global_keys";
+#node specific
+$ssh_file='ssh_key'
+
Index: config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf.local.tmpl
===================================================================
--- config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf.local.tmpl	(revision 8612)
+++ config/iris/proxy/FreeBSD/8.0-RELEASE/genesis.conf.local.tmpl	(revision 8612)
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+#
+# Local variable file
+
+#path variablen
+$home="/usr/local/www/data/genesis";
+$conf_file="$home/tools/FreeBSD6_x/genesis.conf";
+
+
+#(inter)net env
+if( defined $ENV{'SERVER_NAME'} ) {
+  $hostname=$ENV{'SERVER_NAME'};
+}
+else {
+  $hostname=`hostname`;
+};
+
+chomp($hostname);
+$cgi_dir="http://$hostname/freebsd/6.0";
+$source="$cgi_dir/g_list.pl";
+
+#exec vars
+$svn="/usr/local/bin/svn";
+$wicontrol='/usr/sbin/wicontrol';
+
Index: config/iris/proxy/FreeBSD/8.0-RELEASE/wleiden.pl
===================================================================
--- config/iris/proxy/FreeBSD/8.0-RELEASE/wleiden.pl	(revision 8612)
+++ config/iris/proxy/FreeBSD/8.0-RELEASE/wleiden.pl	(revision 8612)
@@ -0,0 +1,423 @@
+#!/usr/bin/perl -w
+#
+# Copyright 2005 Stichting Wireless Leiden
+# maart 2004 rick@wirelessleiden.nl
+#
+
+# Config located at other file
+my $conf_file="./genesis.conf";
+do($conf_file) || die("Cann't open $conf_file");
+################ END OF CONFIG ##########################
+
+#variablen
+my $time=gmtime();
+my $source=`/bin/hostname`;
+chomp($source);
+
+
+#slurp IP berekeningen info
+do ("$IP_pmPath") || die ("Cann't open $IP_pmPath");
+#slurp dns info
+do ("$dnsheader_confPath") || die ("Cann't open $dnsheader_confPath");
+
+
+#zoek uit of het master_ip addr voorkomt in de configs
+#belangrijk van aliassen
+sub master_ipNotUsed {
+  if( $debug ) {
+    print "running master_ipNotUsed...\n";
+  }
+  foreach my $if (keys %config) {
+    if( $IP{$if} =~ /([0-9\.]+).*/ ) {
+      if( $1 eq $master_ip ) {
+        return(0);
+      };
+    };
+  };
+  return(1);
+};
+
+
+
+sub genHeader {
+  my $comment = $_[0];
+  my $output =
+  "$comment This file specific to wireless\n" .
+  "$comment leiden. Please make all changes in Genesis.\n" .
+  "$comment\n" .
+  "$comment Generated by $source\n" .
+  "$comment on $time\n" .
+  "$comment\n" .
+  "$comment  $author\n" .
+  "$comment\n\n\n";
+  return ($output);
+};
+
+
+sub txtconfig {
+  my $output = "";
+  foreach $interface (keys %config) {
+    $output .= $config{$interface};
+  };
+  return($output);
+};
+
+
+sub dnsmasq_conf {
+  my $output = genHeader("#");
+  $output .=
+    "# Query all upstream dns servers by default\n" .
+    "all-servers \n" .
+    "# DHCP server options \n" .
+    "dhcp-authoritative \n" .
+    "dhcp-fqdn \n" .
+    "domain=dhcp.$nodename.$domain. \n" .
+    "bogus-priv \n" .
+    "domain-needed \n" .
+    "expand-hosts \n" .
+    "\n" .
+    "# Low memory footprint \n" .
+    "cache-size=10000 \n" .
+    "\n";
+
+  foreach my $interface (sort keys %config) {
+    if( $interface =~ /^[a-z]+[0-9]+$/i ) {
+      (my $ip, my $netmask) = split('/', $IP{$interface});
+      my $subnet = IP::toSubnet($netmask);
+      
+      $output .=
+      "## $interface $DESC{$interface}\n";
+      
+      if ( $DHCP{$interface} =~ /[0-9]+\-[0-9]+/i ) {
+        my $dhcp_part = $ip;
+        $dhcp_part =~ s/[0-9]+$//;
+        (my $dhcp_start, my $dhcp_stop) = $DHCP{$interface} =~ /([0-9]+)\-([0-9]+)/i;
+        $dhcp_start = $dhcp_part . $dhcp_start;
+        $dhcp_stop = $dhcp_part . $dhcp_stop;
+        $output .= "dhcp-range=$interface,$dhcp_start,$dhcp_stop,$subnet,24h\n\n";
+      }
+      else {
+       $output .= "# not autoritive \n\n";
+      };
+    };
+  };
+  
+  return($output);
+};
+
+
+sub dhcpd_conf {
+  my $output = genHeader("#");
+  $output .=
+  "option domain-name \"$domain\";\n" .
+  " \n" .
+  "default-lease-time 7200;\n" .
+  "max-lease-time 2592000;\n" .
+  "\n" .
+  "ddns-update-style none;\n" .
+  "\n" .
+  "# Hack for the WET11\n" .
+  "#\n" .
+  "always-broadcast on;\n" .
+  "\n" .
+  "option domain-name-servers ${master_ip};\n" .
+  "\n";
+
+  foreach my $interface (sort keys %config) {
+    if( $interface =~ /^[a-z]+[0-9]+$/i ) {
+      (my $ip, my $netmask) = split('/', $IP{$interface});
+      my $subnet = IP::toSubnet($netmask);
+      my $broadcast = IP::getBroadcastAddr($ip, $subnet);
+      my $network = IP::getNetworkAddr($ip, $subnet);
+      
+      $output .=
+      "# $interface $DESC{$interface}\n";
+      
+      if ( $DHCP{$interface} =~ /[0-9]+\-[0-9]+/i ) {
+        my $dhcp_part = $ip;
+        $dhcp_part =~ s/[0-9]+$//;
+        (my $dhcp_start, my $dhcp_stop) = $DHCP{$interface} =~ /([0-9]+)\-([0-9]+)/i;
+        $dhcp_start = $dhcp_part . $dhcp_start;
+        $dhcp_stop = $dhcp_part . $dhcp_stop;
+        $output .=
+        "subnet $network netmask $subnet {\n" .
+        "  range $dhcp_start $dhcp_stop;\n" .
+        "  option broadcast-address $broadcast;\n" .
+        "  option subnet-mask $subnet;\n" .
+        "  option routers $ip;\n" .
+	$DHCP_STATIC{$if} .
+        "}\n" .
+        "\n";
+      }
+      else {
+       $output .=
+       "subnet $network netmask $subnet {not authoritative; }\n" .
+       "\n";
+      };
+    };
+  };
+  
+  return($output);
+};
+
+sub named_conf {
+  my $output = genHeader("#");
+  $output .=
+  "options {\n" .
+  "  directory \"/etc/namedb\"\;\n" .
+  "  pid-file \"/var/run/named/pid\"\;\n" .
+  "  forwarders {\n";
+  foreach my $forward (@forwarder) {
+    $output .= "$forward;\n";
+  };
+  $output .= 
+  "  };\n" .
+  "};\n" .
+  "\n" .
+  "\n" .
+  "zone \"\.\" {\n" .
+  "  type hint;\n" .
+  "  file \"/etc/namedb/named.root\"\;\n" .
+  "}\;\n" .
+  "\n" .
+  "zone \"0\.0\.127\.IN-ADDR.ARPA\" {\n" .
+  "  type master\;\n" .
+  "  file \"/etc/namedb/master/localhost.rev\"\;\n" .
+  "}\;\n" .
+  "\n" .
+  "zone \"1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.INT\" {\n" .
+  "  type master\;\n" .
+  "  file \"/etc/namedb/master/localhost-v6.rev\"\;\n" .
+  "};\n" .
+  "\n";
+
+
+  foreach my $tmpZone (sort keys %zone) {
+    my $dnsZone = $zone{$tmpZone};
+    $output .= 
+    "zone \"$tmpZone\" {\n" .
+    "  type slave\;\n" .
+    "  file \"slave/slave-$tmpZone\"\;\n" .
+    "  masters {\n";
+    foreach my $tmpIP (sort @$dnsZone) {
+      $output .= "    $tmpIP\;\n";
+    };
+    $output .= 
+    "  };\n" .
+    "};\n" .
+    "\n";
+  };
+  
+  return($output);
+};
+
+
+
+sub rc_conf_local {
+  my $output = genHeader("#");
+  my $masterNotUsed = master_ipNotUsed();
+  $output.=
+  "hostname=\"$nodename.$domain\"\n" .
+  "location=\"$location\"\n" .
+  "\n";
+  if( $gateway ) {
+    $output .=  
+    "defaultrouter='$gateway'\n"
+  }
+  if( $tproxy ) {
+    if( $tproxy =~ m/\d+\.\d+\.\d+\.\d+\/\d+/ ) {
+      $output .=
+      "# Tproxy is ran on this system\n".
+      "tproxy_enable='YES'\n".
+      "tproxy_range='$tproxy'\n".
+      "\n";
+    }
+    elsif( $tproxy !~ m/no/i ) {
+      $output .= "# WARNING - specification propably wrong - check " .
+      "genesis. It should be a pure CIDR\n";
+    };
+  };
+  
+  $output .= "ifconfig_lo0_alias0=\"inet 172.31.255.1/32\"\n";
+  if( $masterNotUsed ) {
+    $output .= "ifconfig_lo0_alias1=\"inet $master_ip/32\"\n\n";
+  }
+  else {
+    $output .= "#ifconfig_lo0_alias1=\"inet $master_ip/32\"\n\n";
+  };
+
+  foreach my $interface (sort keys %config) {
+    (my $if, my $number) = split(/:/, $interface);
+      if( defined $number ) {
+        $output .= "ifconfig_$if\_alias$number=\"inet $IP{$interface}\"\n";
+      }
+      else {
+        if ( $DHCPCLIENT{$if} =~ /yes/i ) {
+           $output .= "ifconfig_$if=\"DHCP";
+        } else {
+           $output .= "ifconfig_$if=\"inet $IP{$interface}";
+        };
+        $output .= " $CARD_OPTION{$interface}";
+        if( $TYPE{$if} =~ /wireless/i ) {
+          $output .= " ssid $ESSID{$interface}";
+          if ( $SUBTYPE{$if} =~ /802.11a/i ) {
+            $output .= " mode 11a";
+          } elsif ( $SUBTYPE{$if} =~ /802.11g/i ) {
+            $output .= " mode 11g";
+          } else {
+            # Default output
+            $output .= " mode 11b";
+          }
+
+          if( $MODE{$if}=~/master/i ) {
+            $output .= " channel $CHANNEL{$interface}";
+            $output .= " mediaopt hostap";
+          }
+          else {
+            $output .= "";
+          };
+        };
+        $output .= "\"\n";
+      };
+  };
+  $output .= "\n";
+  $output .= "# XXX: Automagic by finding out which IP is in 172.16.0.0/12, perhaps?\n";
+  $output .= "internalif=\"" . $internalif . "\"\n";
+
+  $output .= "\n";
+  $output .= "static_routes=\"wleiden\"\n";
+
+  $output .= "route_wleiden=\"-net 172.16.0.0/12 $internalroute\"\n";
+
+
+  if( $proxyid ) {
+    # ssh-tun requires a four digit port number, so 22 + "??"
+    $proxyid = sprintf("%02i", $proxyid);
+
+    $output .= "\n";
+    $output .= "sshtun_enable=\"YES\"\n";
+    $output .= "sshtun_flags=\"-R 22$proxyid:localhost:22 \"\n";
+  }
+
+  if ( $nat =~ /yes/i ) {
+    $output .= "\n";
+    $output .= "# Firewall inbound NAT option\n";
+    $output .= "firewall_enable=\"YES\"\n";
+    $output .= "firewall_script=\"/etc/ipfw.sh\"\n";
+    $output .= "firewall_nat_enable=\"YES\"\n";
+    $output .= "gateway_enable=\"YES\"\n";
+
+  } else {
+    $output .= "\n";
+    $output .= "# Disable routing\n";
+    $output .= "gateway_enable=\"no\"\n";
+  }   
+
+  # Block these ip's
+  if ( $firewall_block ) {
+    $firewall_block=~s/\n/\ /g;
+    $output .= "\n";
+    $output .= "firewall_block=\"$firewall_block\"";
+  }
+
+  return($output);
+};
+
+
+sub resolv_conf {
+  my $output = genHeader"#";
+
+#  $output .= 
+#  "search wleiden.net.\n" .
+#  "# Try local (cache) first \n" .
+#  "nameserver 127.0.0.1\n" .
+#  "# Direct neighboors\n" .
+#  "\n";
+#
+#  foreach my $if (sort keys %config) {
+#    if( exists $POINT_TO_POINT{$if} ) {
+#      foreach my $ip ($POINT_TO_POINT{$if}) {
+#        $output .= "nameserver $ip # $DESC{$if}\n";
+#      };
+#    };
+#  };
+#
+#  $output .=
+#  "\n" .
+#  "# Last resort/backup remote nameservers \n" .
+#  "nameserver 172.17.8.68    # proxy1\n" .
+#  "nameserver 172.17.143.4   # proxy2\n" .
+#  "nameserver 172.20.128.98  # proxy3\n" .
+#  "nameserver 172.16.2.254   # proxy4\n" .
+#  "nameserver 172.19.168.66  # proxy5\n";
+
+  $output .=
+  "nameserver 8.8.8.8 # Google\n" .
+  "nameserver 8.8.4.4 # Google\n" .
+  "search wleiden.net";
+
+  return($output);
+};
+
+
+sub parse_config {
+  my $workingfile = $_[0];
+  do($workingfile) || die("Cann't open/parse $workingfile");
+  foreach my $if (keys %config) {
+    my $cfg=$config{$if};
+    while ($cfg) {
+      $cfg=~s/^([^\n\r]+)[\r\n]*//m;
+      my $line=$1;
+      $line=~s/\s*#.*//;
+      if (((my $name, my $value)=split(/=/,$line)) eq 2) {
+        my $doit="if (exists(\$$name\{\"$if\"\})) {\$$name\{\"$if\"\}.=\";$value\";} else {\$$name\{\"$if\"\}.=\"$value\";}";
+        eval($doit);
+      };
+      $cfg=~s/[\r\n]*$//m;
+    };
+  };
+};
+
+sub authorized_keys {
+  my $output = genHeader("#");
+  if( -e "$global_keyPath" ) {
+    open( GLOBAL, "$global_keyPath" ) || die ("Cann't open $global_keyPath");
+      $output .= join("", <GLOBAL>);
+    close( GLOBAL );
+  }
+  else {
+    $output .= "# No $global_keyPath\n";
+  };
+ 
+  if( -e "$ndir/$nodetype$nodename/$ssh_file" ) {
+    open( NODE, "$ndir/$nodetype$nodename/$ssh_file" ) || die ("Cann't open $home/$nodename/$ssh_file");
+      $output .= join("", <NODE>);
+    close( NODE );
+  }
+  else {
+    $output .= "# No $ndir/$nodetype$nodename/$ssh_file\n";
+  };
+  
+  return($output);
+};
+
+sub do_it {
+  my $file = $_[0];
+  my $body = "";
+  
+  $file =~ s/\./_/g;
+  $body=&$file;
+  return($body);
+};
+
+if( exists $ARGV[0] ) {
+  if( exists $ARGV[1] ) {
+    parse_config($ARGV[0]);
+    print do_it($ARGV[1]);
+  }
+  else {
+    print "Usage `perl wleiden.pl 'inputfile' 'outputfile'`\n";
+  };
+};
+
+1;
