ZoneMinder

HowTos > ZoneMinder

Here is a basic guide to setup the marvellous surveillance software Zoneminder (www.zoneminder.com) in a Guruplug:


Assumptions

The Guruplug it's connected to the ethernet 0
The OS installed is Debian and starting from flash.
You know how to edit a file, I'm not going to give details of using 'vi' or another editor.

Disclaimer

This process has been tested in a Guruplug Server Plus running:
       Debian Linux guruplug-debian 2.6.33.7 #3 PREEMPT Thu Dec 9 14:14:08 EST 2010 armv5tel GNU/Linux

The author assumes no responsibility for errors or ommissions in the documentation , neither if your Guruplug gets bricked in the process.

Connect to the Guruplug with Jtag & ethernet, setup the connection so you could connect using SSH.
Open a SSH connection using Putty or another application (terminal).


To setup your guruplug to boot using an ethernet connection and a fixed ip address, backup the existing init_setup.sh and edit it to show this:

#!/bin/sh
# This is called from /etc/rc.local to perform the initial setup.
insmod /root/uap8xxx.ko
rmmod libertas_sdio libertas
cp /root/firmware/sd8688* /lib/firmware/
/etc/init.d/udhcpd stop
/etc/init.d/dnsmasq stop
echo 2 > /proc/uap/uap0/hwstatus
ifconfig uap0 down
rmmod uap8xxx
modprobe libertas_sdio
rm -f /lib/firmware/sd8688*
# stop bluetooth service
service bluetooth stop

# start eth0 with fixed ip
#### change the addresses, subnet mask, etc to addapt it to your router configuration #####
ifconfig eth0 192.168.1.43 netmask 255.255.255.0 up
route add -net 192.168.1.0 netmask 255.255.255.0 eth0
route add default gw 192.168.1.1 eth0

# turn off leds save energy
echo 0 > `eval ls /sys/class/leds/*plug*\:green\:health/brightness`
echo 0 > `eval ls /sys/class/leds/*plug*\:green\:wmode/brightness`

### to use an external usb hard drive to store the zm events, mount the drive, the sleep gives time to the hard drive to be ready, uncomment these lines if you need it
#mount -t ntfs /dev/sdc1 /zmdisk
#sleep 30

In the same way, I have edited the wlan.sh, basically to avoid startting the wifi in the Guruplug, now looks like this:

#!/bin/sh
# The firmware files are -> sd8688.bin & sd8688_helper.bin
# The firmware files need to be present in /lib/firmware
rmmod libertas_sdio libertas
cp /root/firmware/sd8688* /lib/firmware/
/etc/init.d/udhcpd stop
/etc/init.d/dnsmasq stop
echo 2 > /proc/uap/uap0/hwstatus
ifconfig uap0 down
rmmod uap8xxx
modprobe libertas_sdio
# This will be deleted on bootup.
# Bootup by-default is always AP mode.
touch /etc/wlanclient.mode
# Delete the firmware immediately so that next bootup is in AP mode.
rm -f /lib/firmware/sd8688*
# The newly created interface will be eth(n)
# The following command lists all the available wireless networks
# iwlist <ifc-name> scanning
# To connect to a particular SSID
# iwconfig <ifc-name> <essid>

Edit your /etc/apt/sources.list to have at least this entries:

deb http://ftp.us.debian.org/debian/ lenny main contrib non-free
deb http://http.us.debian.org/debian stable main contrib non-free
deb http://security.debian.org lenny/updates main contrib non-free
deb http://www.backports.org/debian lenny-backports main contrib non-free
deb http://ftp.uk.debian.org/debian sid main
deb http://ftp.uk.debian.org/debian lenny main
deb http://ftp.uk.debian.org/debian squeeze main
deb http://ftp.de.debian.org/debian squeeze main
deb http://ftp.es.debian.org/debian squeeze main

Now, it's time to get your Guruplug Debian updated and upgraded using:

apt-get update
apt-get upgrade

This will take some time as will download lots of packages and install the updated packages to your system


Uninstall (or disable it to start in init.d) the lighttpd package, to avoid a port conflict , as we will use apache2.

apt-get remove lighttpd

Install zoneminder (surveillance app), postfix (mailer), mailx (mailer), ufw (firewall), preload (tune system preformance) and phpmyadmin (mysql table maintenance)

apt-get install zoneminder ufw preload postfix mailx phphmyadmin

Note: if you get any error installing a package, use the following command:

apt-get -f install 'name of package

Set the correct time, using :

dpkg-reconfigure tzdata

To install support for ntfs hard disks:

apt-get install libfuse2 ntfs-3g

Setup the firewall (ufw)

To setup ufw, follow the guide here-> https://help.ubuntu.com/community/UFW

I have setup my Guruplug to not respond to pings by editing the file /etc/ufw/before.rules editing the following lines:

# ok icmp codes
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
-A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT
-A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
-A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
-A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT

Change the "ACCEPT" to "DROP"!

# ok icmp codes
-A ufw-before-input -p icmp --icmp-type destination-unreachable -j DROP
-A ufw-before-input -p icmp --icmp-type source-quench -j DROP
-A ufw-before-input -p icmp --icmp-type time-exceeded -j DROP
-A ufw-before-input -p icmp --icmp-type parameter-problem -j DROP
-A ufw-before-input -p icmp --icmp-type echo-request -j DROP

Then, I have configured the firewall to let me use the ports 22 (ssh) and 80 (http)

ufw allow 22
ufw allow 80
ufw enable

Once the packages have been installed, configure apache2 to show the Zoneminder console when connecting to the computer
Edit the file /etc/apache2/sites-enabled/000-default

Find the line: 'DocumentRoot /var/www', change it to -> 'DocumentRoot/usr/share/zoneminder'
Find the line: '<Directory /var/www/>', change it to -> '<Directory /usr/share/zoneminder/>'

Setup your shared memory settings in the file /etc/sysctl.conf, add these lines to the end

kernel.shmall = 131072
kernel.shmmax = 536870912

This settings work for two ipcams, with a resolution of 320x240 pixels, maybe you need to refine these settings to match your setup.


Reboot your Guruplug, open a browser with the ipaddress of your Guruplug (for instance: http://192.168.1.43 ), the Zoneminder console will be shown.

If you get an error during startup of apache2 (apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName), edit /etc/apache2/httpd.conf, add a line ServerName myGuruName


I hope that your system is up and running at this point!

If you need help, contact with me in the forum, user=pacolm

--Pacolm 10:15, 26 January 2011 (UTC)