Forums
  News| Documentation| Screenshots| Downloads| Support| Forums| Wiki| Shop| Search| DonateHome

Ubuntu 6.06 - Alternate

From ZoneMinder

Jump to: navigation, search

Here's an update provided by R2D2 in this thread: http://www.zoneminder.com/forums/viewtopic.php?t=6670

I've used it to create ZoneMinder systems and have no problems what-so-ever.

This page is configured to allow copy-and-paste directly to the editor and/or command line.

Contents

Installation of ZoneMinder on Ubuntu

Modify apt to grab correct repositories

Replace your /etc/apt/sources.list with the following (you may want to replace the `de' with your country code, which may speed up the access to repositories):

# 
# Sources required for ZoneMinder install
#
deb http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper main restricted
deb http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper-updates main restricted
deb http://de.archive.ubuntu.com/ubuntu/ dapper universe
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper universe
deb http://de.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb-src http://de.archive.ubuntu.com/ubuntu/ dapper-backports main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu dapper-security main restricted
deb-src http://security.ubuntu.com/ubuntu dapper-security main restricted
deb http://security.ubuntu.com/ubuntu dapper-security universe
deb-src http://security.ubuntu.com/ubuntu dapper-security universe

Execute the following commands to pull in all of the required updates and packages. Note that this will download approximately 98MB of data:

sudo apt-get update
sudo apt-get install apache2 php5 php5-mysql libapache2-mod-auth-mysql mysql-server g++ \
   make netpbm libssl-dev libjpeg62-dev libmime-perl libwww-perl libarchive-tar-perl \
   libdate-manip-perl libarchive-zip-perl libmime-lite-perl libdbi-perl libdbd-mysql-perl \
   libpcre3-dev libmysqlclient12-dev libcurl3-openssl-dev libjpeg-mmx-dev \
   liblwp-protocol-http-socketunix-perl mc ffmpeg xawtv

Restart apache:

sudo /etc/init.d/apache2 restart

Configure and Compile ZoneMinder

Fetch, extract and configure ZoneMinder (note that file names are up-to-date as of December 11, 2006)

cd /usr/local/src
sudo wget http://www2.zoneminder.com/downloads/ZoneMinder-1.22.3.tar.gz
sudo tar -xvzf ZoneMinder-1.22.3.tar.gz
cd ZoneMinder-1.22.3
sudo ./configure --with-webdir=/var/www/zm --with-cgidir=/usr/lib/cgi-bin --with-webuser=www-data --with-webgroup=www-data

Configure MySQL

From the command prompt, create the ZoneMinder database in MySQL:

sudo mysql < db/zm_create.sql

Run MySQL on the "mysql" (permissions) database

sudo mysql mysql

and allow the ZoneMinder user access to the databases that were just created:

GRANT ALL PRIVILEGES ON zm.* TO 'zmuser'@localhost identified by 'zmpass';
quit

Reload the MySQL databases to make sure that permissions are correct for the next step:

sudo mysqladmin reload

Install ZoneMinder

cd /usr/local/src/ZoneMinder-1.22.3
sudo make install

Configure ZoneMinder Auto-Start

Create a file /etc/init.d/zm containing the following:

#!/bin/sh
# description: Control ZoneMinder as a Service
# chkconfig: 2345 99 00
# Source function library.
#. /etc/rc.d/init.d/functions

prog=ZoneMinder
ZM_VERSION="1.22.3"
ZM_PATH_BIN="/usr/local/bin"
ZM_CONFIG="/usr/local/etc/zm.conf"
command="$ZM_PATH_BIN/zmpkg.pl"

loadconf()
{
	if [ -f $ZM_CONFIG ]; then
		. $ZM_CONFIG
	else
		echo "ERROR: $ZM_CONFIG not found."
		return 1
	fi
}

# Check for old config and update if needed
checkcfg()
{
	# Check config
	if [ "$ZM_DB_HOST" = "" -o "$ZM_DB_NAME" = "" -o "$ZM_DB_USER" = "" -o "$ZM_DB_PASS" = "" ]; then
		if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USERA" != "" -a "$ZM_DB_PASSA" != "" ]; then
			echo -n "Converting $ZM_CONFIG"
			cp $ZM_CONFIG $ZM_CONFIG.old && \
			cat $ZM_CONFIG.old | \
				grep -v ZM_DB_USERB | \
				grep -v ZM_DB_PASSB | \
				sed -e 's/ZM_DB_USERA/ZM_DB_USER/' | \
				sed -e 's/ZM_DB_PASSA/ZM_DB_PASS/' >$ZM_CONFIG && \
			rm -f $ZM_CONFIG.old
			RETVAL=$?
			[ $RETVAL = 0 ] && echo_success
			[ $RETVAL != 0 ] && echo_failure
			echo
		fi
		if [ "$ZM_DB_SERVER" != "" -a "$ZM_DB_NAME" != "" -a "$ZM_DB_USER" != "" -a "$ZM_DB_PASS" != "" ]; then
			echo -n "Converting $ZM_CONFIG to 1.22.0"
			cp $ZM_CONFIG $ZM_CONFIG.old
			rm -f $ZM_CONFIG
			cat $ZM_CONFIG.old | \
			sed -e 's/ZM_DB_SERVER/ZM_DB_HOST/' >/tmp/$$
			. /tmp/$$
			cp $ZM_CONFIG.rpmnew $ZM_CONFIG && chmod 644 $ZM_CONFIG
			for n in ZM_DB_HOST ZM_DB_NAME ZM_DB_USER ZM_DB_PASS; do
				eval "val=\$$n"
				if [ "$val" != "" ]; then
				cp $ZM_CONFIG /tmp/$$.rpmnew &&
				sed 's/^'$n='.*$/'$n=$val'/g' /tmp/$$.rpmnew >$ZM_CONFIG
				fi
			done
			rm /tmp/$$ 
			RETVAL=$?
			[ $RETVAL = 0 ] && echo_success
			[ $RETVAL != 0 ] && echo_failure
			echo
		else
			echo "In $ZM_CONFIG there should not be null values."
			return 1
		fi
	loadconf
	fi
}

checkdb()
{
	# Check database exisits and version
	GetVer="select Value from Config where Name='ZM_DYN_DB_VERSION'"
	OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
	if [ "$OLD_VERSION" = "" ]; then
		GetVer="select Value from Config where Name='ZM_DYN_CURR_VERSION'"
		OLD_VERSION=`echo $GetVer | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
		if [ "$OLD_VERSION" = "" ]; then
			echo -n "You must run zmupdate.pl manualy"
			return 1
		fi	
	fi
	RETVAL=$?
	
	if [ $RETVAL != 0 ]; then
		tbls=`mysql -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS -s -e 'show tables' $ZM_DB_NAME`
		RETVAL=$?
		if [ $RETVAL = 0 ]; then
			echo -n "Initialize $prog database: "
			echo tbls | grep Config >/dev/null 2>&1
			RETVAL=$?
			if [ $RETVAL != 0 ]; then
				mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME < $ZM_PATH_UPDATE/zm_create.sql 
				RETVAL=$?
				[ $RETVAL = 0 ] && echo_success
				[ $RETVAL != 0 ] && echo_failure
				echo
				return $RETVAL
			fi
			( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
			RETVAL=$?
			[ $RETVAL = 0 ] && echo_success
			[ $RETVAL != 0 ] && echo_failure
			echo
			return $RETVAL
		else
			echo "No access to ZoneMinder database. Run $ZM_PATH_BIN/zminit manually."
			return $RETVAL
		fi
	else
		[ "$ZM_VERSION" = "$OLD_VERSION" ] && return 0
		echo -n "Upgrade $prog database: "
		$ZM_PATH_BIN/zmupdate.pl --version=$OLD_VERSION --noi && ( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
		RETVAL=$?
		[ $RETVAL = 0 ] && echo_success
		[ $RETVAL != 0 ] && echo_failure
		echo
		return $RETVAL
	fi
}

start()
{
	loadconf || return $?
	checkcfg || return $?
	checkdb || return $?
	#/usr/local/sbin/motd.sh > /etc/motd
	echo -n "Starting $prog: "
	[ ! -d /var/run/zm ] \
		&& mkdir -m 774 /var/run/zm \
		&& chown $ZM_WEB_USER:$ZM_WEB_GROUP /var/run/zm
	GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
	ZM_PATH_SOCK=`echo $GetPath | mysql -B -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
	[ ! -d $ZM_PATH_SOCK ] \
		&& mkdir -m 774 $ZM_PATH_SOCK \
		&&chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
	$command start
	RETVAL=$?
	[ $RETVAL = 0 ] && echo success
	[ $RETVAL != 0 ] && echo failure
	echo
	[ $RETVAL = 0 ] && touch /var/lock/zm
	return $RETVAL
}

stop()
{
	echo -n $"Stopping $prog: "
	$command stop
	RETVAL=$?
	[ $RETVAL = 0 ] && echo success
	[ $RETVAL != 0 ] && echo failure
	echo
	[ $RETVAL = 0 ] && rm -f /var/lock/zm
}

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
		;;
	'condrestart')
		loadconf
		checkcfg
		result=`$ZM_PATH_BIN/zmdc.pl check`
		if [ "$result" = "running" ]; then
			$ZM_PATH_BIN/zmdc.pl shutdown > /dev/null
			start
		fi
		;;
	'status')
		status
		;;
	*)
		echo "Usage: $0 { start | stop | restart | condrestart | status }"
		RETVAL=1
		;;
esac
exit $RETVAL

Make the ZoneMinder startup executable, make it run at all default levels, and then start it up:

sudo chmod +x /etc/init.d/zm
sudo update-rc.d zm defaults 
sudo /etc/init.d/zm restart

Install Cambozola

This installs the java based streamer:

cd /usr/local/src
sudo wget http://www.charliemouse.com/code/cambozola/cambozola-latest.tar.gz
sudo tar xvfz cambozola-latest.tar.gz
sudo cp /usr/local/src/cambozola-0.68/dist/cambozola.jar /var/www/zm
sudo chmod 775 /var/www/zm/cambozola.jar

At this point, you need to enable the option ZM_OPT_CAMBOZOLA in ZoneMinder.

 ©2006 Triornis Ltd News •  Documentation •  Screenshots •  Downloads •  Support •  Forums •  Wiki •  Shop •  Search •  Donate •  Home