Changeset 10069 in genesis


Ignore:
Timestamp:
Mar 9, 2012, 8:56:40 PM (13 years ago)
Author:
rick
Message:

Nice motd example.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • tools/gformat.py

    r10067 r10069  
    6363    'rc.conf.local',
    6464    'resolv.conf',
     65    'motd',
    6566    'wleiden.yaml',
    6667    ]
     
    383384  output += "\n"
    384385  for iface,addrs in sorted(addrs_list.iteritems()):
    385     for addr,comment in addrs:
     386    for addr, comment in addrs:
     387      ifacedump['iface'] = iface
    386388      output += "# %s || %s || %s\n" % (iface, addr, comment)
    387389    output += "ipv4_addrs_%s='%s'\n\n" % (iface_map[iface], " ".join([x[0] for x in addrs]))
     
    482484  return output
    483485
     486def generate_motd(datadump):
     487  """ Generate configuration file '/etc/motd' """
     488  output = """\
     489FreeBSD 9.0-RELEASE (kernel.wleiden) #0 r230587: Sun Jan 29 17:09:57 CET 2012
     490
     491  WWW: %(autogen_fqdn)s.wleiden.net - http://www.wirelessleiden.nl
     492
     493Interlinks:
     494""" % datadump
     495
     496  # XXX: This is a hacky way to get the required data
     497  for line in generate_rc_conf_local(datadump).split('\n'):
     498    if '||' in line and not line[1:].split()[0] in ['lo0', 'ath0'] :
     499      output += " - %s \n" % line[1:]
     500  output += """\
     501Attached bridges:
     502"""
     503  for iface_key in datadump['autogen_iface_keys']:
     504    ifacedump = datadump[iface_key]
     505    if ifacedump.has_key('ns_ip'):
     506      output += " - %(interface)s || %(mode)s || %(ns_ip)s\n" % ifacedump
     507
     508  return output
    484509
    485510
     
    567592    elif config == 'resolv.conf':
    568593      output += generate_resolv_conf(datadump_extra)
     594    elif config == 'motd':
     595      output += generate_motd(datadump_extra)
    569596    else:
    570597      assert False, "Config not found!"
Note: See TracChangeset for help on using the changeset viewer.