From b3d85b583f312f3d942bd6ea474237b049a9f189 Mon Sep 17 00:00:00 2001 From: Mark Qvist Date: Wed, 14 Sep 2022 16:21:34 +0200 Subject: [PATCH] Place config in .config dir by default --- RNS/Reticulum.py | 14 ++++++++++++-- RNS/Utilities/rnsd.py | 7 ++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/RNS/Reticulum.py b/RNS/Reticulum.py index ce820b5..9606cc6 100755 --- a/RNS/Reticulum.py +++ b/RNS/Reticulum.py @@ -136,7 +136,8 @@ class Reticulum: # The default configuration path will be expanded to a directory # named ".reticulum" inside the current users home directory - configdir = os.path.expanduser("~")+"/.reticulum" + userdir = os.path.expanduser("~") + configdir = None configpath = "" storagepath = "" cachepath = "" @@ -163,7 +164,7 @@ class Reticulum: RNS.exit() - def __init__(self,configdir=None, loglevel=None): + def __init__(self,configdir=None, loglevel=None, logdest=None): """ Initialises and starts a Reticulum instance. This must be done before any other operations, and Reticulum will not @@ -176,6 +177,15 @@ class Reticulum: if configdir != None: Reticulum.configdir = configdir + else: + if os.path.isdir(Reticulum.userdir+"/.reticulum") and os.path.isfile(Reticulum.userdir+"/.reticulum/config"): + Reticulum.configdir = Reticulum.userdir+"/.reticulum" + else: + Reticulum.configdir = Reticulum.userdir+"/.config/reticulum" + + if logdest == RNS.LOG_FILE: + RNS.logdest = RNS.LOG_FILE + RNS.logfile = Reticulum.configdir+"/logfile" Reticulum.configpath = Reticulum.configdir+"/config" Reticulum.storagepath = Reticulum.configdir+"/storage" diff --git a/RNS/Utilities/rnsd.py b/RNS/Utilities/rnsd.py index d659eae..ec56a4d 100755 --- a/RNS/Utilities/rnsd.py +++ b/RNS/Utilities/rnsd.py @@ -33,11 +33,12 @@ 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" + targetlogdest = RNS.LOG_FILE targetloglevel = None + else: + targetlogdest = RNS.LOG_STDOUT - reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel) + reticulum = RNS.Reticulum(configdir=configdir, loglevel=targetloglevel, logdest=targetlogdest) if reticulum.is_connected_to_shared_instance: RNS.log("Started rnsd version {version} connected to another shared local instance, this is probably NOT what you want!".format(version=__version__), RNS.LOG_WARNING) else: