Skip to content

Commit

Permalink
Fixes #133 - adds workaround for UID/GID on closed systems - prefer -…
Browse files Browse the repository at this point in the history
…u param
  • Loading branch information
jaymoulin committed Dec 22, 2024
1 parent e82dc44 commit 3392c4f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ WORKDIR /opt/JDownloader

CMD ["/opt/JDownloader/daemon.sh"]

RUN if [ "" = "$ISDEB" ]; then apk add --update libstdc++ ffmpeg wget procps && \
RUN if [ "" = "$ISDEB" ]; then apk add --update libstdc++ ffmpeg wget procps shadow && \
wget -O /opt/JDownloader/JDownloader.jar "http://installer.jdownloader.org/JDownloader.jar?$RANDOM" && \
chmod 777 /opt/JDownloader/ -R && \
apk del wget --purge; \
Expand Down
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ services:
MYJD_PASSWORD: bar #optional (see [Identify](https://github.com/jaymoulin/docker-jdownloader#identify))
MYJD_DEVICE_NAME: goofy #optional
XDG_DOWNLOAD_DIR: /opt/JDownloader/Downloads #optional
PUID: 1000 #optional user id - not recommanded
GID: 1000 #optional group id - not recommanded
ports:
- 3129:3129
secrets:
Expand Down Expand Up @@ -135,7 +137,7 @@ You can set many parameters when you configure this container, but you must spec
| `-v /opt/JDownloader/app/logs` | Container logs folder, specify it only if you wan to keep logs on the host |
| `-v /opt/JDownloader/app/extensions` | Extensions folder, specify it only if you wan to install extensions and keep it on the host |
| `-v /opt/JDownloader/Downloads` | Downloads folder (where you put your `download` mountpoint) |
| `-u <UID>:<GID>` | Add user identifiers to run the container with user priviledges. To obtain such values, run on your host `id yourusername`, additional information can be found in [Docker documentation](https://docs.docker.com/engine/reference/commandline/exec/#options)
| `-u <UID>:<GID>` | Add user identifiers to run the container with user privileges. To obtain such values, run on your host `id yourusername`, additional information can be found in [Docker documentation](https://docs.docker.com/engine/reference/commandline/exec/#options) |
| `-p 3129:3129` | This Network port is required for Direct Connection mode, more information in [this section](https://github.com/jaymoulin/docker-jdownloader#direct-connection) |

### Environment Variables
Expand All @@ -148,6 +150,8 @@ You can set many parameters when you configure this container, but you must spec
| `MYJD_DEVICE_NAME=goofy`| The device name that will appear on MyJdownloader portal |
| `XDG_DOWNLOAD_DIR=/opt/JDownloader/Downloads` | If you use this variable, set it as per the downloads folder volume! |
| `UMASK="0002"` | Defines specific rights for your downloaded files (default: undefined) - Must respect octal form (begins with 0 followed by three numbers between 0 and 7 included) (cf. https://en.wikipedia.org/wiki/Umask) |
| `PUID=1000` | Your user id (for your user privileges) - workaround for closed systems, prefer `-u` flag method instead [Docker documentation](https://docs.docker.com/engine/reference/commandline/exec/#options) |
| `GID=1000` | Your group id (for your user privileges) - workaround for closed systems, prefer `-u` flag method instead [Docker documentation](https://docs.docker.com/engine/reference/commandline/exec/#options) |

#### Identify
There are 3 possibilities to give login password for MyJDownloader:
Expand Down
12 changes: 11 additions & 1 deletion daemon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,16 @@ trap 'kill -TERM $PID' TERM INT
rm -f /opt/JDownloader/app/JDownloader.jar.* 2> /dev/null
rm -f /opt/JDownloader/app/JDownloader.pid 2> /dev/null

# Define PUID/GID workaround for closed systems
if [ -n "$PUID" ]; then
adduser jdown -D 2> /dev/null
usermod -u $PUID jdown
fi

if [ -n "$GID" ]; then
groupmod -g $GID jdown
fi

# Login user with docker secret or env credentials - Please prefer command way
if [ -n "$FILE_MYJD_USER" ] && [ -n "$FILE_MYJD_PASSWORD" ]; then
configure $(cat "/run/secrets/$FILE_MYJD_USER") $(cat "/run/secrets/$FILE_MYJD_PASSWORD")
Expand Down Expand Up @@ -52,7 +62,7 @@ if echo "$UMASK" | grep -Eq '0[0-7]{3}' ; then
umask "$UMASK"
fi

java -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8 -Djava.awt.headless=true -jar /opt/JDownloader/app/JDownloader.jar -norestart &
su jdown -s /bin/sh -c 'java -Dsun.jnu.encoding=UTF-8 -Dfile.encoding=UTF-8 -Djava.awt.headless=true -jar /opt/JDownloader/app/JDownloader.jar -norestart' &
PID=$!
while [ "$PID" ]
do
Expand Down

0 comments on commit 3392c4f

Please sign in to comment.