2021-09-24 11:17:23 +02:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
|
|
|
|
import RNS
|
|
|
|
import argparse
|
2021-12-05 16:05:43 +01:00
|
|
|
import time
|
2021-09-24 11:17:23 +02:00
|
|
|
|
|
|
|
from RNS._version import __version__
|
|
|
|
|
|
|
|
|
2021-12-05 16:05:43 +01:00
|
|
|
def program_setup(configdir, verbosity = 0, quietness = 0, service = False):
|
|
|
|
targetloglevel = 3+verbosity-quietness
|
|
|
|
|
|
|
|
if service:
|
|
|
|
RNS.logdest = RNS.LOG_FILE
|
|
|
|
RNS.logfile = RNS.Reticulum.configdir+"/logfile"
|
|
|
|
targetloglevel = None
|
|
|
|
|
|
|
|
reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel)
|
2021-09-24 20:05:24 +02:00
|
|
|
RNS.log("Started rnsd version {version}".format(version=__version__), RNS.LOG_NOTICE)
|
2021-09-24 11:17:23 +02:00
|
|
|
while True:
|
2021-12-05 16:05:43 +01:00
|
|
|
time.sleep(1)
|
2021-09-24 11:17:23 +02:00
|
|
|
|
|
|
|
def main():
|
|
|
|
try:
|
2021-09-24 11:26:29 +02:00
|
|
|
parser = argparse.ArgumentParser(description="Reticulum Network Stack Daemon")
|
2021-09-24 11:17:23 +02:00
|
|
|
parser.add_argument("--config", action="store", default=None, help="path to alternative Reticulum config directory", type=str)
|
2021-09-24 20:05:24 +02:00
|
|
|
parser.add_argument('-v', '--verbose', action='count', default=0)
|
|
|
|
parser.add_argument('-q', '--quiet', action='count', default=0)
|
2021-12-05 16:05:43 +01:00
|
|
|
parser.add_argument('-s', '--service', action='store_true', default=False, help="rnsd is running as a service and should log to file")
|
2021-09-24 11:17:23 +02:00
|
|
|
parser.add_argument("--version", action="version", version="rnsd {version}".format(version=__version__))
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.config:
|
|
|
|
configarg = args.config
|
|
|
|
else:
|
|
|
|
configarg = None
|
|
|
|
|
2021-12-05 16:05:43 +01:00
|
|
|
program_setup(configdir = configarg, verbosity=args.verbose, quietness=args.quiet, service=args.service)
|
2021-09-24 11:17:23 +02:00
|
|
|
|
|
|
|
except KeyboardInterrupt:
|
|
|
|
print("")
|
|
|
|
exit()
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|