Skip to content

Instantly share code, notes, and snippets.

@BKPepe
Forked from WtfJoke/jd.sh
Last active January 15, 2020 06:47
Show Gist options
  • Save BKPepe/ed8b9cde3675e48642dc55a8e81d5985 to your computer and use it in GitHub Desktop.
Save BKPepe/ed8b9cde3675e48642dc55a8e81d5985 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/jdownloader"
PIDFILE="$DIR/JDownloader.pid"
JAVA="/usr/bin/java"
PARAM="-Djava.awt.headless=true -jar $DIR/JDownloader.jar"
USER="root"
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment