From 08cb2da105c79b6e4407cf6fc296da9d6b7410fc Mon Sep 17 00:00:00 2001 From: gotofoo Date: Sat, 4 Mar 2017 23:24:03 +0100 Subject: [PATCH 1/8] Add ability to specify a UID and GID --- Dockerfile | 5 +---- startJD2.sh | 27 +++++++++++++++++++++++---- 2 files changed, 24 insertions(+), 8 deletions(-) diff --git a/Dockerfile b/Dockerfile index 296c237..d46ea50 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,7 +1,6 @@ FROM openjdk:8-jre -MAINTAINER PlusMinus - +MAINTAINER GoToFoo # Create directory, downloader JD" and start JD2 for the initial update and creation of config files. RUN \ @@ -9,10 +8,8 @@ RUN \ wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" --progress=bar:force http://installer.jdownloader.org/JDownloader.jar && \ java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar - COPY startJD2.sh /opt/JDownloader/ RUN chmod +x /opt/JDownloader/startJD2.sh - # Run this when the container is started CMD /opt/JDownloader/startJD2.sh diff --git a/startJD2.sh b/startJD2.sh index 99c32c9..790f1fe 100755 --- a/startJD2.sh +++ b/startJD2.sh @@ -7,11 +7,30 @@ function stopJD2 { exit } +if [ "$GID" ] +then + GROUP=jdownloader + groupadd -g $GID $GROUP +else + GROUP=root +fi + +if [ "$UID" ] +then + USER=jdownloader + useradd -r -s /bin/false -u $UID -g $GROUP $USER + chown -R $USER:$GROUP /opt/JDownloader +else + USER=root +fi + trap stopJD2 EXIT -java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar & +su -c "java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar" -s /bin/bash $USER -while true; do - sleep inf -done +#java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar & + +#while true; do +# sleep inf +#done From e82c5db0fd2c195b61204e4afcbc38b1c3b2f9fd Mon Sep 17 00:00:00 2001 From: gotofoo Date: Sat, 4 Mar 2017 23:49:25 +0100 Subject: [PATCH 2/8] Update the readme file for UID and GID --- README.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 46c3f70..7e3e74d 100644 --- a/README.md +++ b/README.md @@ -2,11 +2,24 @@ Headless JDownloader 2 Docker Container ## Running the container -0. `sudo su` -1. Create a folder on your host for the configuration files (eg. sudo mkdir /config/jd2) -2. run `docker run -d --name jd2 -v /config/jd2:/opt/JDownloader/cfg -v /home/user/Downloads:/root/Downloads plusminus/jdownloader2-headless` -3. stop the container `docker stop jd2` -4. On your host, enter your credentials (in quotes) to the file `org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in `{ "password" : "mypasswort", "email" : "email@home.org" }` -5. Start the container +0. `sudo su` +1. Create a folder on your host for the configuration files (eg. sudo mkdir /config/jd2) +2. Run the container: + `docker run -d --name jd2 -v /config/jd2:/opt/JDownloader/cfg -v /home/user/Downloads:/downloads gotofoo/jdownloader2-headless` +3. Wait a minute for the container to initialize +4. Stop the container: + + `docker stop jd2` +5. On your host, enter your credentials (in quotes) to the file `org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in: + + `{ "password" : "mypasswort", "email" : "email@home.org" }` +6. Start the container: +    `docker start jd2` + +## Optional environment variables +|Environment Variable|Description| +|--------------------|-----------| +|UID|Specifies the UID the daemon should run as. All created files will be owned by this UID. Defaults to 0 for root.| +|GID|Specifies the GID for all created files. This only works in combination with the UID. Defaults to 0 for root.| From 4a8746ab8a37dfdf3a9b8ecc943e1a112c15071d Mon Sep 17 00:00:00 2001 From: gotofoo Date: Sun, 5 Mar 2017 00:01:50 +0100 Subject: [PATCH 3/8] Tidy up --- README.md | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7e3e74d..6edced7 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,19 @@ -# headless-jd2-docker +# docker-jdownloader2-headless Headless JDownloader 2 Docker Container ## Running the container -0. `sudo su` +0. Become root: + + `sudo su` 1. Create a folder on your host for the configuration files (eg. sudo mkdir /config/jd2) 2. Run the container: - `docker run -d --name jd2 -v /config/jd2:/opt/JDownloader/cfg -v /home/user/Downloads:/downloads gotofoo/jdownloader2-headless` + ``` + docker run -d --name jd2 \ + -v /config/jd2:/opt/JDownloader/cfg \ + -v /home/user/Downloads:/downloads \ + gotofoo/jdownloader2-headless + ``` 3. Wait a minute for the container to initialize 4. Stop the container: From aa1db2e8e56a0b40a70f3f8eb71368fbf6d40c60 Mon Sep 17 00:00:00 2001 From: gotofoo Date: Sun, 5 Mar 2017 00:06:40 +0100 Subject: [PATCH 4/8] Update README.md --- README.md | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 6edced7..20587eb 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,11 @@ Headless JDownloader 2 Docker Container ## Running the container 0. Become root: - - `sudo su` + ``` + sudo su + ``` 1. Create a folder on your host for the configuration files (eg. sudo mkdir /config/jd2) 2. Run the container: - ``` docker run -d --name jd2 \ -v /config/jd2:/opt/JDownloader/cfg \ @@ -16,14 +16,17 @@ Headless JDownloader 2 Docker Container ``` 3. Wait a minute for the container to initialize 4. Stop the container: - - `docker stop jd2` + ``` + docker stop jd2 + ``` 5. On your host, enter your credentials (in quotes) to the file `org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in: - - `{ "password" : "mypasswort", "email" : "email@home.org" }` + ``` + { "password" : "mypasswort", "email" : "email@home.org" } + ``` 6. Start the container: - -    `docker start jd2` +    ``` + docker start jd2 + ``` ## Optional environment variables |Environment Variable|Description| From f5740bc7c3631afb5a7d1718f472f1beb2a9ce2a Mon Sep 17 00:00:00 2001 From: gotofoo Date: Sun, 5 Mar 2017 00:09:26 +0100 Subject: [PATCH 5/8] Update README.md --- README.md | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 20587eb..f7ef4a5 100644 --- a/README.md +++ b/README.md @@ -3,11 +3,13 @@ Headless JDownloader 2 Docker Container ## Running the container 0. Become root: + ``` sudo su ``` 1. Create a folder on your host for the configuration files (eg. sudo mkdir /config/jd2) 2. Run the container: + ``` docker run -d --name jd2 \ -v /config/jd2:/opt/JDownloader/cfg \ @@ -16,15 +18,18 @@ Headless JDownloader 2 Docker Container ``` 3. Wait a minute for the container to initialize 4. Stop the container: + ``` docker stop jd2 ``` 5. On your host, enter your credentials (in quotes) to the file `org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in: + ``` { "password" : "mypasswort", "email" : "email@home.org" } ``` 6. Start the container: -    ``` + + ``` docker start jd2 ``` From 243384c7b09d0fe438109b2b864b23aa9eec2bf8 Mon Sep 17 00:00:00 2001 From: PlusMinus0 Date: Wed, 20 Sep 2017 17:48:07 +0200 Subject: [PATCH 6/8] Reset Dockerfile --- Dockerfile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index d46ea50..296c237 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,6 +1,7 @@ FROM openjdk:8-jre -MAINTAINER GoToFoo +MAINTAINER PlusMinus + # Create directory, downloader JD" and start JD2 for the initial update and creation of config files. RUN \ @@ -8,8 +9,10 @@ RUN \ wget -O /opt/JDownloader/JDownloader.jar --user-agent="https://hub.docker.com/r/plusminus/jdownloader2-headless/" --progress=bar:force http://installer.jdownloader.org/JDownloader.jar && \ java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar + COPY startJD2.sh /opt/JDownloader/ RUN chmod +x /opt/JDownloader/startJD2.sh + # Run this when the container is started CMD /opt/JDownloader/startJD2.sh From 0173222fb14a7ec3ff6b3c34b1e1f6cc079f01b5 Mon Sep 17 00:00:00 2001 From: PlusMinus0 Date: Wed, 20 Sep 2017 17:54:27 +0200 Subject: [PATCH 7/8] Fix name in README --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f7ef4a5..1f33a8d 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,8 @@ -# docker-jdownloader2-headless +# headless-jd2-docker Headless JDownloader 2 Docker Container ## Running the container -0. Become root: +0. Become root if your user is not part of the docker group: ``` sudo su @@ -14,7 +14,7 @@ Headless JDownloader 2 Docker Container docker run -d --name jd2 \ -v /config/jd2:/opt/JDownloader/cfg \ -v /home/user/Downloads:/downloads \ - gotofoo/jdownloader2-headless + plusminus/jdownloader2-headless ``` 3. Wait a minute for the container to initialize 4. Stop the container: From 27b22ae05a475e5e9c7ebc4728444b1cc0766aa4 Mon Sep 17 00:00:00 2001 From: PlusMinus0 Date: Wed, 20 Sep 2017 18:18:54 +0200 Subject: [PATCH 8/8] =?UTF-8?q?Readdad=20inf=20loop=20and=20forking=20beca?= =?UTF-8?q?use=20I=E2=80=99m=20sure=20I=20had=20reasons=20tha=20last=20tim?= =?UTF-8?q?e=20I=20did=20it.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- startJD2.sh | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/startJD2.sh b/startJD2.sh index 790f1fe..f72887b 100755 --- a/startJD2.sh +++ b/startJD2.sh @@ -18,19 +18,19 @@ fi if [ "$UID" ] then USER=jdownloader - useradd -r -s /bin/false -u $UID -g $GROUP $USER - chown -R $USER:$GROUP /opt/JDownloader + useradd -r -s /bin/false -u $UID $USER else USER=root fi +useradd -G $GROUP $USER +chown -R $USER:$GROUP /opt/JDownloader + trap stopJD2 EXIT -su -c "java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar" -s /bin/bash $USER +su -c "java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar &" -s /bin/bash $USER -#java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar & - -#while true; do -# sleep inf -#done +while true; do + sleep inf +done