Remove rules.py requirement

master
Simon 2 years ago
parent f7804a2515
commit 3da95c45a2

@ -38,9 +38,6 @@ class FD_APIUserDefinedContext(object):
def reset(self,system):
self.CONFIG['SYSTEMS'][system]['_reset'] = True
def queue(self,system,options):
self.APIQUEUE.append((system,options))
def options(self,system,options):
self.CONFIG['SYSTEMS'][system]['OPTIONS'] = options
@ -48,17 +45,6 @@ class FD_APIUserDefinedContext(object):
class FD_API(ServiceBase):
_version = 0.1
#def validateHMAC(_hmac,_system):
# self._config = self._CONFIG['SYSTEMS'][_system]
# _h = blake2b(key=self._config['_opt_key'], digest_size=16)
# _h.update('validate')
# _hash = _h.digest()
# if _hash == _hmac:
# return(True)
# else:
# return(False)
#return API version
@rpc(Unicode, _returns=Decimal())
def version(ctx, sessionid):

@ -2671,7 +2671,7 @@ if __name__ == '__main__':
# CLI argument parser - handles picking up the config file from the command line, and sending a "help" message
parser = argparse.ArgumentParser()
parser.add_argument('-c', '--config', action='store', dest='CONFIG_FILE', help='/full/path/to/config.file (usually hblink.cfg)')
parser.add_argument('-r', '--rules', action='store', dest='RULES_FILE', help='/full/path/to/rules.file (usually rules.py)')
#parser.add_argument('-r', '--rules', action='store', dest='RULES_FILE', help='/full/path/to/rules.file (usually rules.py)')
parser.add_argument('-l', '--logging', action='store', dest='LOG_LEVEL', help='Override config file logging level.')
cli_args = parser.parse_args()
@ -2698,8 +2698,8 @@ if __name__ == '__main__':
CONFIG = config.build_config(cli_args.CONFIG_FILE)
# Ensure we have a path for the rules file, if one wasn't specified, then use the default (top of file)
if not cli_args.RULES_FILE:
cli_args.RULES_FILE = os.path.dirname(os.path.abspath(__file__))+'/rules.py'
#if not cli_args.RULES_FILE:
# cli_args.RULES_FILE = os.path.dirname(os.path.abspath(__file__))+'/rules.py'
# Start the system logger
if cli_args.LOG_LEVEL:
@ -2745,13 +2745,13 @@ if __name__ == '__main__':
# Import the ruiles file as a module, and create BRIDGES from it
spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
rules_module = importlib.util.module_from_spec(spec)
try:
spec.loader.exec_module(rules_module)
logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
except (ImportError, FileNotFoundError):
sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
#spec = importlib.util.spec_from_file_location("module.name", cli_args.RULES_FILE)
#rules_module = importlib.util.module_from_spec(spec)
#try:
# spec.loader.exec_module(rules_module)
# logger.info('(ROUTER) Routing bridges file found and bridges imported: %s', cli_args.RULES_FILE)
#except (ImportError, FileNotFoundError):
#sys.exit('(ROUTER) TERMINATING: Routing bridges file not found or invalid: {}'.format(cli_args.RULES_FILE))
#Load pickle of bridges if it's less than 25 seconds old
#if os.path.isfile('bridge.pkl'):
@ -2768,7 +2768,10 @@ if __name__ == '__main__':
#os.unlink("bridge.pkl")
#else:
BRIDGES = make_bridges(rules_module.BRIDGES)
BRIDGES = make_bridges({'9990': [{'SYSTEM': 'ECHO', 'TS': 2, 'TGID': 9990, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},]}
)
#Subscriber map for unit calls - complete with test entry

@ -24,8 +24,6 @@ services:
mem_reservation: 600m
volumes:
- '/etc/freedmr/freedmr.cfg:/opt/freedmr/freedmr.cfg'
- '/var/log/freedmr/:/opt/freedmr/log/'
- '/etc/freedmr/rules.py:/opt/freedmr/rules.py'
#Write JSON files outside of container
- '/etc/freedmr/json/:/opt/freedmr/json/'

@ -176,8 +176,6 @@ TGID_TS2_ACL: PERMIT:ALL
ANNOUNCEMENT_LANGUAGE: en_GB
EOF
echo Install rules.py ...
echo "BRIDGES = {'9990': [{'SYSTEM': 'ECHO', 'TS': 2, 'TGID': 9990, 'ACTIVE': True, 'TIMEOUT': 2, 'TO_TYPE': 'NONE', 'ON': [], 'OFF': [], 'RESET': []},]}" > /etc/freedmr/rules.py &&
echo Set perms on config directory...
chown -R 54000 /etc/freedmr &&

@ -27,5 +27,5 @@ else
echo 'Starting in FreeDMR mode...'
python /opt/freedmr/hotspot_proxy_v2.py &
python /opt/freedmr/playback.py -c loro.cfg &
python /opt/freedmr/bridge_master.py -c freedmr.cfg -r rules.py
python /opt/freedmr/bridge_master.py -c freedmr.cfg
fi

Loading…
Cancel
Save

Powered by TurnKey Linux.