forked from jaymoulin/docker-jdownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.sh
executable file
·24 lines (19 loc) · 1.12 KB
/
configure.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/bin/bash
usage="$(basename "$0") <email> <password>"
if [ ! $# -eq 2 ]; then
echo "$usage"
exit 1
fi
if [ ! -f /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json ]; then
cp /opt/jdownloader/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json.dist /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
fi
if [ -f /opt/jdownloader/credentials ]; then
cred=($(cat /opt/jdownloader/cfg/credentials))
sed -i "s/\"password\" : \"${cred[1]}\",/\"password\" : \"$2\",/" /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json && \
sed -i "s/\"email\" : \"${cred[0]}\"/\"email\" : \"$1\"/" /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
else
sed -i "s/\"password\" : null,/\"password\" : \"$2\",/" /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json && \
sed -i "s/\"email\" : null/\"email\" : \"$1\"/" /opt/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json
fi
echo -e "$1\n$2" > /opt/jdownloader/credentials
pkill -f "JDownloader"