Need help autostart qBittorrent in FreeNAS jail please

I was successful in portsnap'ing; make install; qbittorrent-nox from freshports to a standard FreeNAS jail.

(The reason is so that I can host my own private tracker - which qbittorrent supports and transmission does not)

Anyways, qbittorrent runs great but only when I manually run the command
Code:
$ qbittorrent-nox
in the jail shell. I've done some reading and attempted to implement a few autostart batch files from the Internet but I have been unsuccessful as I simply do not have the knowledge to set the code correctly and other commands.

My steps:
Code:
$ nano /etc/rc.d/qbit
Paste the script listed here that a FreeNAS user suggested
Code:
#!/bin/sh
# File name 'qbit'
# Place this file into /etc/rc.d
# Edit /etc/rc.conf to include qbit_enable="YES"
     
. /etc/rc.subr
     
name="qbit"
rcvar=qbit_enable
    
PATH="$PATH:/usr/local/bin"
    
start_cmd="${name}_start"
stop_cmd=":"
     
load_rc_config $name
eval "${rcvar}=\${${rcvar}:-'NO'}"
     
qbit_start()
{
# And start up the service.
     
  service minidlna start
     
done
}
     
run_rc_command "$1"
I then set
Code:
$ chmod 775 /etc/rc.d/qbit

$ nano /etc/rc.conf

qbit_enable="YES"
To test I then run
Code:
$ /etc/rc.d/qbit
but it does not work - the software will not autostart after restarting the jail. I can manually run the script but as soon as I close the shell window the service stops.

What do I need to change? What am I missing? I simply don't have the knowledge to make this work, your input would be very much appreciated.
 
As a second attempt coming from a different angle, here is something else I tried but with the same result - it will not autostart and running the script manually will not keep the service running once the shell window is closed.

Code:
$ pkg install screen

Code:
nano qbit.sh

Code:
#!/bin/bash
screen -S qbnox -d -m qbittorrent-nox

Code:
$ nano -w /etc/rc.d/rc.local

Code:
#!/bin/sh -e
sh '/path/to/your/script/qbit.sh'

exit 0

Code:
$ chown root /etc/rc.d/rc.local
$ chmod 755 /etc/rc.d/rc.local
$ chmod 755 qbit.sh
 
Go back and read the "EDIT" note of first reply in the FreeNAS forum, especially what is mentioned about line 23 of the provided script. Then run qbittorent-nox --help (hint: look for the word "background"). Put the two together and it should do exactly what you want.
 
Thank you for the --help command! That got me in the right direction, at least now I can run qbittorrent-nox -d and be able to close the shell window.

Now I'm stuck at actually getting the right syntax in the script.

Would it be:
Code:
qbit_start()
{
# And start up the service.
 
  service qbittorrent-nox -d | --daemon start
 
done
}
or
Code:
  service qbittorrent-nox -d start
or neither? To manually run qbittorrent as daemon I simply run root@qbittorrent:/ # qbittorrent-nox -d Does the script need to have a / or ../ or something else that's missing?
 
It's the neither choice; this script just needs to do what you type in manually, so drop the "service" at the front and the "start" at the end. It might be a good idea to give /the/full/path/to/qbittorrent-nox (try which qbittorrent-nox) just in case the PATH is not set the same when interactively running as root versus the when the jail runs this script.
 
Back
Top