Place config in .config dir by default

This commit is contained in:
Mark Qvist 2022-09-14 16:21:34 +02:00
parent 03695565ba
commit b3d85b583f
2 changed files with 16 additions and 5 deletions

View File

@ -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"

View File

@ -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: