Jdownloader Seedbox on Debian vServer

The last ~1 year, I used my Raspi to run Jdownloader in headless mode (see post) and store/extract files on my local NAS.
As I wanted to have high bandwith access to that files from several locations, I deceided to set up a private server with some storage and access via CIFS/FTPS/SFTP/Webdavs for Kodi.
I figured out a hosting provider which offers a vServer monthly for about 5€ and additional storage for about 6€ (for 500GB). This storage can be accessed internally as well as externally via CIFS/FTPS/SFTP/Webdavs, which makes it very easy for me, because I do not need to care about setting up external access to the storage via the vServer.
All I had to to do is to set up JDownloader headless on the Debian minimal and to mount the storage (I am using CIFS):

Based on:
https://kaistech.wordpress.com/2016/01/31/jdownloader-headless-on-raspberry-pi/
https://misterunknown.de/blog/2016/05/jdownloader-headless-auf-debian-ubuntu-server-installieren.html

Login as root

mkdir /home/jd
useradd -g users -d /home/jd -s /bin/bash jd
chown -hvR jd /home/jd

apt-get install openjdk-7-jre-headless

su jd
mkdir /home/jd/jdownloader
cd /home/jd/jdownloader
wget http://installer.jdownloader.org/JDownloader.jar
java -jar JDownloader.jar
reboot

su jd
cd /home/jd/jdownloader
java -jar JDownloader.jar
(then press y to enter MyJdownloader Logins)
Exit with Strg-C

Exit su jd with “exit” (now you are root again)

touch /home/jd/jdownloader/JDownloader.pid
nano /etc/init.d/jdownloader
(insert from: https://gist.github.com/WtfJoke/45796a5cfb0e746c84eb0d5b4650e11c)

#! /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

chmod 755 /etc/init.d/jdownloader
systemctl daemon-reload
systemctl enable jdownloader
reboot

Storage connected with CIFS like this: https://anteru.net/blog/2014/09/20/2480/

Login as root

apt-get install autofs cifs-utils

For safety reasons disable some server services which came with autofs and cifs-utils:
systemctl disable rpcbind
(portmapper server which came with autofs)
systemctl disable smbd
(SAMBA server which came with cifs-utils)
systemctl disable nmbd
(Netbios server which came with cifs-utils)
reboot

check with “netstat -tuplen”
it should only show sshd listening on port 22 (IPv4 and IPv6), dhclient and systemd-timesyn.

mkdir /mnt/net
mkdir /mnt/net/smb
nano /etc/auto.master
-> insert: /mnt/net/smb /etc/auto.cifs-shares
su jd
nano /home/jd/.smbcredentials
-> insert:
username=
password=

exit

find id for user jd
cut -d: -f1,3 /etc/passwd
-> e.g. id=1000

nano /etc/auto.cifs-shares
-> insert: storage -fstype=cifs,rw,credentials=/home/jd/.smbcredentials,uid=1000 ://cifspathtoyourstorage/subfolder

service autofs restart

su jd
cd /mnt/net/smb/storage
touch test.txt

change JDownloader path via MyJdownloader to /mnt/net/smb/storage

In Expert settings change MyJDownloaderSettings: Direct Connect Mode to “Disable direct connections” (this will change Jdownloader not to open a public tcp port on your server!).

Set up IPv4 to IPv6 portforwarder on vServer

To be used of you are behind a DS-Lite Cable/DSL-Connection and only have a fixed IPV6 (and a floating NATed IPv4).
Same service like offered by Universal Portmapper from e.g. feste-ip.net

Login as root
apt-get install 6tunnel

e.g. for OpenVPN running on remote host
6tunnel localport remotehost remoteport
6tunnel 1194 homeserver.remote 1194
or
6tunnel 10000 homeserver.remote 1194

Show running processes of 6tunnel
ps aux | grep 6tunnel

Create bootup-start/stop-script:
nano /etc/init.d/6tunnel
Insert:

#! /bin/sh
### BEGIN INIT INFO
# Provides: 6tunnel
# Required-Start: networking
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: 6tunnel server daemon
# Description: 6tunnel server daemon
### END INIT INFO

PARAM="/usr/bin/6tunnel 10000 homeserver.remote 1194"
USER="root"

start_daemon () {
start-stop-daemon --start --background --oknodo --chuid $USER --exec $PARAM
}

stop_daemon () {
start-stop-daemon --stop --name 6tunnel
}

# Switch case
case "$1" in
start)
# On start
echo "Start 6tunnel"
start_daemon
;;

stop)
# On stop
echo "Stop 6tunnel"
stop_daemon
;;

restart)
# On restart
echo "Restart 6tunnel"
start_daemon
stop_daemon
;;
*)
# Default action
echo "(start|stop|restart)"
;;
esac

exit 0

chmod +x /etc/init.d/6tunnel

Test with:
/etc/init.d/6tunnel start
netstat -tulpen
/etc/init.d/6tunnel stop

systemctl daemon-reload
systemctl enable 6tunnel

Jdownloader headless on Raspberry Pi

Old: Mount remote SMB (via SSH):
http://geeks.noeit.com/mount-an-smb-network-drive-on-raspberry-pi/
using:
//192.168.x.x/JDownloader /media/smb/JDownloader cifs username=xxx,password=xxx,rw,file_mode=0777,dir_mode=0777 0 0
plus activate “Wait for network at boot” via raspi-config

Update: Mount remote SMB (via SSH):
I changed to using AutoFS to mount my NAS share, because it seems to be more stable/reliable. Using the fstab approach lost connection sometimes (maybe because of standby of NAS or short connection break).
https://anteru.net/2014/09/20/2480/

Install Jdownloader (via SSH):
sudo apt-get install oracle-java8-jdk
mkdir jdownloader
cd jdownloader
wget http://installer.jdownloader.org/JDownloader.jar
java -Djava.awt.headless=true -jar JDownloader.jar

(wait a loooong time until updates have been installed and JDownloader tells you that it has restarted itself…)

Kill process using shown PID (message of restart after updates installed).

Insert email and password of your MyJDownloader login:

sudo nano /home/pi/jdownloader/cfg/org.jdownloader.api.myjdownloader.MyJDownloaderSettings.json

Restart and check, if it appears in your http://my.jdownloader.org/

Create init-scrip
sudo nano /etc/init.d/jdownloader
insert

#! /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/pi/jdownloader”
PIDFILE=”$DIR/JDownloader.pid”
JAVA=”/usr/lib/jvm/jdk-8-oracle-arm-vfp-hflt/jre/bin/java”
PARAM=”-Djava.awt.headless=true -jar $DIR/JDownloader.jar”

start_daemon () {
start-stop-daemon –start –background –oknodo –chuid pi –group pi –make-pidfile –pidfile $PIDFILE –exec $JAVA — $PARAM
}

stop_daemon () {
start-stop-daemon –stop –pidfile $PIDFILE
}

#Switch case fuer den ersten Parameter
case “$1” in
start)
#Aktion wenn start uebergeben wird
echo “Starte jDownloader2”
start_daemon
;;

stop)
#Aktion wenn stop uebergeben wird
echo “Stoppe jDownloader2”
stop_daemon
;;

restart)
#Aktion wenn restart uebergeben wird
echo “Restarte jDownloader2”
start_daemon
stop_daemon
;;
*)
#Standard Aktion wenn start|stop|restart nicht passen
echo “(start|stop|restart)”
;;
esac

exit 0

Install init.d with defaults

sudo systemctl daemon-reload
sudo systemctl enable jdownloader