Skip to content

Instantly share code, notes, and snippets.

@WtfJoke
Last active August 19, 2021 09:51
Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save WtfJoke/45796a5cfb0e746c84eb0d5b4650e11c to your computer and use it in GitHub Desktop.
Save WtfJoke/45796a5cfb0e746c84eb0d5b4650e11c to your computer and use it in GitHub Desktop.
JDownloader 2 headless startup script (starts jdownloader as non root user jd)
#! /bin/sh
### BEGIN INIT INFO
# Provides: JDownloader2
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: JDownloader2 server daemon
# Description: JDownloader2 server daemon
### END INIT INFO
DIR="/home/jd/jdownloader"
PIDFILE="$DIR/JDownloader.pid"
JAVA="/usr/bin/java"
PARAM="-Djava.awt.headless=true -jar $DIR/JDownloader.jar"
USER="jd"
start_daemon () {
start-stop-daemon --start --background --oknodo --chuid $USER --make-pidfile --pidfile $PIDFILE --exec $JAVA -- $PARAM
}
stop_daemon () {
start-stop-daemon --stop --pidfile $PIDFILE
}
# Switch case
case "$1" in
start)
# On start
echo "Start JDownloader"
start_daemon
;;
stop)
# On stop
echo "Stop JDownloader"
stop_daemon
;;
restart)
# On restart
echo "Restart JDownloader"
start_daemon
stop_daemon
;;
*)
# Default action
echo "(start|stop|restart)"
;;
esac
exit 0
@N30Z3N
Copy link

N30Z3N commented Aug 18, 2021

how to use this??

@WtfJoke
Copy link
Author

WtfJoke commented Aug 19, 2021

how to use this??

Its been a while, but I think its an init.d script which can be placed to the other scripts, which are ran at startup.
Depending on your system the default scripts can be found in /etc/init.d.

However, I'm not using that script anymore.

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