Register for the iXsystems Community to get an ad-free experience and exclusive discounts in our eBay Store.

[GUIDE] Jdownloader2 in 11.1-RELEASE iocage with rar5 working

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Hi all, I made this how-to after struggling with this in the last days. Maybe this is interesting for some of you.
I will make it more pretty in the next week. If you have any suggestions feel free to write.
My main language is not english but I thought to reach a bigger community when writing this in english. So please forgive some mistakes.

How to install JDownloader2-Headless (Java) with rar5 extraction in a FreeNAS 11.1 iocage jail

### This is a guide for noobs who have no idea how to start this. I'm not an expert. I just made this running properly and want to share how I did this. ###

system: HP-N54L with 9TB RAID-Z1 storage
software: FreeNAS-11.1-U6

###1### Prepare your download folder ###

I assume that you already created a dataset within your ZFS tank for the downloaded files to be stored. You can do this in the FreeNAS gui.
Log in to your jail via SSH or use the shell in the webinterface. The first option is highly recommended.
Make sure to make it belong to the root by the following command:

root@host:~ # chown -R root:wheel /mnt/"your tank"/"your dataset"

to make it save set the rights for reading and writing to owner and group with this:

root@host:~ # chmod -R 660 /mnt/"your tank"/"your dataset"

(here is a calculator for you if you want to give other rights https://chmod-calculator.com/)

###2### Create the iocage ###
Lets start and create the jail for our JDownloader.

First of all lets see what releases your system has to offer:

root@host:~ # iocage fetch [0] 9.3-RELEASE (EOL) [1] 10.1-RELEASE (EOL) [2] 10.2-RELEASE (EOL) [3] 10.3-RELEASE (EOL) [4] 10.4-RELEASE (EOL) [5] 11.0-RELEASE (EOL) [6] 11.1-RELEASE (EOL) [7] 11.2-RELEASE [8] 12.0-RELEASE Type the number of the desired RELEASE Press [Enter] to fetch the default selection: (11.1-RELEASE) Type EXIT to quit:

I chose option 6 (11.1). Higher releases should also work in general but here is a bug in FreeNAS at the moment that does not let you start 11.2 jail's again after the first start. So also chose 11.1 to be save.
This can take some time as the release is downloaded and extractet.

Type in "ifconfig" to see the name of your main network adapter:

root@host:~ # ifconfig bge0: flags=8843<UP,BROADCAST,RUNNING,SIMPLEX,MULTICAST> metric 0 mtu 1500 options=c019b<RXCSUM,TXCSUM,VLAN_MTU,VLAN_HWTAGGING,VLAN_HWCSUM,TSO4,VLAN_HWTSO,LINKSTATE> ether xx:xx:xx:xx:xx:xx hwaddr xx:xx:xx:xx:xx:xx inet xxx.xxx.xxx.xxx netmask 0xffffff00 broadcast xxx.xxx.xxx.xxx nd6 options=9<PERFORMNUD,IFDISABLED> media: Ethernet autoselect (1000baseT <full-duplex,master>) status: active

You can see in m case its "bge0".

Now we create the jail with the following command:

root@host:~ # iocage create -r 11.1-RELEASE --name jd2 boot=on vnet=off ip4_addr="bge0|192.168.1.7/24"
-r is for chosing the release.
boot=on means its starts when your host system starts.
vnet=off makes us using share ip with the host system.
ip4_addr sets our network config. Chose a free IP in your lokal network.
With this setup you can later on just switch to Direct-Connection-Mode and just need to open a port in your router for the Jail IP.

After sending the whole command it should look like this:

root@host:~ # iocage create -r 11.1-RELEASE --name jd2 boot=on vnet=off ip4_addr="bge0|192.168.1.7/24" jd2 successfully created! * Starting jd2 + Started OK + Starting services OK

Check if the jail is up and running with a short "jls".

root@host:~ # jls JID IP Address Hostname Path 1 192.168.1.7 jd2 /mnt/iocage/jails/jd2/root

Remember the JID, as we need it later.

###3### Enter the matix iocage ###
Let's log in to our jail with this:

root@host:~ # jexec 1 tcsh root@jd2:/ #

1 is the JID. Its a counting number. If you restart the jail it will rise till you restart the host system.
So if you need to log in to the jail just check the ID first with a "jls" command.

We are now root in the jail and start with this to create our download folder

root@jd2:/ # mkdir /mnt/Downloads

then enter "exit" and stop the jail with

root@host:~ # iocage stop jd2 * Stopping jd2 + Running prestop OK + Stopping services OK + Removing jail process OK + Running poststop OK

mount the share of the hostsystem permanently to your new jail with this:

root@host:~ # iocage fstab -a jd2 "/mnt/"your tank"/"your dataset"/ /mnt/Downloads nullfs rw 0 0" Successfully added mount to jd2's fstab

Your dataset is now mounted as /mnt/Downloads within the jail whenever it starts

start the jail again

root@host:~ # iocage start jd2 * Starting jd2 + Started OK + Starting services OK

log in to the jail again (jid has rised)

root@host:~ # jexec 2 tcsh root@jd2:/ #

lets update it (make sure you are INSIDE the jail!)

root@jd2:/ # pkg update

Maybe you need to install pkg first but the system will ask you if you want to. Just answer everything with y.
Also kernel missmatch questions - just y.

you should get:

root@jd2:/ # pkg update Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date.

Time to upgrade:

root@jd2:/ # pkg upgrade Updating FreeBSD repository catalogue... FreeBSD repository is up to date. All repositories are up to date. Updating database digests format: 100% Checking for upgrades (1 candidates): 100% Processing candidates (1 candidates): 100% Checking integrity... done (0 conflicting) Your packages are up to date.

type in this:

root@jd2:/ # pkg install nano

answer all with y.

After nano is installed type in:

root@jd2:/ # nano /etc/pkg/FreeBSD.conf

you will get to this file:

Code:
# $FreeBSD: releng/11.1/etc/pkg/FreeBSD.conf 320745 2017-07-06 17:22:33Z gjb $
#
# To disable this repository, instead of modifying or removing this file,
# create a /usr/local/etc/pkg/repos/FreeBSD.conf file:
#
#   mkdir -p /usr/local/etc/pkg/repos
#   echo "FreeBSD: { enabled: no }" > /usr/local/etc/pkg/repos/FreeBSD.conf
#

FreeBSD: {
  url: "pkg+http://pkg.FreeBSD.org/${ABI}/quarterly",
  mirror_type: "srv",
  signature_type: "fingerprints",
  fingerprints: "/usr/share/keys/pkg",
  enabled: yes
}


Change the quartely to release_2 and press CTRL+X, then y and enter. This step is also very important if you have a kernel missmatch like me. If not changed you can run into "libdl.so.1" not found" error.

then

pkg update -f

all questions y and later

pkg upgrade -f

with all questions y.

Looks fine. Time to install some packages which we might need in the future.
Always say y if there is a question. (every package is important - make sure to get all)

pkg install nano compat9x-amd64-9.3.903000.20170608 compat11x-amd64-11.2.1102000.20181014 p7zip-16.02_2 p7zip-codec-rar-16.02_1 unzip zip unrar rar libunrar5 libarchive cmake lang/gcc openjdk8-jre-8.202.8 openjdk8-8.202.8 bootstrap-openjdk8-r450802 wget python27-2.7.15 git

installing these packages can take a moment.
(fyi: if you need to search for a package in case there is a new version or a different name you can do it with pkg search "name" like pkg search compat)

###4### Install the JDownloader2 ###
Let's get jdownloader.

first create a folder for the jdownloader. "jdownloader" in the root will make the job

root@jd2:/ # mkdir /jdownloader root@jd2:/ # cd /jdownloader root@jd2:/jdownloader #

now download the jdownloader

root@jd2:/jdownloader # wget http://installer.jdownloader.org/JDownloader.jar

start jdownloader and let it do its thing (lots of text will run down the screen)

root@jd2:/jdownloader # java -jar JDownloader.jar -norestart

when you see this screen...

Code:
|---------------------------Headless Information-------------------------------
|       Restart Required
|       JDownloader Updated Itself and will exit now.
|       Please restart JDownloader after a few seconds.
|       Make sure that there is no running JDownloader process before restarting.
|------------------------------------------------------------------------------
root@jd2:/jdownloader #


...Run this:

root@jd2:/jdownloader # chown -R root:wheel /jdownloader root@jd2:/jdownloader # chmod -R 770 /jdownloader/tmp

Then again

root@jd2:/jdownloader # java -jar JDownloader.jar -norestart

when you see this you can insert your myjdownloader login information after typing y and enter

Code:
|---------------------------Headless Information-------------------------------
|       MyJDownloader Setup
|       Your 'My JDownloader' logins are not correct.
|       Please check username/email and password!
|       Enter y -> Enter Logins
|       Enter n -> Exit JDownloader


you should see the jdownloader now in you myjdownloader web gui as Jdownloader@root.
Go to its Settings and change the download folder to /mnt/Downloads
The / before mnt is important.

Now add a zip testfile to the linkgrabber of you jdownloader and start the download.
it should be downloaded and extracted without a problem.
but when you to this now with a rar5 file, jdownloaded will not extract. that because out of the box jdownloaded in the FreeNAS jail can't handle rar5.

###5### Compile the rar5 packages ###
but here we will compile the needed packages for ourselfes.

Stop the jdownloader with CTRL+C in the terminal and insert this:

root@jd2:/jdownloader # mkdir /rar5 root@jd2:/jdownloader # cd /rar5 root@jd2:/jdownloader # git clone https://github.com/borisbrodski/sevenzipjbinding.git sevenzipbinding

change in the new subfolder with

root@jd2:/rar5 # cd sevenzipbinding/

and run

root@jd2:/rar5/sevenzipbinding # git checkout migrate-to-15.09-try2 Branch 'migrate-to-15.09-try2' set up to track remote branch 'migrate-to-15.09-try2' from 'origin'. Switched to a new branch 'migrate-to-15.09-try2'

now we start compiling the package for our system:
the folder /usr/local/openjdk8 might be a bit different on your system if you use ther java versions or other releases. keep this in mind.

root@jd2:/rar5/sevenzipbinding # cmake . -DJAVA_JDK=/usr/local/openjdk8

some text will appear and it should say "-- Build files have been written to: /rar5/sevenzipbinding"

now insert this, it will take a while and lots of text will run down the screen.

root@jd2:/rar5/sevenzipbinding # make

if you get the "/usr/bin/ld: cannot find -ldl" error you will need to delete the "-ldl" parameter at the end of this file, like this:
(you can go to the end of the line with the "End" key on the keyboard ... its a very long line.)

root@jd2:/rar5/sevenzipbinding # nano /rar5/sevenzipbinding/jbinding-cpp/CMakeFiles/7-Zip-JBinding.dir/link.txt

then close and save wiht CTRL+X, followed by y and enter.

now again try make:

root@jd2:/rar5/sevenzipbinding # make

after a few sec its should say

[100%] Built target sevenzipjbinding-lib-jar

now insert

root@jd2:/rar5/sevenzipbinding # make package

again some text blabla... and you will find the holy grale to unpack rar5 in here:
(you might have other version numbers)

/rar5/sevenzipbinding/sevenzipjbinding-15.09-2.01beta-FreeBSD-amd64.zip

in the zip file you will find two files which need to be renamed and moved:

so do this:

root@jd2:/rar5/sevenzipbinding # unzip sevenzipjbinding-15.09-2.01beta-FreeBSD-amd64.zip root@jd2:/rar5/sevenzipbinding # cd sevenzipjbinding-15.09-2.01beta-FreeBSD-amd64/lib root@jd2:/rar5/sevenzipbinding # mv sevenzipjbinding.jar /jdownloader/libs/sevenzipjbinding1509.jar root@jd2:/rar5/sevenzipbinding # mv sevenzipjbinding-FreeBSD-amd64.jar /jdownloader/libs/sevenzipjbinding1509Bsd.jar

check if everything went well:

root@jd2:/jdownloader/libs # cd /jdownloader/libs/ root@jd2:/jdownloader/libs # ls

you should see

root@jd2:/jdownloader/libs # ls
bcprov-jdk15on.jar jackson-databind.jar proxyVole.jar
brotli.jar JAntiCaptcha.jar sevenzipjbinding.jar
cons.jar JDGUI.jar sevenzipjbinding1509.jar
dbus JDHttp.jar sevenzipjbinding1509Bsd.jar
Dynamics.jar JDUtils.jar sevenzipjbindingBsd.jar
Filters.jar jna_platform.jar svgSalamander.jar
htmlunit-core-js.jar jna.jar UPNP
image4j.jar js.jar zip4j.jar
jackson-annotations.jar jsyntaxpane.jar
jackson-core.jar laf

sevenzipjbinding1509Bsd.jar and sevenzipjbinding1509.jar are in place. your jdownloader can now extract rar5 files.

lets test:

start the jdownloader with

root@jd2:/jdownloader/libs # java -Djava.awt.headless=true -jar JDownloader.jar >/dev/null 2>/dev/null &

add a test rar5 file to the download quere via myjdownloader webinterface and test if the file gets extracted after download.
in my case the testfiles was extractet.

if not you can create a log from the regarding time via webinterface and check the ExtractionExtension.log.0 file within the regarding folder in /jdownloader/logs

so now we have a running jail with w working rar5 compatible jdownloader.

would be nice if the jdownloader starts if the jail starts, right?

###5### Configure autostart for JDownloader2 ###
lets create a simple script as a service for the jdownlader which starts when the jail starts

switch to /etc/rc.d/ with

root@jd2:/ # cd /etc/rc.d/

create our script file and make it executeable

root@jd2:/etc/rc.d # touch jd2 root@jd2:/etc/rc.d # chmod +x jd2

lets start scripting

root@jd2:/etc/rc.d # nano jd2

paste this:

Code:
#!/bin/sh

. /etc/rc.subr

name=jd2
rcvar=jd2_enable

start_cmd="${name}_start"
stop_cmd="${name}_stop"

load_rc_config $name

jd2_start()
{
#!/bin/bash
echo "starting JDownloader2..."
umask 000
cd /jdownloader/
/usr/local/bin/java -Djava.awt.headless=true -jar JDownloader.jar >/dev/null 2>/dev/null &
}

jd2_stop()
{
#!/bin/bash
echo "killing java (and JDownloader2)..."
pgrep java | xargs kill
}

jd2_restart()
{
#!/bin/bash
echo "killing java (and JDownloader2)..."
pgrep java | xargs kill
umask 000
cd /jdownloader/
echo "starting JDownloader2..."
/usr/local/bin/java -Djava.awt.headless=true -jar JDownloader.jar >/dev/null 2>/dev/null &
}

run_rc_command "$1"


Because of "umask 000" the process which writes the files later to the disk makes the files fully read-, write, and deleateable by any user who can access the share where the files are. This makes it easy to manage the files from any windows machine in the network. Without this only the root user of our system could manage them properly.

then save and exit with CTRL+X then y and enter.

From now you can use this three commands in terminal: care for the one
root@jd2:/ # service jd2 onestart #This will start the JDownloader in silent headless mode.
root@jd2:/ # service jd2 onestop #This will kill the java task and so also kill JDownloader2.
root@jd2:/ # service jd2 onerestart #This will do both, stop and start again.

if you want to make this service autostart now
edit the rc.conf

root@jd2:/etc # nano /etc/rc.conf

and add this line to the bottom:

jd2_enable="YES"

the file should look like this for example:

Code:
host_hostname="jd2"
cron_flags="$cron_flags -J 15"

# Disable Sendmail by default
sendmail_enable="NONE"
sendmail_submit_enable="NO"
sendmail_outbound_enable="NO"
sendmail_msp_queue_enable="NO"

# Run secure syslog
syslogd_flags="-c -ss"

# Enable IPv6
ipv6_activate_all_interfaces="YES"

jd2_enable="YES"


then save and exit with CTRL+X then y and enter.

after editing the rc.conf you can leafe away the one for the commands and your jd2 will autostart when the iocage starts
root@jd2:/ # service jd2 start #This will start the JDownloader in silent headless mode.
root@jd2:/ # service jd2 stop #This will kill the java task and so also kill JDownloader2.
root@jd2:/ # service jd2 restart #This will do both, stop and start again.

lets try out our service

fire up the service with

root@jd2:/etc # service jd2 start starting JDownloader2...

jdownloader should start now - if you want you can close with with the myjdownloader webinterface.

lets try if it starts on jail/host reboot.

root@jd2:/etc # exit root@host:~ # iocage stop jd2 * Stopping jd2 + Running prestop OK + Stopping services OK + Removing jail process OK + Running poststop OK

cross your fingers and fire it up again:

root@host:~ # iocage start jd2

check the JID and enter the jail

root@host:~ # jls JID IP Address Hostname Path 4 192.168.1.7 jd2 /mnt/iocage/jails/jd2/root root@host:~ # jexec 4 tcsh root@jd2:/ #

java should be running now, lets check:

root@jd2:/ # top

it is! autostart works!

in the host sytem you might want to make a snapshot of you new working jail to recover it in the future if something fails:

root@host:~ # iocage snapshot jd2


So what do we have now?

We have a iocage called jd2 which starts automaticly when the host system starts.
within this we have a rar5 compatible jdownloader which starts when the iocage starts.
downloaded files are stored extraxted in /mnt/Download which is monuted from your host system dataset.
in the FreeNAS gui you can make a SMB Share for examle to let windows users access the dataset and the extracted and downloaded files in there. Due to the way of how SharedIP works we can easily use the direct connection mode of jdownloader without the need of additional setup. Just open the port you chose in the myjdownloader webgui in your router for the IP of the jail and we're done.

If you have any suggestions feel free to write.
My main language is not english but I thought to reach a bigger community when writing this in english. So please be patient with some mistakes.


used sources:
chmod calculator: https://chmod-calculator.com/
iocage usage: https://iocage.readthedocs.io/en/latest/basic-use.html
iocage networking: https://iocage.readthedocs.io/en/latest/networking.html
use fstab in iocage: https://forums.freenas.org/index.php?threads/iocage-jail-and-storage.59875/post-424831
install jdownloader in freenas: https://forums.freenas.org/index.php?threads/tutorial-jdownloader-in-a-jail.48374/
fixing "libdl.so.1" not found" error: https://forums.freenas.org/index.ph...n-jail-with-libdl-so-1-not-found-error.70391/
gitub resource jor sevenzipjbind: https://github.com/borisbrodski/sevenzipjbinding/tree/migrate-to-15.09-try2
jdownloader startscript: https://forums.freenas.org/index.php?threads/tutorial-jdownloader-in-a-jail.48374/post-345343
Bug fixing in jdowdnloader board: https://board.jdownloader.org/showthread.php?t=79842
new jd2 service script: https://board.jdownloader.org/showpost.php?p=436847&postcount=22
kill a task without knowing pid: https://unix.stackexchange.com/questions/138202/can-i-chain-pgrep-with-kill
 
Last edited:

jirkatran

Dabbler
Joined
Mar 29, 2019
Messages
11
great guide but after turning off my NAS jdownloader wont start a lost internet connection :( im on 11.2 build do you know when they fix this bug
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Hi and thank you, what do you mean by "won't start a lost internet connection"?

The jail won't start?
As far as I know there is a bug in FreeNAS at the moment that does not let you start 11.2 jail's again after the first start and stop. But it should be fixed in the newer versions. https://www.ixsystems.com/community...ails-plugins-on-11-2beta1-iocage-error.68789/
What does your machine say if you put in the shell "iocage start <name>" ?
 

jirkatran

Dabbler
Joined
Mar 29, 2019
Messages
11
i got it working now somehow now .i had to delete jail with jd2 , my internet connection on NAS start working again a have to create new jd2 jail . its working but its buggy somehow


" iocage start jd2
* Starting jd2
+ Started OK and its gonna lag like this in shell and missing the" *services ok"

and my main shell will show this

Code:
Apr  5 11:33:52 TKD-NAS /middlewared[235]: dnssd_clientstub DNSServiceRefSockFD called with invalid DNSServiceRef 0x81c030180 FFFFFFFF DDDDDDDD
Apr  5 11:33:52 TKD-NAS /middlewared[235]: dnssd_clientstub DNSServiceProcessResult called with invalid DNSServiceRef 0x81c0303c0 FFFFFFFF DDDDDDDD

but its working now will see tmrw
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Sounds like some problems with the host system. Saw some other posts in the forum about this error message. Unfortunately did not see a quick and easy solution.
 

jirkatran

Dabbler
Joined
Mar 29, 2019
Messages
11
so i probably found fix . i turned off jdownloader updates . now i can turn off and urn it on normally .
 
Joined
Sep 13, 2014
Messages
149
Hey @honeybee, thanks for the tutorial but there apears to be a couple of errors / typos.

root@jd2:/jdownloader # chown -R root:wheel /mnt/jdownloader root@jd2:/jdownloader # chmod -R 770 /mnt/jdownloader/tmp

Shouldn't it be?...

root@jd2:/jdownloader # chown -R root:wheel /jdownloader root@jd2:/jdownloader # chmod -R 770 /jdownloader/tmp

if you want to make this service autostart now
edit the rc.conf

root@jd2:/etc # nano /etc/rc.conf

and add this line to the bottom:

jd2="YES"

You forgot "enable" in the last code snippet. It should be...

jd2_enable="YES"
 

honeybee

Dabbler
Joined
Feb 21, 2019
Messages
30
Hey @honeybee, thanks for the tutorial but there apears to be a couple of errors / typos.

Hi CompuGlobalHyperMegaNet, I checked my old machine and you are right with both. Thank you very much!

Will amend my tutorial.
Also added an explanation why I used "umask 000".
 
Last edited:
Top