blob: 99fef8c87d37298b17c1893ca5f015a3ea689bb4 (
plain)
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
33
34
35
36
37
38
39
40
41
42
43
44
|
#!/usr/bin/env bash
THIS_PATH="$(dirname "$(readlink -f "$0")")"
source "$THIS_PATH/changeUser"
function showFailure(){
local FAILURE="$1"
if [ -t 0 ] ; then
echo "WARNING: $FAILURE"
else
echo "ERROR: $FAILURE"
echo "You could run \"JDownloaderHeadlessCleanLogin\" to remove entire MyJDownloader Settings."
echo "Afterwards you should run \"JDownloaderHeadless\" in a terminal"
exit 2
fi
}
#check for config
if [ ! -f "cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" ]; then
showFailure "Configurationfile not set"
fi
grep email "cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" >/dev/null
if [ $? -ne 0 ]; then
showFailure "Email seems not to be set"
fi
grep password "cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json" >/dev/null
if [ $? -ne 0 ]; then
showFailure "Password seems not to be set"
fi
LOGFILE="JDownloader.service.log"
if [ -t 0 ] ; then
exec java -Djava.awt.headless=true -jar JDownloader.jar -norestart "$@"
else
if [ -f "$LOGFILE" ]; then
# Save the old Logfile (this automatically removes the n-2 one, if there is one)
mv "${LOGFILE}" "${LOGFILE}.old"
fi
echo "All output is redirected to \"$(readlink -f "${LOGFILE}")\""
exec java -Djava.awt.headless=true -jar JDownloader.jar -norestart "$@" >"${LOGFILE}" 2>&1
fi
|