lazylibrarian install in 11.2 iocage jail help

Brownz

Dabbler
Joined
Sep 5, 2017
Messages
23
Im attempting to install lazy librarian into 11.2 iocage. I found after a hard search there is a severe lack of install guides...something I'm quite dependent on being a freenas noob. so far I have muddled along using similar python based install guides:

Current Install:
Code:
pkg update
pkg upgrade
pkg install nano git python py27-sqlite3
git clone https://gitlab.com/LazyLibrarian/LazyLibrarian.git /usr/local/share/LazyLibrarian
python /usr/local/share/LazyLibrarian/LazyLibrarian.py -d

Init Script:
I'm unsure how to get the rc.d script to auto start and end the app with the jail.
I also want to be able to use service commands instead of calling the python script manually.
I noticed the old version on git lab had init scripts for various OS's that's are designed to do this, but the new gitlab version does not.
Whats should I do?

Warnings:
Code:
Lazylibrarian is starting up...
16-Dec-2018 12:34:55 - INFO :: MAIN : __init__.py:initialize:666 : Log level set to [1]- Log Directory is [/usr/local/share/LazyLibrarian/Logs] - Config level is [1]
16-Dec-2018 12:34:55 - INFO :: MAIN : __init__.py:initialize:672 : Screen Log set to INFO
16-Dec-2018 12:34:55 - INFO :: MAIN : __init__.py:config_read:988 : Config file loaded
16-Dec-2018 12:34:56 - INFO :: MAIN : __init__.py:initialize:733 : Database is version 49, integrity check: ok
16-Dec-2018 12:34:56 - INFO :: MAIN : dbupgrade.py:check_db:460 : Database check found 0 errors
16-Dec-2018 12:34:56 - INFO :: MAIN : common.py:logHeader:816 : Checking TLS version, you can ignore any "InsecureRequestWarning" message
/usr/local/share/LazyLibrarian/lib/requests/packages/urllib3/connectionpool.py:843: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning)
16-Dec-2018 12:34:57 - WARNING :: MAIN : __init__.py:initialize:759 : urllib3: missing
16-Dec-2018 12:34:57 - WARNING :: MAIN : __init__.py:initialize:759 : unrar: missing: Couldn't find path to unrar library.
16-Dec-2018 12:34:57 - WARNING :: MAIN : __init__.py:initialize:759 : pyOpenSSL: module missing
16-Dec-2018 12:34:57 - INFO :: MAIN : __init__.py:build_bookstrap_themes:1414 : Bookstrap found 16 themes
16-Dec-2018 12:34:58 - INFO :: MAIN : versioncheck.py:logmsg:41 : New version is available. You are 6 commits behind

Got various warnings on startup is this anything to be worried about, is there anything I can do to the install to clean this up?

Install Location:
What is the standard install directory for installing these python apps manually, I'm using '/usr/local/share/' based on another install guide but I'm unsure if this is good practice?
 

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Never used lazylibrarian and likely never will, but your WARNING messages show three packages are missing and you'll need to install the relevant packages. Make sure everything is python 2.7 (py27) if that's your python choice.

Install location I think should be /usr/local/bin and the init script belongs in /user/local/etc/rc.d/..

A quick look on gitlab show this file file might work https://gitlab.com/LazyLibrarian/LazyLibrarian/blob/master/init/freebsd.initd
 

Brownz

Dabbler
Joined
Sep 5, 2017
Messages
23
ahhh ok thanks for this..i missed that init script.
After adding script I'm still get the following:

Updated Install:
Code:
pkg update
pkg upgrade
pkg install nano git python py27-sqlite3 unrar openssl

mkdir /usr/local/lazylibrarian
git clone https://gitlab.com/LazyLibrarian/LazyLibrarian.git /usr/local/lazylibrarian

cp /usr/local/lazylibrarian/init/freebsd.initd /usr/local/etc/rc.d/lazylibrarian.initd
nano /etc/rc.conf
---
lazylibrarian_enable="YES"
lazylibrarian_user="lazy"
lazylibrarian_dir="/usr/local/lazylibrarian"
---

service lazylibrarian onestop

Response:
lazylibrarian does not exist in /etc/rc.d or the local startup
directories (/usr/local/etc/rc.d), or is not executable

What am I doing wrong?
 
Last edited:

KrisBee

Wizard
Joined
Mar 20, 2017
Messages
1,288
Looking at that initd, contrary to what I thought, the comments say to add the file to /etc/rc.conf.local or /etc/rc.conf and unless you alter lazylibrarian_dir, it expects to find LazyLibrarian.py in directory /usr/local/lazylibrarian
 

Toast

Dabbler
Joined
Jun 17, 2014
Messages
16
From guides on other jail program installs, it seems they use chmod u+x On the rc file. I'm trying to get lazy librarian working too. Let us know how it turns out.
 

Brownz

Dabbler
Joined
Sep 5, 2017
Messages
23
I tired the above suggestions:

- directory for install: /usr/local/lazylibrarian,
- directory for config: /etc/rc.conf,
- directory for script: /usr/local/etc/rc.d/lazylibrarian.initd,

I also tried chmod u+x on these directories, but no luck.
Im sure this is simple, but I just havnt done it before. Anyone?
 

naq90

Dabbler
Joined
Jun 7, 2015
Messages
24
I tired the above suggestions:

- directory for install: /usr/local/lazylibrarian,
- directory for config: /etc/rc.conf,
- directory for script: /usr/local/etc/rc.d/lazylibrarian.initd,

I also tried chmod u+x on these directories, but no luck.
Im sure this is simple, but I just havnt done it before. Anyone?

Hey have you had any luck with finding a guide to install this? I'm wanting to do the same for my machine.
 

ByteNick

Explorer
Joined
Jan 24, 2015
Messages
98
I installed LazyLibrarian following the code bellow. I am not going to go in very small details, because I think it is easy to follow:
Code:
# detroy the previous jail:
iocage destroy lazylibrarian

# install the new jail:
echo '{"pkgs":["git","wget","openssl","readline","pcre","libnghttp2","python36","py36-setuptools","py36-sqlite3","py36-openssl","unrar","ca_root_nss"]}' > /tmp/pkg.json
iocage create -n "lazylibrarian" -p /tmp/pkg.json -r 11.2-RELEASE ip4_addr="vnet0|192.168.10.15/24" defaultrouter="192.168.10.1" vnet="on" allow_raw_sockets="1" boot="on" host_hostname="lazylibrarian"
rm /tmp/pkg.json

# create the apps dirs:
mkdir -p /mnt/tank/apps/lazylibrarian
iocage exec lazylibrarian "mkdir -p /usr/local/etc/pkg/repos"
iocage fstab -a lazylibrarian /mnt/tank/apps/_common_/repos /usr/local/etc/pkg/repos nullfs ro 0 0
iocage fstab -a lazylibrarian /mnt/tank/apps/lazylibrarian /config nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/torrents /mnt/torrents nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/nzb /mnt/nzb nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/media/audiobooks /mnt/media/audiobooks nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/media/books /mnt/media/books nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/media/comics /mnt/media/comics nullfs rw 0 0
iocage fstab -a lazylibrarian /mnt/tank/media/magazines /mnt/media/magazines nullfs rw 0 0
# the above structure is similar to what I use, but it can obviously adapted

# getting Lazylibrarian:
iocage exec lazylibrarian ln -s /usr/local/bin/python3.6 /usr/local/bin/python
iocage exec lazylibrarian git clone https://gitlab.com/LazyLibrarian/LazyLibrarian.git /usr/local/share/lazylibrarian

# this is requested (don't know why), and cannot install it from FN:
iocage exec lazylibrarian git clone git://github.com/urllib3/urllib3.git
iocage exec lazylibrarian
cd urllib3
python /urllib3/setup.py install
exit
iocage exec lazylibrarian rm -r /urllib3

# defining the rights and prepare the setup:
iocage exec lazylibrarian "pw user add lazylibrarian -c lazylibrarian -u 111 -d /nonexistent -s /usr/bin/nologin"
iocage exec lazylibrarian chown -R lazylibrarian:lazylibrarian /usr/local/share/lazylibrarian /config


Now, edit /usr/local/etc/rc.d/lazylibrarian with:
iocage exec lazylibrarian "ee /usr/local/etc/rc.d/lazylibrarian"
and insert:
Code:
#!/bin/sh
#
# Author: Kriss1981
#
# PROVIDE: LazyLibrarian
# REQUIRE: DAEMON sabnzbd
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# lazylibrarian_enable (bool): Set to NO by default.
#           Set it to YES to enable it.
# lazylibrarian_user:  The user account LazyLibrarian daemon runs as what
#           you want it to be. It uses '_sabnzbd' user by
#           default. Do not sets it as empty or it will run
#           as root.
# lazylibrarian_dir:   Directory where lazylibrarian lives.
#           Default: /usr/local/lazylibrarian
# lazylibrarian_chdir:  Change to this directory before running lazylibrarian.
#     Default is same as lazylibrarian_dir.
# lazylibrarian_pid:  The name of the pidfile to create.
#     Default is lazylibrarian.pid in lazylibrarian_dir.

. /etc/rc.subr

name="lazylibrarian"
rcvar=${name}_enable

load_rc_config ${name}

: ${lazylibrarian_enable:="NO"}
: ${lazylibrarian_user:="USERNAME"}
: ${lazylibrarian_dir:="/usr/local/lazylibrarian"}
: ${lazylibrarian_chdir:="${lazylibrarian_dir}"}
: ${lazylibrarian_datadir:="${lazylibrarian_dir}"}
: ${lazylibrarian_pid:="${lazylibrarian_datadir}/lazylibrarian.pid"}
: ${lazylibrarian_conf:="${lazylibrarian_datadir}/config.ini"}
: ${lazylibrarian_flags:=""}

PATH="/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin"

WGET="/usr/local/bin/wget"      # You need wget for this script to safely shutdown lazylibrarian.
LLUSR=""                        # Set LazyLibrarian username (if you use one) here.
LLPWD=""                        # Set LazyLibrarian password (if you use one) here.

if [ -e "${lazylibrarian_conf}" ]; then
    HOST=`grep -A128 "\[General\]" "${lazylibrarian_conf}"|egrep "^http_host"|perl -wple 's/^http_host = (.*)$/$1/'`
    PORT=`grep -A128 "\[General\]" "${lazylibrarian_conf}"|egrep "^http_port"|perl -wple 's/^http_port = (.*)$/$1/'`
else
    HOST="localhost"
    PORT="5299"
fi

status_cmd="${name}_status"
stop_cmd="${name}_stop"

command="${lazylibrarian_dir}/LazyLibrarian.py"
command_args="--daemon --quiet --pidfile ${lazylibrarian_pid} --datadir ${lazylibrarian_datadir} ${lazylibrarian_flags}"

# Check for wget and refuse to start without it.
if [ ! -x "${WGET}" ]; then
    warn "lazylibrarian not started: You need wget to safely shut down lazylibrarian."
    exit 1
fi

# Ensure user is root when running this script.
if [ `id -u` != "0" ]; then
    echo "Oops, you should be root before running this!"
    exit 1
fi

verify_lazylibrarian_pid() {
    # Make sure the pid corresponds to the lazylibrarian process.
    pid=`cat ${lazylibrarian_pid} 2>/dev/null`
    ps -p ${pid} | grep -q "python ${lazylibrarian_dir}/LazyLibrarian.py"
    return $?
}

# Try to stop lazylibrarian cleanly by calling shutdown over http.
lazylibrarian_stop() {
    echo "Stopping $name"
    verify_lazylibrarian_pid
    ${WGET} -O - -q --user=${LLUSR} --password=${LLPWD} "http://${HOST}:${PORT}/shutdown/" >/dev/null
    if [ -n "${pid}" ]; then
        wait_for_pids ${pid}
        echo "Stopped"
    fi
}

lazylibrarian_status() {
    verify_lazylibrarian_pid && echo "$name is running as ${pid}" || echo "$name is not running"
}

run_rc_command "$1"


save it and continue with:
Code:
# covering the basic configs:
iocage exec lazylibrarian chmod u+x /usr/local/etc/rc.d/lazylibrarian
iocage exec lazylibrarian sysrc "lazylibrarian_enable=YES"
iocage exec lazylibrarian sysrc "lazylibrarian_user=lazylibrarian"
iocage exec lazylibrarian sysrc "lazylibrarian_dir=/usr/local/share/lazylibrarian"
iocage exec lazylibrarian sysrc "lazylibrarian_datadir=/config"
iocage exec lazylibrarian sed -i '' -e 's?/var/run/lazylibrarian/lazylibrarian.pid?/config/lazylibrarian.pid?g' /usr/local/etc/rc.d/lazylibrarian

# personnaly, I use the user media for all these apps, but you can do otherwise:
iocage exec lazylibrarian "pw user add media -c media -u 8675309 -d /nonexistent -s /usr/bin/nologin"
iocage exec lazylibrarian "pw groupadd -n media -g 8675309"
iocage exec lazylibrarian "pw groupmod media -m lazylibrarian"
iocage exec lazylibrarian chown -R media:media /usr/local/share/lazylibrarian /config /mnt/torrents /mnt/nzb /mnt/media/audiobooks /mnt/media/books /mnt/media/comics /mnt/media/magazines
iocage exec lazylibrarian sysrc 'lazylibrarian_user=media'

# a final update before the launch:
iocage exec lazylibrarian "pkg update && pkg upgrade -y"

# and finally:
iocage exec lazylibrarian service lazylibrarian start


It will give a small error message regarding the SSL certificate which can probably solved in the configuration, but I would not know.

lazylibrarian should then be available at http://192.168.10.15:5299 (or whatever you set in).

Configuration takes a long time. You find it here: https://lazylibrarian.gitlab.io/config_interface/
 
Top