Home/Building Automation

Scripts, documents and anything related to Home Automation and Building Control at VEMAR.

antonello.ventre@vemarsas.it

Installazione Zoneminder su Debian Wheezy

Scaricare e installare Debian Wheezy NetInstall 64-bits (http://www.debian.org/CD/netinst/)

Modificare sources.list :

nano /etc/apt/sources.list

e aggiungere
deb ftp://ftp.deb-multimedia.org wheezy main non-free
wget http://www.deb-multimedia.org/pool/main/d/deb-multimedia-keyring/deb-multimedia-keyring_2012.05.10-dmo4_all.deb
dpkg -i debian-multimedia-keyring_2010.12.26_all.deb

aggiornare il sistema :

apt-get update

installare i pacchetti multimediali :

apt-get install libfaac-dev
apt-get install libmp3lame-dev
apt-get install libogg-dev
apt-get install libtheora-dev
apt-get install libvorbis-dev
apt-get install libx264-dev
apt-get install libxvidcore4-dev

Installare i pacchetti necessari :

aptitude install acpid build-essential linux-headers-`uname -r` automake perl libauthen-pam-perl \
apache2 libpam-runtime libio-pty-perl libmysqlclient-dev php5 php5-cli libapache2-mod-php5 php5-mysql \
libarchive-zip-perl libdate-manip-perl libdevice-serialport-perl libjpeg62 libmime-perl libstdc++6 libwww-perl \
zlib1g zip unzip patch ntp openssl libpcre3-dev libssl-dev libjpeg-progs libcurl4-gnutls-dev munin munin-node libmime-lite-perl \
netpbm libbz2-dev subversion yasm libnet-ssleay-perl libauthen-pam-perl libio-pty-perl apt-show-versions git-core mysql-server mysql-client

Installare libjpeg-turbo *

*(installata da Sourceforge per evitare warning con telecamere Foscam di tipo zmc_m114935WAR [Corrupt JPEG data: 1 extraneous bytes before marker 0xd9]

[[http://lachlanmiskin.com/blog/2012/06/25/zoneminder-foscam-fi8918w-war-corrupt-jpeg-data-extraneous-bytes-before-marker-0xd9/]]

wget http://downloads.sourceforge.net/project/libjpeg-turbo/1.1.1/libjpeg-turbo_1.1.1_amd64.deb?use_mirror=voxel

mv libjpeg-turbo_1.1.1_amd64.deb?use_mirror=voxel libjpeg-turbo_1.1.1_amd64.deb && \
dpkg -i libjpeg-turbo_1.1.1_amd64.deb

ln -s /opt/libjpeg-turbo/lib/libjpeg.a /usr/lib/libjpeg.a && \
ln -s /opt/libjpeg-turbo/include/jconfig.h /usr/include/jconfig.h && \
ln -s /opt/libjpeg-turbo/include/jerror.h /usr/include/jerror.h && \
ln -s /opt/libjpeg-turbo/include/jmorecfg.h /usr/include/jmorecfg.h && \
ln -s /opt/libjpeg-turbo/include/jpeglib.h /usr/include/jpeglib.h

echo "/opt/libjpeg-turbo/lib" > /etc/ld.so.conf.d/libjpeg-turbo.conf && \
echo "/usr/local/lib" > /etc/ld.so.conf.d/ffmpeg.conf && \
echo "LD_LIBRARY_PATH=/usr/local/lib:/opt/libjpeg-turbo/lib:$LD_LIBRARY_PATH" >> /etc/bash.bashrc && \
echo "export LD_LIBRARY_PATH" >> /etc/bash.bashrc

ldconfig

Installare alcuni moduli perl con Cpan

perl -MCPAN -e shell

install CPAN

exit

perl -MCPAN -e shell

install YAML PHP::Serialization Module::Load X10::ActiveHome

exit

LC_ALL=C perl -MCPAN -e shell

install Sys::Mmap

install DBI

install DBD::mysql

exit

Installare FFMPEG 0.10

cd /usr/src && wget http://ffmpeg.org/releases/ffmpeg-0.10.tar.gz

tar -xzvf ffmpeg-0.10.tar.gz

mv ffmpeg-0.10 ffmpeg

#Preparar y compilar FFmpeg

cd /usr/src/ffmpeg/ && ./configure --enable-gpl --enable-shared --enable-pthreads --enable-libx264 --enable-libfaac --enable-nonfree --enable-x11grab --enable-version3

make

make install

make install-libs

cd /lib && ln -s /usr/local/lib/libswscale.so.0 && \
ln -s /usr/local/lib/libavformat.so.52 && \
ln -s /usr/local/lib/libavcodec.so.52 && \
ln -s /usr/local/lib/libavutil.so.50 && \
ln -s /usr/local/lib/libavdevice.so.52

ldconfig

Installare Zoneminder

cd /usr/src 

wget http://www.zoneminder.com/downloads/ZoneMinder-1.25.0.tar.gz

tar -xzvf ZoneMinder-1.25.0.tar.gz

mv ZoneMinder-1.25.0 zm

ZM_DB_PASS=zmpass 

cd /usr/src/zm && \ 
./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin \
ZM_DB_HOST=localhost ZM_DB_NAME=zm ZM_DB_USER=zmuser \
ZM_DB_PASS=zmpass ZM_SSL_LIB=openssl --enable-debug=no \
--with-webgroup=www-data --with-webuser=www-data --enable-mmap=yes CPPFLAGS="-D__STDC_CONSTANT_MACROS ${CPPFLAGS}" 

autoconf

aclocal

automake

make

mysql -u root -p < db/zm_create.sql
mysql -u root -p

grant select,insert,update,delete on zm.* to 'zmuser'@localhost identified by 'zmpass';

quit

mysqladmin -p reload
make install

Installiamo Cambozola plugin Java per la visione dello streaming su Explorer e Chrome

cd /usr/src && wget http://www.charliemouse.com:8080/code/cambozola/cambozola-latest.tar.gz

tar -xzvf cambozola-latest.tar.gz

#Cambiar las xx con el numero de version descargada de cambozola

cp cambozola-0.xx/dist/cambozola.jar /var/www/zm

Creiamo lo script di inizializzazione di Zoeminder

nano -w /etc/init.d/zm

Copiamo il contenuto sottostante nel file etc/init.d/zm

#!/bin/sh
### BEGIN INIT INFO
# Provides:          ZM
# Required-Start:    $network mysql $local_fs 
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: <Enter a short description of the sortware>
# Description:       <Enter a long description of the software>
#                    <...>
#                    <...>
### END INIT INFO

prog=ZoneMinder
ZM_PATH_BIN="/usr/local/bin" 
command="$ZM_PATH_BIN/zmpkg.pl" 

start() {
        echo -n "Starting $prog: " 
        $command start
        RETVAL=$?
        [ $RETVAL = 0 ] && echo success
        [ $RETVAL != 0 ] && echo failure
        return $RETVAL
}
stop() {
        echo -n "Stopping $prog: " 
        $command stop
        RETVAL=$?
        [ $RETVAL = 0 ] && echo success
        [ $RETVAL != 0 ] && echo failure
}
status() {
        result=`$command status`
        if [ "$result" = "running" ]; then
                echo "ZoneMinder is running" 
                RETVAL=0
        else
                echo "ZoneMinder is stopped" 
                RETVAL=1
        fi
}

case "$1" in
'start')
        start
        ;;
'stop')
        stop
        ;;
'restart')
        stop
        start
        ;;
'status')
        status
        ;;
*)
        echo "Usage: $0 { start | stop | restart | status }" 
        RETVAL=1
        ;;
esac
exit $RETVAL

Garantiamo i permessi di esecuzione allo script

chmod 755 /etc/init.d/zm
chown www-data:www-data -R /tmp/zm

Se tutto ha funzionato correttamente lanciando Zoneminder con

/etc/init.d/zm start

e digitando su Firefox l'indirizzo seguente :

http://Tu_IP_Zoneminder/zm

dovrebbe apparire l'interfaccia di amministrazione di Zoneminder

Problemi ricorrenti :

Se si dovesse verificare il seguente errore :
ERR [Got unexpected memory map file size 1524, expected 9217524]

consultando il wiki di Zoneminder :

[[www.zoneminder.com/wiki/index.php]]

/FAQ#What_does_a_.27Can.27t_shmget:_Invalid_argument.27_error_in_my_logs_mean.3F_and_my_cameras_won.27t_display_video_at_higher_resolutions

modifichiamo /etc/sysctl.conf

nano 

Aggiungendo

kernel.shmall = 167772160
kernel.shmmax = 167772160

e poi un bel reboot del sistema
dovrebbe risolvere il problema

se cliccando sulla funzione Probe in aggiungi nuovo monitor si presenta il seguente errore:

Unable to probe network cameras, status is '127'

eseguire la seguente modifica :

in /skins/classic/views/monitorprobe.php

sostituiamo $command="arp -a"; con 
$command = "/usr/sbin/arp -a";

Per risolvere il problema "shared data size conflict" 
modificare il file Memory.pm

modificando

$arch = int(3.2*length(~0));

con

$arch = 32;

N.B Medibuntu non è più supportato quindi per caricare alcuni codec Multimediali seguire la seguente procedura :

sudo apt-get install curl
sudo rm /etc/apt/sources.list.d/medibuntu.list
curl ftp://ftp.videolan.org/pub/debian/videolan-apt.asc | sudo apt-key add -
echo "deb ftp://ftp.videolan.org/pub/debian/stable ./" | sudo tee /etc/apt/sources.list.d/libdvdcss.list
sudo apt-get update

Bibliografia

www.zoneminder.com/wiki/index.php

http://www.zoneminder.com/wiki/index.php/Debian_6_Squeeze_64-bit_with_ZoneMinder_1.25.0_Preview,_FFmpeg,_libjpeg-turbo,_Webmin,_Cambozola%28Spanish_Diciembre_2011%29