Page 1 of 5

ZM on FreeBSD

Posted: Mon Mar 28, 2016 12:02 am
by Darius121
Hi,
I'm trying to update the FreeBSD port (currently 1.25) but I am having an issue with paths, I am seeing it install a lot of stuff to /, eg..

Code: Select all

-- Installing: //ONVIF::Media::Elements::GetAudioSourceConfigurations.3
-- Installing: //ONVIF::Analytics::Types::VideoAttributes.3
-- Installing: //ONVIF::PTZ::Types::WhiteBalanceOptions.3
-- Installing: //ONVIF::Analytics::Types::PrefixedIPv6Address.3
-- Installing: //ONVIF::Device::Elements::VideoAnalyticsConfiguration.3
It looks like all the perl stuff is going into / rather than where it's supposed to (/usr/local/blah). I don't really know where to start looking, my cmake and perl fu is pretty weak :(

The // says to me a variable is empty but I don't know which one..

Can anyone give me a hint? :)

(I'm also on IRC as Dar1us)

Re: ZM on FreeBSD

Posted: Mon Mar 28, 2016 1:37 pm
by Darius121
Actually I did some proper searching and realised people are already working on getting it going.

I found a fix for my problem, however I need to work on some more stuff.

If anyone is interested in helping update the port please get in touch.

Re: ZM on FreeBSD

Posted: Fri Apr 01, 2016 7:05 pm
by knight-of-ni
That is happening because the Perl that ships with the latest FreeBSD has not been built properly.
The "vendor" installation folders have not been assigned as can be seen from this output:

Code: Select all

$ perl '-V:install.*'
installarchlib='/usr/local/lib/perl5/5.20/mach';
installbin='/usr/local/bin';
installhtml1dir='';
installhtml3dir='';
installman1dir='/usr/local/lib/perl5/5.20/perl/man/man1';
installman3dir='/usr/local/lib/perl5/5.20/perl/man/man3';
installprefix='/usr/local';
installprefixexp='/usr/local';
installprivlib='/usr/local/lib/perl5/5.20';
installscript='/usr/local/bin';
installsitearch='/usr/local/lib/perl5/site_perl/mach/5.20';
installsitebin='/usr/local/bin';
installsitehtml1dir='';
installsitehtml3dir='';
installsitelib='/usr/local/lib/perl5/site_perl';
installsiteman1dir='/usr/local/lib/perl5/site_perl/man/man1';
installsiteman3dir='/usr/local/lib/perl5/site_perl/man/man3';
installsitescript='/usr/local/bin';
installstyle='lib/perl5';
installusrbinperl='undef';
installvendorarch='';
installvendorbin='';
installvendorhtml1dir='';
installvendorhtml3dir='';
installvendorlib='';
installvendorman1dir='';
installvendorman3dir='';
installvendorscript='';
The real fix is to get the FreeBSD maintainer to populate the vendor folders. The workaround is to set the cmake flag ZM_PERL_MM_PARMS INSTALLDIRS=site when building zoneminder, or set ZM_TARGET_DISTRO=freeBSD to configure many of the cmake variables to values that makes sense in a FreeBSD environment.

Re: ZM on FreeBSD

Posted: Sat Apr 02, 2016 4:18 am
by Darius121
OK, I'll email the perl port maintainer. I did set ZM_PERL_MM_PARMS and it worked, as does setting ZM_TARGET_DISTRO.

I think the FreeBSD path defaults should be a little different to what they are (which more closely match the existing zone minder port in FreeBSD)
Also, can 'freeBSD' be changed to 'FreeBSD'? (a minor nit I know)

Both can be done with this patch..

Code: Select all

diff --git a/CMakeLists.txt b/CMakeLists.txt
index b2014e1..1615fd9 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -182,16 +182,16 @@ elseif(ZM_TARGET_DISTRO STREQUAL "OS13")
 	set(ZM_WEB_GROUP "www")
 	set(ZM_WEBDIR "/srv/www/htdocs/zoneminder")
 	set(ZM_CGIDIR "/srv/www/cgi-bin")
-elseif(ZM_TARGET_DISTRO STREQUAL "freeBSD")
+elseif(ZM_TARGET_DISTRO STREQUAL "FreeBSD")
 	set(ZM_RUNDIR "/var/run/zm")
         set(ZM_SOCKDIR "/var/run/zm")
 	set(ZM_TMPDIR "/var/tmp/zm")
-        set(ZM_CONTENTDIR "/usr/local/var/lib/zoneminder")
+        set(ZM_CONTENTDIR "/var/run/zm")
         set(ZM_WEB_USER "www")
         set(ZM_WEB_GROUP "www")
         set(ZM_CONFIG_DIR "/usr/local/etc/zm")
-        set(ZM_WEBDIR "/usr/local/share/zoneminder/www")
-        set(ZM_CGIDIR "/usr/local/libexec/zoneminder/cgi-bin")
+        set(ZM_WEBDIR "/usr/local/www/zoneminder/data")
+        set(ZM_CGIDIR "/usr/local/www/zoneminder/cgi-bin")
         set(ZM_PERL_MM_PARMS "INSTALLDIRS=site")
 endif((ZM_TARGET_DISTRO STREQUAL "f22") OR (ZM_TARGET_DISTRO STREQUAL "f23"))

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 9:36 am
by abi
I have almost working distrubution for FreeBSD, however 2 blockers on zms preventing port release.
https://github.com/abishai/Zoneminder-port
If you wish, you can test it and send feedback.

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 12:01 pm
by knight-of-ni
I am not necessarily opposed to changing the folders configured when setting ZM_TARGET_DISTRO.
However, there needs to be a good, documented reason why.

The folders currently assigned are all based off the Filesystem Hierarchy Standard and the FreeBSD handbook:
https://en.wikipedia.org/wiki/Filesyste ... y_Standard
https://www.freebsd.org/doc/handbook/dirstructure.html

This does not mean there is no room for flexibility as these standards can be subject to different interpretations.
However, I am not willing to change the folders simply because someone does not like them or they are not convenient for someone.
I don't necessarily like them either, but it doesn't matter what we like. What matters is that the entire community follows the same documentation and standards.

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 12:09 pm
by Darius121
abi wrote:I have almost working distrubution for FreeBSD, however 2 blockers on zms preventing port release.
https://github.com/abishai/Zoneminder-port
If you wish, you can test it and send feedback.
Wow great, I should have done more googling before going down this road :)

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 12:16 pm
by Darius121
knnniggett wrote:I am not necessarily opposed to changing the folders configured when setting ZM_TARGET_DISTRO.
However, there needs to be a good, documented reason why.

The folders currently assigned are all based off the Filesystem Hierarchy Standard and the FreeBSD handbook:
https://en.wikipedia.org/wiki/Filesyste ... y_Standard
https://www.freebsd.org/doc/handbook/dirstructure.html

This does not mean there is no room for flexibility as these standards can be subject to different interpretations.
However, I am not willing to change the folders simply because someone does not like them or they are not convenient for someone.
I don't necessarily like them either, but it doesn't matter what we like. What matters is that the entire community follows the same documentation and standards.
That sounds reasonable.

My changes were suggested specifically because ports are much more likely to use /var/run for temporary content. This can get nuked between reboots - is that going to impact on an ZM functionality?

I changed the web and CGI dirs because all of the other "web application" type ports install into /usr/local/www/XXX and the old ZM port did as well so any existing users which upgrade would expect it to be there (and all their Apache config would point there)

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 1:00 pm
by Darius121
Darius121 wrote:
abi wrote:I have almost working distrubution for FreeBSD, however 2 blockers on zms preventing port release.
https://github.com/abishai/Zoneminder-port
If you wish, you can test it and send feedback.
Wow great, I should have done more googling before going down this road :)
Also, what are the 2 blocking issues?

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 1:08 pm
by knight-of-ni
Darius121 wrote: Also, what are the 2 blocking issues?
One of the blocking issues is a report that the his build of ZoneMinder can only stream to one client at a time. Based on the presented data, this does not look like an issue with the ZoneMinder source code itself. This thread is probably a good place to have this discussion and determine the fix.

What would be very helpful is data from another build of ZoneMinder on FreeBSD. On a confirmed working installation of ZoneMinder on FreeBSD, try to view the same live monitor from two clients simultaneously. We also need to know the webserver you are using (apache, nginx, etc).

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 1:42 pm
by Darius121
knnniggett wrote:
Darius121 wrote: Also, what are the 2 blocking issues?
One of the blocking issues is a report that the his build of ZoneMinder can only stream to one client at a time. Based on the presented data, this does not look like an issue with the ZoneMinder source code itself. This thread is probably a good place to have this discussion and determine the fix.

What would be very helpful is data from another build of ZoneMinder on FreeBSD. On a confirmed working installation of ZoneMinder on FreeBSD, try to view the same live monitor from two clients simultaneously. We also need to know the webserver you are using (apache, nginx, etc).
I just tried the port with 1 active camera and 3 different clients and it worked. Specifically on the same PC I used Safari and Chrome, and I then connected with my phone (iOS Safari) and all 3 ran simultaneously.

I am using Apache 2.4 and my config block (/usr/local/etc/apache24/Includes/zoneminder.conf) looks like...

Code: Select all

<VirtualHost *:80>
    ServerName zm.local
    ServerAdmin webmaster@dons.net.au

    DocumentRoot "/usr/local/www/zoneminder/"
    <Directory "/usr/local/www/zoneminder">
        Options FollowSymLinks
        AllowOverride All
	Require all granted
    </Directory>

    ScriptAlias /cgi-bin "/usr/local/www/zoneminder/cgi-bin"
    <Directory "/usr/local/www/zoneminder/cgi-bin">
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
	Require all granted
    </Directory>

    # Use the first option to have Apache logs written to the general log
    # directory, or the second to have them written to the regular Apache
    # directory (you may have to change the path to that used on your system)
    #ErrorLog /var/log/zm/apache-error.log
    #ErrorLog /var/log/httpd/zm-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    #LogLevel notice
    LogLevel debug

    # Use the first option to have Apache logs written to the general log
    # directory, or the second to have them written to the regular Apache
    # directory (you may have to change the path to that used on your system)
    #CustomLog /var/log/zm/apache-access.log combined
    #CustomLog /var/log/httpd/zm-access.log combined
</VirtualHost>
Note that I am running it inside a jail, I would expect that to make a difference but you never know.

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 1:46 pm
by knight-of-ni
Excellent data. Now we just need @abi to compare his system to yours.
He is using nginx, and it could be something with that configuration or, failing that, it could be something unexpected with the particular way ZoneMinder was built.

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 1:51 pm
by Darius121
knnniggett wrote:Excellent data. Now we just need @abi to compare his system to yours.
He is using nginx, and it could be something with that configuration or, failing that, it could be something unexpected with the particular way ZoneMinder was built.
OK, let me know if you want me to generate some debugging or log information for comparison.

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 2:18 pm
by abi
Darius121 wrote:OK, let me know if you want me to generate some debugging or log information for comparison.
1. Do you have analog/USB cameras ? I have no luck compiling support of them - cmake doesn't detect V4L. However, I didn't investigated the matter.
2. Can you check my port under nginx?
You need to install ZM, nginx, php-fpm
Config for nginx I use
/usr/local/etc/nginx/nginx.conf

Code: Select all

user  www;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

pid        /var/run/nginx.pid;

events {
    worker_connections  1024;
}

http {
    include       mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    sendfile on;
    tcp_nopush on;
    tcp_nodelay on;
    keepalive_timeout  65;
    server_tokens off;

    gzip  on;
    gzip_comp_level 4;
    gzip_min_length 1100;
    gzip_buffers 64 8k;
    gzip_http_version 1.1;
    gzip_proxied any;
    gzip_types text/plain application/xml application/x-javascript text/css;

    client_max_body_size 10m;

    include /usr/local/etc/nginx/sites/*;
}
Create sites folder with ZM config

Code: Select all

server {
        listen 80;
        server_name zm.local
        keepalive_timeout 70;

        root /usr/local/www/zoneminder;
        index index.php index.html index.htm;
#        access_log /home/www/zoneminder/logs/access.log main;
#        error_log /home/www/zoneminder/logs/error.log;
proxy_buffering off;
    location = /cgi-bin/nph-zms {
        proxy_buffering off;
        root /usr/local/www/zonemindeR;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /usr/local/www/zoneminder/cgi-bin/nph-zms;
        fastcgi_pass unix:/var/run/fcgiwrap/fcgiwrap.sock;
    }

        location ~ \.php(?:$|/) {
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass   unix:/tmp/php-fpm.sock;
                fastcgi_index  index.php;
proxy_buffering off;
                fastcgi_param  DOCUMENT_ROOT    /usr/local/www/zoneminder;
                fastcgi_param  SCRIPT_FILENAME  /usr/local/www/zoneminder$fastcgi_script_name;

                fastcgi_param  PATH_TRANSLATED  /usr/local/www/zoneminder$fastcgi_script_name;
                include fastcgi_params;
        }
}
Edit /usr/local/etc/php-fpm.conf to use unix sockets.

Code: Select all

; Note: This value is mandatory.
;listen = 127.0.0.1:9000
listen = /tmp/php-fpm.sock

; Set listen(2) backlog.
; Default Value: 65535 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 65535

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
listen.owner = www
listen.group = www
listen.mode = 0660
Enable stuff in /etc/rc.conf and start daemons

Code: Select all

# NGIX
nginx_enable="YES"
fcgiwrap_enable="YES"
fcgiwrap_user="www"

# PHP
php_fpm_enable="YES"
3. Signal 4 should be confirmed. Make some events and try to play it. zms should crash.
4. Also, I have incorrect titles in monitor view - http://i.imgur.com/pUUOYkE.png
5. php notices in database. select User from Monitors; That's due to E_ALL error reporting used in index.php
6. One of .pl's throwing error, but this one is harmless and, obviously, trivial.

Code: Select all

'zmtelemetry.pl' exited abnormally, exit status 9

Re: ZM on FreeBSD

Posted: Wed Apr 06, 2016 2:34 pm
by abi
knnniggett wrote:I am not necessarily opposed to changing the folders configured when setting ZM_TARGET_DISTRO.
However, there needs to be a good, documented reason why.

The folders currently assigned are all based off the Filesystem Hierarchy Standard and the FreeBSD handbook:
https://en.wikipedia.org/wiki/Filesyste ... y_Standard
https://www.freebsd.org/doc/handbook/dirstructure.html

This does not mean there is no room for flexibility as these standards can be subject to different interpretations.
However, I am not willing to change the folders simply because someone does not like them or they are not convenient for someone.
I don't necessarily like them either, but it doesn't matter what we like. What matters is that the entire community follows the same documentation and standards.
Port collection assumes stuff executing by http servers goes to /usr/local/www
https://github.com/freebsd/freebsd-port ... sd.port.mk

Code: Select all

WWWDIR?= ${PREFIX}/www/${PORTNAME}
However, I'm not insisting you change it as port infrastructure can do whatever porter need with sources, I'd say let's make port and when it's accepted by FreeBSD commiters, we can tweak some defaults if we still want to.