Skip to content

Instantly share code, notes, and snippets.

@weigeloveu
Forked from leosuncin/JDownloader2.sh
Last active August 5, 2020 11:06
Show Gist options
  • Save weigeloveu/fe63b337d86b664c9f99ad58cc835bf3 to your computer and use it in GitHub Desktop.
Save weigeloveu/fe63b337d86b664c9f99ad58cc835bf3 to your computer and use it in GitHub Desktop.
JDownloader 2 headless startup script
#!/bin/sh
### BEGIN INIT INFO
# Provides: ### BEGIN INIT INFO
# Provides: JDownloader2
# Required-Start: $local_fs $remote_fs $network
# Required-Stop: $local_fs $remote_fs $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start or stop the JDownloader2.
# Description: Enable service provided by JDownloader2.
### END INIT INFO
NAME=JDownloader2
PIDFILE=/var/run/$NAME.pid
COMMAND="/usr/bin/java -- -Djava.awt.headless=true -jar /root/jd/JDownloader.jar"
RUN_AS=root
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
@weigeloveu
Copy link
Author

weigeloveu commented Aug 5, 2020

JDownloader 2 daemon script for use in root

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

wget https://gist.githubusercontent.com/weigeloveu/fe63b337d86b664c9f99ad58cc835bf3/raw/471fd7c860cda05c577dc18ca54070c2c28b3388/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

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