Skip to content

Instantly share code, notes, and snippets.

@leosuncin
Last active May 28, 2024 09:44
Show Gist options
  • Select an option

  • Save leosuncin/50367b3c905fe8699b13bd85ad26071b to your computer and use it in GitHub Desktop.

Select an option

Save leosuncin/50367b3c905fe8699b13bd85ad26071b to your computer and use it in GitHub Desktop.
JDownloader 2 headless startup script
#!/bin/sh
DESC="JDownloader 2 Headless"
NAME=JDownloader2
PIDFILE=/var/run/$NAME.pid
COMMAND="/usr/bin/java -- -Djava.awt.headless=true -jar /home/osmc/jDownloader2/JDownloader.jar"
RUN_AS=osmc
d_start() {
start-stop-daemon --start --quiet --background --make-pidfile --pidfile $PIDFILE --chuid $RUN_AS --exec $COMMAND
}
d_stop() {
start-stop-daemon --stop --quiet --pidfile $PIDFILE
if [ -e $PIDFILE ]
then rm $PIDFILE
fi
}
case $1 in
start)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
restart)
echo -n "Restarting $DESC: $NAME"
d_stop
sleep 1
d_start
echo "."
;;
*)
echo "usage: $NAME {start|stop|restart}"
exit 1
;;
esac
exit 0
@leosuncin
Copy link
Copy Markdown
Author

leosuncin commented May 1, 2016

JDownloader 2 daemon script for use in OSMC

Download and copy this script to /etc/init.d

wget https://gist.github.com/leosuncin/50367b3c905fe8699b13bd85ad26071b/raw/e4698a199cc13c51b2c849a0ce762dceff15b60e/JDownloader2.sh # This URL may change
chmod +x JDownloader2.sh
sudo cp JDownloader2.sh /etc/init.d/JDownloader2

Start service

sudo /etc/init.d/JDownloader2 start

Enable autostart

sudo update-rc.d JDownloader2 defaults

@daimo996
Copy link
Copy Markdown

daimo996 commented Oct 7, 2017

Hello,
thank you very much for your work.
it also works on odroid-C2

@Bau250
Copy link
Copy Markdown

Bau250 commented Apr 21, 2018

After days of frustration this is the only one that worked like a freakin charm, thank you!

Now how do I get it to work with MYJdownloader?

@tony-terrible
Copy link
Copy Markdown

Bau250: Install JDownloader as normal. Fire up the gui (export DISPLAY=YOUREMOTEX:0; java -jar path/to/JDownloader.jar) and click the tab in the GUI marked "MyJDownloader" and enter the account settings from the website after your signed up there.. http://my.jdownloader.org

JD will save you settings, and you can exit the program and use it headless again and control it with the android client or the web interface, what have you.

@fabme1
Copy link
Copy Markdown

fabme1 commented Nov 13, 2018

I use this on a raspberry, but JDownloader doesnt start at boot.

@wemakefuture
Copy link
Copy Markdown

@fabme1 add a cronjob

@atiris
Copy link
Copy Markdown

atiris commented Jan 23, 2019

@weigeloveu
Copy link
Copy Markdown

weigeloveu commented Aug 5, 2020

I use this on a raspberry, but JDownloader doesnt start at boot.

i make some changes,it should work now

https://gist.githubusercontent.com/weigeloveu/fe63b337d86b664c9f99ad58cc835bf3/raw/471fd7c860cda05c577dc18ca54070c2c28b3388/JDownloader2.sh

@issamu2k
Copy link
Copy Markdown

issamu2k commented Jun 4, 2021

Thanks for the startup script.
Problem is when the daemon is running on the background I can't start the JDownloader GUI.
How could I be able to run it on background but still open the GUI when needed?

@leosuncin
Copy link
Copy Markdown
Author

Thanks for the startup script.
Problem is when the daemon is running on the background I can't start the JDownloader GUI.
How could I be able to run it on background but still open the GUI when needed?

I think is not possible, JDownloader avoids to open multiple windows, so, one process only. Use the web interface or the app of JDownloader.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment