The latest release is v1.34.2, you have v1.32.3.

JoeAtWork

Contributor
Joined
Aug 20, 2018
Messages
165
Zoneminder is barking at me and the command line for the jail pkg search zoneminder says that FreeBSD users are stuck on 1.32.3

How do FreeBSD users upgrade or how do FreeNAS plugin uses upgrade? Command line? I am one of the cursed trying to use an Amcrest 841b 2mp ip camera and I assume the udate will make it work.

Thanks,
Joe
 

cherup

Dabbler
Joined
Nov 21, 2015
Messages
20
The offical plugin seems to be quite outdated. I decided to install all needed packages using the ports collection and after a view tries I successully had installed ZM 1.34.6 - not sure if / when the plugin will be updated.

Would be interested in supporting a community plugin with the latest version if someone is interested and have some experiences with that.
 

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
cherup,
Did you upgrade on FreeNAS (hopefully 11.3) and can you give a rundown on how you did it please?

Frank
 

cherup

Dabbler
Joined
Nov 21, 2015
Messages
20
Yes, all on 11.3 -

1. first you have to install the ports collection (https://www.freebsd.org/doc/handbook/ports-using.htm)
2. Install the following packages from the ports:

  • fcgiwrap-1.1.0_9
  • mysql56-server-5.6.47_1
  • nginx-1.16.1_12,2
  • zoneminder-1.34.6
3. Once done you can run the post_install.sh script from the plugin

Ideally then it should work.
Hope this helps for the start ?
 

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
Thanks cherup, but I tried to follow the directions but I don't understand them. My excuse is nearly total ignorance.

To which part of this page (https://www.freebsd.org/doc/en_US.ISO8859-1/books/handbook/ports-using.html) do you mean when you say to install the ports collection?
To install the ports you listed, do I use # pkg install at root of the jail?
From where do I find the post install script and do I run this at root too?

Thanks for your help. The nag pop-up about the old plugin is driving me spare. :) Edit: The pop-up just alerted me to an even later version 1.34.8.

Frank
 
Last edited:

cherup

Dabbler
Joined
Nov 21, 2015
Messages
20
Hi, for the pots installtion you have to do the following.

1. Install a new jail
2. Open shell in new jail
3. Do the following commands:

portsnap fetch
portsnap extract


move the the right folder, e.g. /usr/ports/multimedia/zoneminder

make install clean (or make install clean BATCH=yes)

This will install from source...

This you can repeat for all needed packages..
 

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
Yep,
Did all that to the letter though fcgiwrap took over eight hours to install, and now the IP address is inaccessible.
My hardware is a HP Gen* Microserver with 16G and Xeon 1265L so it should not be too slow.
 

turtlepants

Dabbler
Joined
Jan 10, 2018
Messages
12
This worked for me after a few more steps...

Make sure you copy over the config files from the plugin (https://github.com/freenas/iocage-plugin-zoneminder) before running the post_install.sh script using the same paths shown in the repo (just remove "overlay" from the path).

Also, I installed mysql56 instead of mysql57 and the post_install.sh script has a bug. It should've created the zoneminder log folder in both cases but only did it for mysql57. Not sure why but I just manually created them after and restarted zoneminder service and it worked...

Code:
# Make the default log directory
mkdir /var/log/zm
chown www:www /var/log/zm
service zoneminder restart


It took me the whole weekend to make all the ports but it did work.
 

turtlepants

Dabbler
Joined
Jan 10, 2018
Messages
12
Update, instead of using ports, I tried installing it with pkg and that worked too & took about 10 mins...
Code:
pkg update
pkg install mysql57-server mysql57-client fcgiwrap nginx
pkg install zoneminder

I still had to use the config files & script from the zoneminder plugin repo, but this was a lot quicker.
 

Yorick

Wizard
Joined
Nov 4, 2018
Messages
1,912

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
@turtlepants,

Thanks for your posts. I did all this;
pkg update
pkg install mysql57-server mysql57-client fcgiwrap nginx
pkg install zoneminder

I then installed GitHub Desktop on a Windows 10 PC and downloaded the repo which I opened with Windows Explorer. I went though the whole tree /usr/local/etc/mysql, nginx, php-fpm.d and replaced every .conf in the jail with the corresponding file in the tree. I even created a directory conf.d and put the zoneminder.conf in it. I copied and created the post_install.sh file in the root of the jail but could not get it to run.

The IP address of the jail tells me it refuses to connect and I am lost.
 

turtlepants

Dabbler
Joined
Jan 10, 2018
Messages
12
I copied and created the post_install.sh file in the root of the jail but could not get it to run.

You need to make it executable...
Code:
chmod u+x post_install.sh
./post_install.sh


Do that and try running it again and see if that fixes it.
 

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
Thanks again @turtlepants,
I did run your suggestion and this is what I got;
root@ZoneMinder:~ # ./post_install.sh
nginx_enable: YES -> YES
mysql_enable: YES -> YES
fcgiwrap_enable: YES -> YES
fcgiwrap_user: www -> www
fcgiwrap_socket_owner: www -> www
fcgiwrap_flags: -c 4 -> -c 4
php_fpm_enable: YES -> YES
zoneminder_enable: YES -> YES
nginx already running? (pid=77685).
php_fpm already running? (pid=77677).
fcgiwrap already running? (pid=77702)
mysql already running? (pid=77670)
USER=dbadmin: command not found.
DB=zm: command not found.
DB: Undefined variable.

This is the post_install.sh file. I did remove the su on some lines because it is at root already.
#Enable nginx
sysrc -f /etc/rc.conf nginx_enable="YES"
#Enable MySQL
sysrc -f /etc/rc.conf mysql_enable="YES"
#Enable fcgi_wrapper for nginx
sysrc -f /etc/rc.conf fcgiwrap_enable="YES"
sysrc -f /etc/rc.conf fcgiwrap_user="www"
sysrc -f /etc/rc.conf fcgiwrap_socket_owner="www"
sysrc -f /etc/rc.conf fcgiwrap_flags="-c 4"
#Enable PHP
sysrc -f /etc/rc.conf php_fpm_enable="YES"
#Enable ZoneMinder
sysrc -f /etc/rc.conf zoneminder_enable="YES"

# Start the service
service nginx start 2>/dev/null
service php-fpm start 2>/dev/null
service fcgiwrap start 2>/dev/null
service mysql-server start 2>/dev/null

# Database Setup
USER="dbadmin"
# Bug in the sql script there is a default use which i cant fix without breaking other things
DB="zm"

# Save the config values
echo "$DB" > /root/dbname
echo "$USER" > /root/dbuser
export LC_ALL=C
cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 16 | head -n 1 > /root/dbpassword
PASS=`cat /root/dbpassword`

echo "Database User: $USER"
echo "Database Password: $PASS"

if [ -e "/root/.mysql_secret" ] ; then
# Mysql > 57 sets a default PW on root
TMPPW=$(cat /root/.mysql_secret | grep -v "^#")
echo "SQL Temp Password: $TMPPW"

# Configure mysql
mysql -u root -p"${TMPPW}" --connect-expired-password <<-EOF
ALTER USER 'root'@'localhost' IDENTIFIED BY '${PASS}';
CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}';
CREATE DATABASE ${DB} CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON *.* TO '${USER}'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';
FLUSH PRIVILEGES;
EOF

# Make the default log directory
mkdir /var/log/zm
chown www:www /var/log/zm

else
# Mysql <= 56 does not

# Configure mysql
mysql -u root <<-EOF
UPDATE mysql.user SET Password=PASSWORD('${PASS}') WHERE User='root';
DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '127.0.0.1', '::1');
DELETE FROM mysql.user WHERE User='';
DELETE FROM mysql.db WHERE Db='test' OR Db='test_%';
CREATE USER '${USER}'@'localhost' IDENTIFIED BY '${PASS}';
CREATE DATABASE ${DB} CHARACTER SET utf8;
GRANT ALL PRIVILEGES ON *.* TO '${USER}'@'localhost' WITH GRANT OPTION;
GRANT ALL PRIVILEGES ON ${DB}.* TO '${USER}'@'localhost';
FLUSH PRIVILEGES;
EOF
fi

#Setup Database
sed -i '' "s|ZM_DB_NAME=zm|ZM_DB_NAME=${DB}|g" /usr/local/etc/zm.conf
sed -i '' "s|ZM_DB_USER=zmuser|ZM_DB_USER=${USER}|g" /usr/local/etc/zm.conf
sed -i '' "s|ZM_DB_PASS=zmpass|ZM_DB_PASS=${PASS}|g" /usr/local/etc/zm.conf

#Import Database
mysql -u ${USER} -p${PASS} ${DB} < /usr/local/share/zoneminder/db/zm_create.sql

# Create Zoneminder data directories
-m www -c 'mkdir /var/db/zoneminder/events'
-m www -c 'mkdir /var/db/zoneminder/images'

# Restart the services after everything has been setup
service mysql-server restart 2>/dev/null
service fcgiwrap restart 2>/dev/null
service php-fpm restart 2>/dev/null
service nginx restart 2>/dev/null

# Start Zoneminder service after everything has been setup
service zoneminder start 2>/dev/null

# Output the relevant database details
echo "Database User: $USER" > /root/PLUGIN_INFO
echo "Database Password: $PASS" >> /root/PLUGIN_INFO
echo "Database Name: $DB" >> /root/PLUGIN_INFO

When I get this running, I will create a thread with a clear title and systematically list the steps for others. I have done this before with LMS 7.9.2 of FreeNAS 11.2 so that others will benefit, as I am from you. My thanks again.
 

turtlepants

Dabbler
Joined
Jan 10, 2018
Messages
12
It looks like your script ran this time but I am not sure why you are getting those command not found errors.

If you want, you can try the following to rebuild a jail from scratch just to test it out.

1. Log into the shell of freenas.
2. Create a pkgs.json file (I used vi for this but you can use a different editor)
Code:
vi pkgs.json

3. Copy the following to it & save it.
Code:
{
    "pkgs": [
    "mysql57-server",
    "mysql57-client",
    "fcgiwrap",
    "nginx",
    "zoneminder",
    "git"
    ]
}

4. Run the following commands.
Note: I named my jail zoneminder-jail but you can change to to something else. Just make sure they are all the same below & the jail name you pick is not used yet.
Code:
iocage fetch -r 11.3-RELEASE
iocage create -r 11.3-RELEASE -p ./pkgs.json -n zoneminder-jail dhcp=on boot=on
iocage exec zoneminder-jail git clone https://github.com/freenas/iocage-plugin-zoneminder.git
iocage exec zoneminder-jail cp -R iocage-plugin-zoneminder/overlay/ /
iocage exec zoneminder-jail iocage-plugin-zoneminder/post_install.sh


After the last line, I got the following output;
Code:
nginx_enable:  -> YES
mysql_enable:  -> YES
fcgiwrap_enable:  -> YES
fcgiwrap_user:  -> www
fcgiwrap_socket_owner:  -> www
fcgiwrap_flags:  -> -c 4
php_fpm_enable:  -> YES
zoneminder_enable:  -> YES
Performing sanity check on nginx configuration:
Starting nginx.
Performing sanity check on php-fpm configuration:
Starting php_fpm.
Starting fcgiwrap.
Starting mysql.
Database User: dbadmin
Database Password: [randomly generated password]
SQL Temp Password: [randomly generated password]
mysql: [Warning] Using a password on the command line interface can be insecure.
mysql: [Warning] Using a password on the command line interface can be insecure.
Stopping mysql.
Waiting for PIDS: 64245.
Starting mysql.
Stopping fcgiwrap.
Waiting for PIDS: 52334.
Starting fcgiwrap.
Performing sanity check on php-fpm configuration:
Stopping php_fpm.
Waiting for PIDS: 52249.
Performing sanity check on php-fpm configuration:
Starting php_fpm.
Performing sanity check on nginx configuration:
Stopping nginx.
Waiting for PIDS: 52179.
Performing sanity check on nginx configuration:
Starting nginx.


The Database User, and Database Password are stored in ~/ folder as dbuser and dbpassword. These are needed if you ever need to access the MYSQL database for some reason.

This only sets up the jail and gets zoneminder running for testing. Everything will be stored inside the jail and if you ever need to rebuild the jail for some reason, all your video will be lost. I have notes somewhere on how to mount a pool inside a jail for zoneminder but it will take it bit to find them. Hopefully, this will get you up and running for the time being.
 

Frank Collins

Explorer
Joined
Apr 10, 2019
Messages
53
@turtlepants,
Thank you, it all worked (after I reading your directions properly rather than a bull at a gate). I have added a camera and video is being captured with motion detection.

Tomorrow (it is about 5pm here and refreshment time), I will start a thread with an unambiguous title and post your code, hopefully with a few tips to prevent behaviour like mine. I will also keep it updated if there are any useful additions. The nag pop-up still happens saying the latest version is 1.34.8 but I'd rather be a version or two behind than several dozen. It looks far more 'professional' and seems to have far fewer (none at this stage) niggles than the official plug-in.

Best regards,

Frank
 
Top