Skip to content

Commit

Permalink
Merge pull request #32 from tuxpeople/fix/config
Browse files Browse the repository at this point in the history
fix: Various config and script fixes
  • Loading branch information
tuxpeople authored Jan 4, 2022
2 parents 187c272 + acaf85c commit fed30d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ RUN echo "@community http://dl-cdn.alpinelinux.org/alpine/edge/community" >> /et
# which is compiled against libstdc++
COPY ./ressources/${TARGETARCH}/*.jar /opt/JDownloader/libs/
COPY ./root/ /
COPY ./config/default-config.json.dist /opt/JDownloader/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.dist
COPY ./config/default-config.json.dist /etc/JDownloader/settings.json.dist
COPY ./scripts/configure.sh /usr/bin/configure

EXPOSE 3129
16 changes: 8 additions & 8 deletions root/etc/cont-init.d/30-prepare-jdownloader
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/bin/sh
#!/usr/bin/with-contenv sh

SETTINGSFILE="/opt/JDownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json"

# Login user with env credentials - Please prefer command way
if [ -n "$MYJD_USER" ] && [ -n "$MYJD_PASSWORD" ]; then
configure "$MYJD_USER" "$MYJD_PASSWORD"
if [ -n "${MYJD_USER}" ] && [ -n "${MYJD_PASSWORD}" ]; then
/usr/bin/configure "${MYJD_USER}" "$MYJD_PASS{WORD"
fi

# Defining device name to jdownloader interface - please prefer this method than changing on MyJDownloader to keep correct binding
if [ -n "$MYJD_DEVICE_NAME" ]; then
if [ -n "${MYJD_DEVICE_NAME}" ]; then
jq --arg v "${MYJD_DEVICE_NAME}" '.devicename = $v' ${SETTINGSFILE} | sponge ${SETTINGSFILE}
fi

Expand All @@ -20,7 +20,7 @@ fi

# Check if settings file exists
if [ ! -f ${SETTINGSFILE} ]; then
cp /opt/JDownloader/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.dist ${SETTINGSFILE}
cp /etc/JDownloader/settings.json.dist ${SETTINGSFILE}
fi

# Check JDownloader.jar integrity and removes it in case it's not
Expand All @@ -41,7 +41,7 @@ if [ ! -f /opt/JDownloader/JDownloader.jar ]; then
fi

# Defines umask - should respect octal format
if echo "$UMASK" | grep -Eq '0[0-7]{3}' ; then
echo "Defining umask to $UMASK"
umask "$UMASK"
if echo "${UMASK}" | grep -Eq '0[0-7]{3}' ; then
echo "Defining umask to ${UMASK}"
umask "${UMASK}"
fi
2 changes: 1 addition & 1 deletion scripts/configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ if [ ! $# -eq 2 ]; then
fi

if [ ! -f ${SETTINGSFILE} ]; then
cp /opt/JDownloader/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.dist ${SETTINGSFILE}
cp /etc/JDownloader/settings.json.dist ${SETTINGSFILE}
fi

jq --arg v "${2}" '.password = $v' ${SETTINGSFILE} | sponge ${SETTINGSFILE}
Expand Down

0 comments on commit fed30d5

Please sign in to comment.