use a shell script to start SMF and detach stdin/stdout/stderr

(Boeing r1822)
This commit is contained in:
ahrenholz 2014-01-22 17:31:40 +00:00
parent a69396d1d5
commit 3b01f99e2c

View file

@ -83,16 +83,21 @@ class NrlSmf(NrlService):
''' Simplified Multicast Forwarding for MANET networks. ''' Simplified Multicast Forwarding for MANET networks.
''' '''
_name = "SMF" _name = "SMF"
_startup = ("nrlsmf", ) _startup = ("sh startsmf.sh", )
_shutdown = ("killall nrlsmf", ) _shutdown = ("killall nrlsmf", )
_validate = ("pidof nrlsmf", ) _validate = ("pidof nrlsmf", )
_configs = ("startsmf.sh", )
@classmethod @classmethod
def getstartup(cls, node, services): def generateconfig(cls, node, filename, services):
''' Generate the appropriate command-line based on node interfaces. ''' Generate a startup script for SMF. Because nrlsmf does not
daemonize, it can cause problems in some situations when launched
directly using vcmd.
''' '''
cmd = cls._startup[0] cfg = "#!/bin/sh\n"
cmd += " instance %s_smf" % node.name cfg += "# auto-generated by nrl.py:NrlSmf.generateconfig()\n"
comments = ""
cmd = "nrlsmf instance %s_smf" % (node.name)
servicenames = map(lambda x: x._name, services) servicenames = map(lambda x: x._name, services)
netifs = filter(lambda x: not getattr(x, 'control', False), \ netifs = filter(lambda x: not getattr(x, 'control', False), \
@ -101,13 +106,16 @@ class NrlSmf(NrlService):
return () return ()
if "arouted" in servicenames: if "arouted" in servicenames:
comments += "# arouted service is enabled\n"
cmd += " tap %s_tap" % (node.name,) cmd += " tap %s_tap" % (node.name,)
cmd += " unicast %s" % cls.firstipv4prefix(node, 24) cmd += " unicast %s" % cls.firstipv4prefix(node, 24)
cmd += " push lo,%s resequence on" % netifs[0].name cmd += " push lo,%s resequence on" % netifs[0].name
if len(netifs) > 0: if len(netifs) > 0:
if "NHDP" in servicenames: if "NHDP" in servicenames:
comments += "# NHDP service is enabled\n"
cmd += " ecds " cmd += " ecds "
elif "OLSR" in servicenames: elif "OLSR" in servicenames:
comments += "# OLSR service is enabled\n"
cmd += " smpr " cmd += " smpr "
else: else:
cmd += " cf " cmd += " cf "
@ -116,7 +124,9 @@ class NrlSmf(NrlService):
cmd += " hash MD5" cmd += " hash MD5"
cmd += " log /var/log/nrlsmf.log" cmd += " log /var/log/nrlsmf.log"
return (cmd, )
cfg += comments + cmd + " < /dev/null > /dev/null 2>&1 &\n\n"
return cfg
addservice(NrlSmf) addservice(NrlSmf)