From 177c0955be7907eef60e9363aa6092c3118e07de Mon Sep 17 00:00:00 2001 From: prilka Date: Sat, 3 Aug 2019 11:05:11 +0200 Subject: [PATCH] auto create myjdownloader config --- alpine.Dockerfile | 2 +- common/entrypoint.sh | 11 +++++++++++ debian.Dockerfile | 2 +- 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/alpine.Dockerfile b/alpine.Dockerfile index 19f6ba0..001a6f4 100644 --- a/alpine.Dockerfile +++ b/alpine.Dockerfile @@ -4,7 +4,7 @@ MAINTAINER PlusMinus # Create directory, and start JD2 for the initial update and creation of config files. RUN apk update && apk upgrade && \ - apk add --no-cache --quiet tini su-exec shadow ffmpeg && \ + apk add --no-cache --quiet tini su-exec shadow ffmpeg jq && \ mkdir -p /opt/JDownloader/libs && \ wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" http://installer.jdownloader.org/JDownloader.jar && \ java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar diff --git a/common/entrypoint.sh b/common/entrypoint.sh index 6f2f589..4df666f 100755 --- a/common/entrypoint.sh +++ b/common/entrypoint.sh @@ -21,6 +21,17 @@ else usermod -ag $GID fi +# Set MyJDownloader credentials +CONFIG_FILE="/opt/JDownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" +if [ ! -z "$EMAIL" ] ; then + if [ ! -f "$CONFIG_FILE" ] || [ ! -s "$CONFIG_FILE" ] ; then + echo '{}' > "$CONFIG_FILE" + fi + + CFG=$(jq -r --arg EMAIL "$EMAIL" --arg PASSWORD "$PASSWORD" '.email = $EMAIL | .password = $PASSWORD' "$CONFIG_FILE") + [ ! -z "$CFG" ] && echo "$CFG" > "$CONFIG_FILE" +fi + chown -R $UID:$GID /opt/JDownloader # Sometimes this gets deleted. Just copy it every time. diff --git a/debian.Dockerfile b/debian.Dockerfile index b6c0577..c955418 100644 --- a/debian.Dockerfile +++ b/debian.Dockerfile @@ -4,7 +4,7 @@ MAINTAINER PlusMinus # Create directory, and start JD2 for the initial update and creation of config files. RUN apt-get update && apt-get dist-upgrade -yqq && \ - apt-get install -yqq tini ffmpeg wget make gcc && \ + apt-get install -yqq tini ffmpeg wget make gcc jq && \ mkdir -p /opt/JDownloader/libs && \ wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" http://installer.jdownloader.org/JDownloader.jar && \ java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar && \