mirror of
https://git.netzspielplatz.de/docker-multiarch/jdownloader2-headless.git
synced 2025-11-08 17:19:32 +00:00
Merge pull request #37 from prilka/credentials-with-env-vars
auto create myjdownloader config
This commit is contained in:
commit
e2f81c7ccf
9 changed files with 48 additions and 26 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
|
@ -2,4 +2,4 @@
|
||||||
.\#*
|
.\#*
|
||||||
\#*\#
|
\#*\#
|
||||||
.config/
|
.config/
|
||||||
goss.yaml
|
/goss.yaml
|
||||||
|
|
|
||||||
33
README.md
33
README.md
|
|
@ -9,6 +9,7 @@
|
||||||
|
|
||||||
|
|
||||||
# Running the container
|
# Running the container
|
||||||
|
|
||||||
0. Become root if your user is not part of the docker group:
|
0. Become root if your user is not part of the docker group:
|
||||||
|
|
||||||
```
|
```
|
||||||
|
|
@ -19,31 +20,25 @@
|
||||||
|
|
||||||
```
|
```
|
||||||
docker run -d --name jd2 \
|
docker run -d --name jd2 \
|
||||||
|
-e EMAIL=my@mail.com -e PASSWORD=my_secret_password
|
||||||
-v /config/jd2:/opt/JDownloader/cfg \
|
-v /config/jd2:/opt/JDownloader/cfg \
|
||||||
-v /home/user/Downloads:/opt/JDownloader/Downloads \
|
-v /home/user/Downloads:/opt/JDownloader/Downloads \
|
||||||
plusminus/jdownloader2-headless
|
plusminus/jdownloader2-headless
|
||||||
```
|
```
|
||||||
3. Wait a minute for the container to initialize
|
|
||||||
4. Stop the container:
|
|
||||||
|
|
||||||
```
|
If you don't want to specify your credentials on the command line, remove them from the command above (`-e EMAIL=... -e PASSWORD=...`)
|
||||||
docker stop jd2
|
and add them manually to the file`<config-dir>/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in
|
||||||
```
|
|
||||||
5. On your host, enter your credentials (in quotes) to the file `org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json` as in:
|
|
||||||
|
|
||||||
```
|
```
|
||||||
{ "email" : "email@home.org", "password" : "mypasswort" }
|
{ "email" : "my@mail.com", "password" : "my_secret_password" }
|
||||||
```
|
```
|
||||||
6. Start the container:
|
|
||||||
|
|
||||||
```
|
|
||||||
docker start jd2
|
|
||||||
```
|
|
||||||
|
|
||||||
# Optional environment variables
|
# Optional environment variables
|
||||||
|Environment Variable|Description|
|
Environment Variable | Description
|
||||||
|--------------------|-----------|
|
---------------------|------------
|
||||||
|UID|Specifies the UID the daemon should run as. All created files will be owned by this UID. Defaults to 1000.|
|
EMAIL | The MyJDownloader account e-mail. Is written automatically to config-file, if set.
|
||||||
|GID|Specifies the GID for all created files. This only works in combination with the UID. Defaults to 100 for users.|
|
PASSWORD | The MyJDownloader account password. Is written automatically to config-file, if set.
|
||||||
|
UID | Specifies the UID the daemon should run as. All created files will be owned by this UID. Defaults to 1000.
|
||||||
|
GID | Specifies the GID for all created files. This only works in combination with the UID. Defaults to 100 for users.
|
||||||
|
|
||||||
Not setting these will default to 1000:100.
|
Not setting `UID` / `GID` will default to `1000`:`100`.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ MAINTAINER PlusMinus <piddlpiddl@gmail.com>
|
||||||
|
|
||||||
# Create directory, and start JD2 for the initial update and creation of config files.
|
# Create directory, and start JD2 for the initial update and creation of config files.
|
||||||
RUN apk update && apk upgrade && \
|
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 && \
|
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 && \
|
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
|
java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
|
cd $(dirname $0)
|
||||||
|
|
||||||
images=('alpine' 'debian')
|
images=('alpine' 'debian')
|
||||||
|
|
||||||
if [ "$(docker version --format '{{.Server.Experimental}}')" = 'true' ]; then
|
if [ "$(docker version --format '{{.Server.Experimental}}')" = 'true' ]; then
|
||||||
|
|
@ -15,12 +17,13 @@ for image in "${images[@]}"; do
|
||||||
docker build -t $tag -f $image.Dockerfile .
|
docker build -t $tag -f $image.Dockerfile .
|
||||||
|
|
||||||
echo "Testing image"
|
echo "Testing image"
|
||||||
cp goss-default.yaml goss.yaml
|
GOSS_FILES_PATH=./tests/default dgoss run $tag
|
||||||
dgoss run $tag
|
|
||||||
|
|
||||||
echo "Testing again with UID and GID"
|
echo "Testing again with UID and GID"
|
||||||
cp goss-uid-test.yaml goss.yaml
|
GOSS_FILES_PATH=./tests/uid-test dgoss run -e UID=1001 -e GID=101 $tag
|
||||||
dgoss run -e UID=1001 -e GID=101 $tag
|
|
||||||
|
echo "Testing again with EMAIL and PASSWORD"
|
||||||
|
GOSS_FILES_PATH=./tests/credentials-test dgoss run -e EMAIL=mymail@example.com -e PASSWORD=mypassword $tag
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,17 @@ else
|
||||||
usermod -ag $GID
|
usermod -ag $GID
|
||||||
fi
|
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
|
chown -R $UID:$GID /opt/JDownloader
|
||||||
|
|
||||||
# Sometimes this gets deleted. Just copy it every time.
|
# Sometimes this gets deleted. Just copy it every time.
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ MAINTAINER PlusMinus <piddlpiddl@gmail.com>
|
||||||
|
|
||||||
# Create directory, and start JD2 for the initial update and creation of config files.
|
# Create directory, and start JD2 for the initial update and creation of config files.
|
||||||
RUN apt-get update && apt-get dist-upgrade -yqq && \
|
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 && \
|
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 && \
|
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 && \
|
java -Djava.awt.headless=true -jar /opt/JDownloader/JDownloader.jar && \
|
||||||
|
|
|
||||||
11
tests/credentials-test/goss.yaml
Normal file
11
tests/credentials-test/goss.yaml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
file:
|
||||||
|
/opt/JDownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json:
|
||||||
|
exists: true
|
||||||
|
mode:
|
||||||
|
or:
|
||||||
|
- "0664"
|
||||||
|
- "0644"
|
||||||
|
filetype: file
|
||||||
|
contains:
|
||||||
|
- mymail@example.com
|
||||||
|
- mypassword
|
||||||
|
|
@ -30,6 +30,8 @@ file:
|
||||||
package:
|
package:
|
||||||
ffmpeg:
|
ffmpeg:
|
||||||
installed: true
|
installed: true
|
||||||
|
jq:
|
||||||
|
installed: true
|
||||||
user:
|
user:
|
||||||
jdownloader:
|
jdownloader:
|
||||||
exists: true
|
exists: true
|
||||||
Loading…
Add table
Add a link
Reference in a new issue