Index: tools/gformat.py
===================================================================
--- tools/gformat.py	(revision 10109)
+++ tools/gformat.py	(revision 10110)
@@ -44,4 +44,6 @@
 except ImportError:
     from yaml import Loader, Dumper
+
+from jinja2 import Template
 
 import logging
@@ -268,53 +270,51 @@
 def generate_rc_conf_local(datadump):
   """ Generate configuration file '/etc/rc.conf.local' """
+  datadump['ileiden_enable'] = 'yes' if datadump['ileiden'] else 'no'
+
   output = generate_header("#");
-  output += """\
-hostname='%(autogen_fqdn)s.%(domain)s'
-location='%(location)s'
-""" % datadump
-
-  # TProxy configuration
-  output += "\n"
-  try:
-    if datadump['tproxy']:
-      output += """\
+  output += Template("""\
+hostname='{{ autogen_fqdn }}.{{ domain }}'
+location='{{ location }}'
+nodetype="{{ nodetype }}"
+
+{% if tproxy -%}
 tproxy_enable='YES'
-tproxy_range='%(tproxy)s'
-""" % datadump
-  except KeyError:
-    output += "tproxy_enable='NO'\n"
-
-  # Extra Proxy configuration
-  datadump['ileiden_enable'] = 'yes' if datadump['ileiden'] else 'no'
-  if datadump['nodetype'] == 'Proxy':
-    output += """
+tproxy_range='{{ tproxy }}'
+{% else -%}
+tproxy_enable='NO'
+{% endif -%}
+
+{% if nodetype == "Proxy" %}
 #
 # PROXY Configuration
 #
 sshtun_enable="YES"
-sshtun_flags="-R 22%(proxyid)02i:localhost:22"
+sshtun_flags="-R 22{{ "%02i"|format(proxyid) }}:localhost:22"
 
 static_routes="wleiden"
-route_wleiden="-net 172.16.0.0/12 %(internalroute)s"
-defaultrouter="%(gateway)s"
-
-internalif="%(internalif)s"
+route_wleiden="-net 172.16.0.0/12 {{ internalroute }}"
+{% if gateway -%}
+defaultrouter="{{ gateway }}"
+{% else -%}
+#defaultrouter="NOTSET"
+{% endif -%}
+
+internalif="{{ internalif }}"
 
 # PROXY iLeiden Configuration
-ileiden_enable="%(ileiden_enable)s"
-gateway_enable="%(ileiden_enable)s"
-firewall_enable="%(ileiden_enable)s"
+ileiden_enable="{{ ileiden_enable }}"
+gateway_enable="{{ ileiden_enable }}"
+firewall_enable="{{ ileiden_enable }}"
 firewall_script="/etc/ipfw.sh"
-firewall_nat_enable="%(ileiden_enable)s"
-""" % datadump
-
-  if datadump['nodetype'] == 'CNode' and datadump['ileiden']:
-    output += """
+firewall_nat_enable="{{ ileiden_enable }}"
+{% endif -%}
+
+{% if nodetype == "CNode" %} 
 # NODE iLeiden Configuration
-ileiden_enable="%(ileiden_enable)s"
-
 captive_portal_whitelist=""
-captive_portal_interfaces="%(autogen_dhcp_interfaces)s"
-""" % datadump
+captive_portal_interfaces="{{ autogen_dhcp_interfaces }}"
+{% endif %}
+
+""").render(datadump)
 
   # lo0 configuration:
