forked from jaymoulin/docker-jdownloader
-
Notifications
You must be signed in to change notification settings - Fork 0
/
daemon.sh
executable file
·32 lines (26 loc) · 1.04 KB
/
daemon.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
25
26
27
28
29
30
31
32
#!/usr/bin/env bash
trap 'kill -TERM $PID' TERM INT
rm -f /opt/jdownloader/JDownloader.jar.*
rm -f /opt/jdownloader/JDownloader.pid
# Check if JDownloader.jar exists, or if there is an interrupted update
if [ ! -f /opt/jdownloader/JDownloader.jar ] && [ -f /opt/jdownloader/tmp/update/self/JDU/JDownloader.jar ]; then
cp /opt/jdownloader/tmp/update/self/JDU/JDownloader.jar /opt/jdownloader/
fi
# Execute VPN
if [ -f /etc/openvpn/config ] && [ -f /etc/openvpn/auth ]; then
vpnconfigfile=`cat /etc/openvpn/config`
vpnauthfile=`cat /etc/openvpn/auth`
openvpn --config $vpnconfigfile --auth-user-pass $vpnauthfile --daemon
wait $!
fi
# Execute JDownloader
java -Djava.awt.headless=true -jar /opt/jdownloader/JDownloader.jar &
PID=$!
wait $PID
wait $PID
# Debugging helper - if the container crashes, create a file called "jdownloader-block.txt" in the download folder
# The container will not terminate (and you can run "docker exec -it ... bash")
if [ -f /root/Downloads/jdownloader-block.txt ]; then
sleep 1000000
fi
EXIT_STATUS=$?