Make onionr use dirs from env

This commit is contained in:
Arinerron 2019-03-28 12:03:37 -07:00
parent 66d7dae08f
commit 9bd5efce1f
No known key found for this signature in database
GPG Key ID: 99383627861C62F0
3 changed files with 10 additions and 10 deletions

View File

@ -5,7 +5,7 @@ set -e
[ "root" != "$USER" ] && exec sudo $0 "$@"
export OUTPUT_DIR=${OUTPUT_DIR:=/usr/share/onionr}
export DATA_DIR=${DATA_DIR:=/etc/onionr}
export ONIONR_HOME=${ONIONR_HOME:=/etc/onionr}
export LOG_DIR=${LOG_DIR:=/var/log/onionr}
cd "$OUTPUT_DIR"

View File

@ -64,10 +64,9 @@ class colors:
'''
Use the bitwise operators to merge these settings
'''
USE_ANSI = 0b100
if os.name == 'nt':
USE_ANSI = 0b000
else:
USE_ANSI = 0b100
OUTPUT_TO_CONSOLE = 0b010
OUTPUT_TO_FILE = 0b001
@ -80,7 +79,7 @@ LEVEL_IMPORTANT = 6
_type = OUTPUT_TO_CONSOLE | USE_ANSI # the default settings for logging
_level = LEVEL_DEBUG # the lowest level to log
_outputfile = './output.log' # the file to log to
_outputfile = 'data/onionr.log' # the file to log to
def set_settings(type):
'''

View File

@ -62,12 +62,13 @@ class Onionr:
except FileNotFoundError:
pass
try:
self.dataDir = os.environ['ONIONR_HOME']
if not self.dataDir.endswith('/'):
self.dataDir += '/'
except KeyError:
self.dataDir = 'data/'
# set data dir
self.dataDir = os.environ.get('ONIONR_HOME', os.environ.get('DATA_DIR', 'data/'))
if not self.dataDir.endswith('/'):
self.dataDir += '/'
# set log file
logger.set_file(os.environ.get('LOG_DIR', 'data') + '/onionr.log')
# Load global configuration data
data_exists = Onionr.setupConfig(self.dataDir, self = self)