From 3b01f99e2c2ad23214e65c08086297c2f669b581 Mon Sep 17 00:00:00 2001 From: ahrenholz Date: Wed, 22 Jan 2014 17:31:40 +0000 Subject: [PATCH] use a shell script to start SMF and detach stdin/stdout/stderr (Boeing r1822) --- daemon/core/services/nrl.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/daemon/core/services/nrl.py b/daemon/core/services/nrl.py index d0275662..871ff048 100644 --- a/daemon/core/services/nrl.py +++ b/daemon/core/services/nrl.py @@ -83,16 +83,21 @@ class NrlSmf(NrlService): ''' Simplified Multicast Forwarding for MANET networks. ''' _name = "SMF" - _startup = ("nrlsmf", ) + _startup = ("sh startsmf.sh", ) _shutdown = ("killall nrlsmf", ) _validate = ("pidof nrlsmf", ) + _configs = ("startsmf.sh", ) @classmethod - def getstartup(cls, node, services): - ''' Generate the appropriate command-line based on node interfaces. + def generateconfig(cls, node, filename, services): + ''' 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] - cmd += " instance %s_smf" % node.name + cfg = "#!/bin/sh\n" + cfg += "# auto-generated by nrl.py:NrlSmf.generateconfig()\n" + comments = "" + cmd = "nrlsmf instance %s_smf" % (node.name) servicenames = map(lambda x: x._name, services) netifs = filter(lambda x: not getattr(x, 'control', False), \ @@ -101,13 +106,16 @@ class NrlSmf(NrlService): return () if "arouted" in servicenames: + comments += "# arouted service is enabled\n" cmd += " tap %s_tap" % (node.name,) cmd += " unicast %s" % cls.firstipv4prefix(node, 24) cmd += " push lo,%s resequence on" % netifs[0].name if len(netifs) > 0: if "NHDP" in servicenames: + comments += "# NHDP service is enabled\n" cmd += " ecds " elif "OLSR" in servicenames: + comments += "# OLSR service is enabled\n" cmd += " smpr " else: cmd += " cf " @@ -116,7 +124,9 @@ class NrlSmf(NrlService): cmd += " hash MD5" cmd += " log /var/log/nrlsmf.log" - return (cmd, ) + + cfg += comments + cmd + " < /dev/null > /dev/null 2>&1 &\n\n" + return cfg addservice(NrlSmf)