diff --git a/Dockerfile b/Dockerfile index e6b0a48..5538ce1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,6 +4,8 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="True" +ENV DATA_FOLDER="/config" + WORKDIR /app COPY /requirements.txt /Varken.py /app/ @@ -17,6 +19,6 @@ COPY /utilities /app/data/utilities RUN apk add --no-cache tzdata && \ pip install --no-cache-dir -r /app/requirements.txt -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py VOLUME /config diff --git a/Dockerfile.arm b/Dockerfile.arm index 98db2c5..2a5732f 100644 --- a/Dockerfile.arm +++ b/Dockerfile.arm @@ -4,6 +4,8 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="True" +ENV DATA_FOLDER="/config" + WORKDIR /app COPY /requirements.txt /Varken.py /app/ @@ -15,6 +17,6 @@ COPY /data /app/data RUN apk add --no-cache tzdata && \ pip install --no-cache-dir -r /app/requirements.txt -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py VOLUME /config diff --git a/Dockerfile.arm64 b/Dockerfile.arm64 index 5000236..a83d917 100644 --- a/Dockerfile.arm64 +++ b/Dockerfile.arm64 @@ -4,6 +4,8 @@ LABEL maintainers="dirtycajunrice,samwiseg0" ENV DEBUG="True" +ENV DATA_FOLDER="/config" + WORKDIR /app COPY /requirements.txt /Varken.py /app/ @@ -15,6 +17,6 @@ COPY /data /app/data RUN apk add --no-cache tzdata && \ pip install --no-cache-dir -r /app/requirements.txt -CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py --data-folder /config +CMD cp /app/data/varken.example.ini /config/varken.example.ini && python3 /app/Varken.py VOLUME /config diff --git a/Varken.py b/Varken.py index 4464085..487cbea 100644 --- a/Varken.py +++ b/Varken.py @@ -4,6 +4,7 @@ from time import sleep from queue import Queue from sys import version from threading import Thread +from os import environ as env from os import access, R_OK, getenv from distro import linux_distribution from os.path import isdir, abspath, dirname, join @@ -45,8 +46,6 @@ if __name__ == "__main__": opts = parser.parse_args() - DATA_FOLDER = abspath(join(dirname(__file__), 'data')) - templogger = getLogger('temp') templogger.setLevel(DEBUG) tempch = StreamHandler() @@ -54,17 +53,15 @@ if __name__ == "__main__": tempch.setFormatter(tempformatter) templogger.addHandler(tempch) - if opts.data_folder: - ARG_FOLDER = opts.data_folder + DATA_FOLDER = env.get('DATA_FOLDER', vars(opts).get('data_folder') or abspath(join(dirname(__file__), 'data'))) - if isdir(ARG_FOLDER): - DATA_FOLDER = ARG_FOLDER - if not access(DATA_FOLDER, R_OK): - templogger.error("Read permission error for %s", DATA_FOLDER) - exit(1) - else: - templogger.error("%s does not exist", ARG_FOLDER) + if isdir(DATA_FOLDER): + if not access(DATA_FOLDER, R_OK): + templogger.error("Read permission error for %s", DATA_FOLDER) exit(1) + else: + templogger.error("%s does not exist", DATA_FOLDER) + exit(1) # Set Debug to True if DEBUG env is set enable_opts = ['True', 'true', 'yes']