summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pcr/zoneminder/Controls_Orbit.sql3
-rw-r--r--pcr/zoneminder/PKGBUILD114
-rw-r--r--pcr/zoneminder/arm-context.patch18
-rwxr-xr-xpcr/zoneminder/customdb31
-rw-r--r--pcr/zoneminder/httpd-zm.conf18
-rw-r--r--pcr/zoneminder/patch-ffmpeg-0.11.patch60
-rw-r--r--pcr/zoneminder/patch-libavcodec-detection.patch11
-rw-r--r--pcr/zoneminder/zm.rc.d172
-rwxr-xr-xpcr/zoneminder/zmeventbackup48
-rw-r--r--pcr/zoneminder/zminit.arch143
-rw-r--r--pcr/zoneminder/zoneminder-1.25.0-kernel35.patch21
-rw-r--r--pcr/zoneminder/zoneminder.install57
12 files changed, 696 insertions, 0 deletions
diff --git a/pcr/zoneminder/Controls_Orbit.sql b/pcr/zoneminder/Controls_Orbit.sql
new file mode 100644
index 000000000..23224e4aa
--- /dev/null
+++ b/pcr/zoneminder/Controls_Orbit.sql
@@ -0,0 +1,3 @@
+
+INSERT INTO `Controls` VALUES (7,'Orbit','Remote','mjpgStreamer',0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,1,1,-7000,7000,200,200,1,100,100,0,0,1,-2000,2000,10,100,1,200,200,0,0,0,0);
+
diff --git a/pcr/zoneminder/PKGBUILD b/pcr/zoneminder/PKGBUILD
new file mode 100644
index 000000000..38e8732d6
--- /dev/null
+++ b/pcr/zoneminder/PKGBUILD
@@ -0,0 +1,114 @@
+# Maintainer: Vojtech Aschenbrenner <v@asch.cz>
+# Contributor: Jason Gardner <buhrietoe@gmail.com>
+# Contributor: Ross melin <rdmelin@gmail.com>
+
+pkgname=zoneminder
+pkgver=1.25.0
+pkgrel=13
+pkgdesc="Capture, analyse, record and monitor video security cameras."
+arch=('i686' 'x86_64' 'arm')
+url="http://www.zoneminder.com"
+license=('GPL')
+depends=('cambozola' 'apache' 'php' 'php-gd' 'php-mcrypt' 'mysql' 'pcre' 'openssl' 'ffmpeg' 'perl-libwww' 'perl-date-manip' 'perl-unicode-map' 'perl-dbi' 'perl-dbd-mysql' 'perl-io-stringy' 'perl-mime-lite' 'perl-timedate' 'perl-x10' 'perl-time-modules' 'perl-net-smtp-ssl' 'perl-sys-mmap' 'perl-net-sftp-foreign' 'perl-mime-tools' 'perl-io-tty' 'sudo' 'libv4l' 'libjpeg' 'gnutls' 'php-apache')
+makedepends=()
+install=zoneminder.install
+source=("http://www.zoneminder.com/downloads/ZoneMinder-${pkgver}.tar.gz"
+ zm.rc.d
+ Controls_Orbit.sql
+ zminit.arch
+ customdb
+ httpd-zm.conf
+ zmeventbackup
+ patch-ffmpeg-0.11.patch
+ patch-libavcodec-detection.patch
+ zoneminder-1.25.0-kernel35.patch
+ arm-context.patch)
+
+md5sums=('eaefa14befd482154970541252aa1a39'
+ '9fb81f81b056c18be6eef3f1c8e0dd6d'
+ '5033bc098bf497c8aed1fc1b3c9c5f9c'
+ 'f9720872736f26d17bc49d8725b75ae4'
+ '942f6641c744ffe7d64846a5c34d84f1'
+ 'e63262d1417105ae24c7a03d98b2c64c'
+ '1a6d7c43af79c786b27cc88f7ba7ed3e'
+ 'b872dd86926ab00c5d4733e7e38eaa9c'
+ '94bf5d95fe5429f7df458ddfbabf0c12'
+ '88bd124dfb841320cecb0a757b2a78c1'
+ 'b28c8eb392a7e7b6ef665817d7fe61f4')
+
+build() {
+ cd "$srcdir/ZoneMinder-$pkgver"
+
+ # Patch for GCC 4.7.x
+ sed -i -e '1 s/^/#include <unistd.h>\n/;' src/zm_logger.cpp
+ sed -i -e '1 s/^/#include <unistd.h>\n/;' src/zm_thread.h
+
+ # Patch for build/upgrade path
+ sed -i -e 's#ZM_PATH_BUILD=@PATH_BUILD@#ZM_PATH_BUILD=/srv/zoneminder/upgrade\nZM_PATH_UPDATE=/srv/zoneminder/upgrade#' zm.conf.in
+
+ # Patch for support new ffmpeg
+ patch -p1 < ../patch-ffmpeg-0.11.patch
+
+ # Patch for correct libavcodec detection
+ patch -p0 < ../patch-libavcodec-detection.patch
+
+ # Patch for type cast in kernel3.5
+ patch -p0 < ../zoneminder-1.25.0-kernel35.patch
+
+ # Patch for ARM
+ if test "$CARCH" == arm; then
+ patch -p0 < ../arm-context.patch
+ fi
+
+ # Add some more configs into DB
+ cat ../Controls_Orbit.sql >> db/zm_create.sql.in
+
+ ./configure --prefix=/usr \
+ --sysconfdir=/etc \
+ --with-webuser=http \
+ --with-webgroup=http \
+ --with-mysql=/usr \
+ --with-webdir=/srv/zoneminder/www \
+ --with-cgidir=/srv/zoneminder/cgi-bin \
+ --bindir=/srv/zoneminder/bin \
+ ZM_SSL_LIB=openssl \
+ CPPFLAGS=-D__STDC_CONSTANT_MACROS
+
+ # chown line mucks everything up, we'll chown it in the install script
+ sed -i '/chown/d' Makefile
+
+ # modify hard-coded paths
+ sed -i 's#/var/lib/zm#/srv/zoneminder/backup#' scripts/zmdbrestore.in
+ sed -i 's#/var/lib/zm#/srv/zoneminder/backup#' scripts/zmlogrotate.conf.in
+ sed -i 's#/var/lib/zm#/srv/zoneminder/backup#' scripts/zmdbbackup.in
+
+ # Build it!
+ make || return 1
+ make DESTDIR="$pkgdir" install || return 1
+
+ install -D -m 700 $startdir/src/zminit.arch $startdir/pkg/srv/zoneminder/bin/zminit
+ install -D -m 755 $startdir/src/zm.rc.d $startdir/pkg/etc/rc.d/zm
+ install -D -m 700 scripts/zmdbbackup $startdir/pkg/srv/zoneminder/bin/zmdbbackup
+ install -D -m 700 scripts/zmdbbackup $startdir/pkg/srv/zoneminder/bin/zmdbbackup
+ install -D -m 700 scripts/zmdbrestore $startdir/pkg/srv/zoneminder/bin/zmdbrestore
+ install -D -m 700 scripts/zmeventdump $startdir/pkg/srv/zoneminder/bin/zmeventdump
+ install -D -m 700 scripts/zmlogrotate.conf $startdir/pkg/etc/logrotate.d/zm
+ install -D -m 700 $startdir/src/zmeventbackup $startdir/pkg/etc/cron.hourly/zmeventbackup
+
+ mkdir -p $startdir/pkg/etc/httpd/conf/extra/
+ install -m 644 $startdir/src/httpd-zm.conf $startdir/pkg/etc/httpd/conf/extra/httpd-zm.conf
+
+ install -D -m 700 $startdir/src/customdb $startdir/pkg/srv/zoneminder/upgrade/customdb
+ install -D db/zm*.sql $startdir/pkg/srv/zoneminder/upgrade/
+
+ mkdir -p $startdir/pkg/var/run/zm
+
+ ### remove special files
+ find $startdir/pkg/ -name "perllocal.pod" \
+ -o -name ".packlist" \
+ -o -name "*.bs" \
+ |xargs -i rm -f {}
+
+}
+
+# vim:set ft=sh ts=2 sw=2 et:
diff --git a/pcr/zoneminder/arm-context.patch b/pcr/zoneminder/arm-context.patch
new file mode 100644
index 000000000..a6fbb5328
--- /dev/null
+++ b/pcr/zoneminder/arm-context.patch
@@ -0,0 +1,18 @@
+--- src/zm_signal.cpp.orig 2012-08-30 13:24:16.479872021 -0700
++++ src/zm_signal.cpp 2012-08-30 13:27:35.909871996 -0700
+@@ -82,13 +82,13 @@
+ int trace_size = 0;
+
+ #if HAVE_STRUCT_SIGCONTEXT_EIP
+- Error( "Signal address is %p, from %p", (void *)context.cr2, (void *)context.eip );
++ Error( "Signal address is %p, from %p", (void *)context.fault_address, (void *)context.eip );
+
+ trace_size = backtrace( trace, TRACE_SIZE );
+ // overwrite sigaction with caller's address
+ trace[1] = (void *)context.eip;
+ #elif HAVE_STRUCT_SIGCONTEXT
+- Error( "Signal address is %p, no eip", (void *)context.cr2 );
++ Error( "Signal address is %p, no eip", (void *)context.fault_address );
+
+ trace_size = backtrace( trace, TRACE_SIZE );
+ #else // HAVE_STRUCT_SIGCONTEXT
diff --git a/pcr/zoneminder/customdb b/pcr/zoneminder/customdb
new file mode 100755
index 000000000..afd295935
--- /dev/null
+++ b/pcr/zoneminder/customdb
@@ -0,0 +1,31 @@
+#!/bin/sh
+DBHOST=$1
+DBNAME=$2
+USERNAME=$3
+PASSWORD=$4
+
+ZM_PATH_ZMS=/cgi-bin/nph-zms
+ZM_PATH_SOCKS=/srv/zoneminder/socks
+ZM_PATH_LOGS=/var/log/zm
+ZM_WEB_LIST_THUMBS=1
+ZM_WEB_MONTAGE_WIDTH=320
+ZM_WEB_MONTAGE_HEIGHT=240
+ZM_OPT_CAMBOZOLA=1
+ZM_OPT_MPEG=ffmpeg
+ZM_PATH_FFMPEG=/usr/bin/ffmpeg
+ZM_OPT_NETPBM=1
+ZM_EXTRA_DEBUG_LOG=/var/log/zm/zm_debug.log
+ZM_OPT_USE_AUTH=0
+
+sql=/tmp/$$
+echo "" >$sql
+for n in ZM_PATH_ZMS ZM_PATH_SOCKS ZM_PATH_LOGS ZM_WEB_LIST_THUMBS ZM_WEB_MONTAGE_WIDTH ZM_WEB_MONTAGE_HEIGHT ZM_OPT_CAMBOZOLA ZM_OPT_MPEG ZM_PATH_FFMPEG ZM_OPT_NETPBM ZM_EXTRA_DEBUG_LOG ZM_OPT_USE_AUTH; do
+ eval "val=\$$n"
+ echo "UPDATE Config SET Value='$val' WHERE Name='$n';" >>$sql
+done
+
+cat $sql | mysql --user=$USERNAME --password=$PASSWORD --host=$DBHOST $DBNAME
+rm -f $sql
+
+
+exit 0
diff --git a/pcr/zoneminder/httpd-zm.conf b/pcr/zoneminder/httpd-zm.conf
new file mode 100644
index 000000000..ad24cbbe4
--- /dev/null
+++ b/pcr/zoneminder/httpd-zm.conf
@@ -0,0 +1,18 @@
+# /etc/httpd/conf/extra/httpd-zm.conf
+# Config for zoneminder web app
+
+Alias /zm "/srv/zoneminder/www"
+<Directory "/srv/zoneminder/www">
+ Options -Indexes MultiViews FollowSymLinks
+ AllowOverride All
+ Order allow,deny
+ Allow from all
+</Directory>
+
+ScriptAlias /cgi-bin "/srv/zoneminder/cgi-bin"
+<Directory "/srv/zoneminder/cgi-bin">
+ AllowOverride All
+ Options ExecCGI
+ Order allow,deny
+ Allow from all
+</Directory>
diff --git a/pcr/zoneminder/patch-ffmpeg-0.11.patch b/pcr/zoneminder/patch-ffmpeg-0.11.patch
new file mode 100644
index 000000000..8356fff83
--- /dev/null
+++ b/pcr/zoneminder/patch-ffmpeg-0.11.patch
@@ -0,0 +1,60 @@
+diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp
+index 42927f6..61df606 100644
+--- a/src/zm_ffmpeg_camera.cpp
++++ b/src/zm_ffmpeg_camera.cpp
+@@ -108,7 +108,7 @@ int FfmpegCamera::PrimeCapture()
+ Info( "Priming capture from %s", mPath.c_str() );
+
+ // Open the input, not necessarily a file
+- if ( av_open_input_file( &mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 )
++ if ( avformat_open_input( &mFormatContext, mPath.c_str(), NULL, NULL ) !=0 )
+ Fatal( "Unable to open input %s due to: %s", mPath.c_str(), strerror(errno) );
+
+ // Locate stream info from input
+@@ -139,7 +139,7 @@ int FfmpegCamera::PrimeCapture()
+ Fatal( "Can't find codec for video stream from %s", mPath.c_str() );
+
+ // Open the codec
+- if ( avcodec_open( mCodecContext, mCodec ) < 0 )
++ if ( avcodec_open2( mCodecContext, mCodec, NULL ) < 0 )
+ Fatal( "Unable to open codec for video stream from %s", mPath.c_str() );
+
+ // Allocate space for the native video frame
+
+diff --git a/src/zm_mpeg.cpp b/src/zm_mpeg.cpp
+index f5de2a4..d614346 100644
+--- a/src/zm_mpeg.cpp
++++ b/src/zm_mpeg.cpp
+@@ -167,10 +167,12 @@ void VideoStream::SetParameters()
+ {
+ /* set the output parameters (must be done even if no
+ parameters). */
+- if ( av_set_parameters(ofc, NULL) < 0 )
++ /*
++ * Removed in last ffmpeg
++ * if ( av_set_parameters(ofc, NULL) < 0 )
+ {
+ Panic( "Invalid output format parameters" );
+- }
++ }*/
+ //dump_format(ofc, 0, filename, 1);
+ }
+
+@@ -259,7 +261,7 @@ void VideoStream::OpenStream()
+ if ( !(of->flags & AVFMT_NOFILE) )
+ {
+ #if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,2,1)
+- if ( avio_open(&ofc->pb, filename, URL_WRONLY) < 0 )
++ if ( avio_open(&ofc->pb, filename, AVIO_FLAG_WRITE) < 0 )
+ #else
+ if ( url_fopen(&ofc->pb, filename, URL_WRONLY) < 0 )
+ #endif
+@@ -278,7 +280,7 @@ void VideoStream::OpenStream()
+ }
+
+ /* write the stream header, if any */
+- av_write_header(ofc);
++ avformat_write_header(ofc, NULL);
+ }
+
+ VideoStream::VideoStream( const char *filename, const char *format, int bitrate, double frame_rate, int colours, int subpixelorder, int width, int height ) \ No newline at end of file
diff --git a/pcr/zoneminder/patch-libavcodec-detection.patch b/pcr/zoneminder/patch-libavcodec-detection.patch
new file mode 100644
index 000000000..0aaa9bc23
--- /dev/null
+++ b/pcr/zoneminder/patch-libavcodec-detection.patch
@@ -0,0 +1,11 @@
+--- configure.ac~ 2012-07-15 22:27:11.195257379 +0100
++++ configure.ac 2012-07-15 22:24:34.308268675 +0100
+@@ -276,7 +276,7 @@
+ AC_CHECK_LIB(avutil,av_malloc,,AC_MSG_WARN(libavutil.a may be required for MPEG streaming))
+ # Don't bother to warn about this one
+ AC_CHECK_LIB(avcore,av_image_copy,,)
+-AC_CHECK_LIB(avcodec,avcodec_init,,AC_MSG_WARN(libavcodec.a is required for MPEG streaming))
++AC_CHECK_LIB(avcodec,avcodec_open,,AC_MSG_WARN(libavcodec.a is required for MPEG streaming))
+ AC_CHECK_LIB(avformat,av_new_stream,,AC_MSG_WARN(libavformat.a is required for MPEG streaming))
+ AC_CHECK_LIB(avdevice,avdevice_register_all,,AC_MSG_WARN(libavdevice.a may be required for MPEG streaming))
+ AC_CHECK_LIB(swscale,sws_scale,,,-lswscale) \ No newline at end of file
diff --git a/pcr/zoneminder/zm.rc.d b/pcr/zoneminder/zm.rc.d
new file mode 100644
index 000000000..99a1f1f22
--- /dev/null
+++ b/pcr/zoneminder/zm.rc.d
@@ -0,0 +1,172 @@
+#!/bin/bash
+
+# Source function library.
+. /etc/rc.conf
+. /etc/rc.d/functions
+
+prog=ZoneMinder
+ZM_VERSION="1.25.0"
+ZM_PATH_BIN="/srv/zoneminder/bin"
+ZM_CONFIG="/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
+ echo "In $ZM_CONFIG there should not be null values.
+"
+ return 1
+ 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 "You must run $ZM_PATH_BIN/zminit manually
+"
+ 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 "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 ] && stat_done
+ [ $RETVAL != 0 ] && stat_fail
+ echo
+ return $RETVAL
+ fi
+ ( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
+ RETVAL=$?
+ [ $RETVAL = 0 ] && stat_done
+ [ $RETVAL != 0 ] && stat_fail
+ 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 "Upgrade %s database: " "$prog"
+ $ZM_PATH_BIN/zmupdate.pl --version=$OLD_VERSION --noi && ( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
+ RETVAL=$?
+ [ $RETVAL = 0 ] && stat_done
+ [ $RETVAL != 0 ] && stat_fail
+ echo
+ return $RETVAL
+ fi
+}
+
+start()
+{
+ loadconf || return $?
+ checkcfg || return $?
+ checkdb || return $?
+ stat_busy "Starting $prog"
+ [ -d /var/run/zm ] || mkdir -m 774 /var/run/zm
+ chown -R $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 -p $ZM_PATH_SOCK
+ sudo -u $ZM_WEB_USER test -O $ZM_PATH_SOCK \
+ || chown -R $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
+ # Setup the log dir
+ [ -d /var/log/zm ] || mkdir /var/log/zm
+ for logs in zmaudit.log zmdc.log zmfilter.log zmpkg.log zmupdate.log zmwatch.log; do
+ touch /var/log/zm/$logs
+ done
+ chown -R $ZM_WEB_USER:$ZM_WEB_GROUP /var/log/zm
+ $command start
+ RETVAL=$?
+ [ $RETVAL = 0 ] && stat_done && add_daemon zm
+ [ $RETVAL != 0 ] && stat_fail
+ #[ $RETVAL = 0 ] && touch /var/lock/subsys/zm
+ return $RETVAL
+}
+
+stop()
+{
+ stat_busy "Stopping $prog"
+ $command stop
+ RETVAL=$?
+ [ $RETVAL = 0 ] && stat_done && rm_daemon zm
+ [ $RETVAL != 0 ] && stat_fail
+ #[ $RETVAL = 0 ] && rm -f /var/lock/subsys/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: zm { start | stop | restart | condrestart | status }
+"
+ RETVAL=1
+ ;;
+esac
+exit $RETVAL
diff --git a/pcr/zoneminder/zmeventbackup b/pcr/zoneminder/zmeventbackup
new file mode 100755
index 000000000..a14ee22a1
--- /dev/null
+++ b/pcr/zoneminder/zmeventbackup
@@ -0,0 +1,48 @@
+#!/bin/bash
+#===============================================================================
+#
+# FILE: eventdump.sh
+#
+# USAGE: ./eventdump.sh
+#
+# DESCRIPTION: Uses mysqldump to create a .sql file for individual zm
+# events to make Event table recovery possible by doing a
+# 'find' search in ZoneMinder the events directory
+#
+# OPTIONS: ---
+# REQUIREMENTS: --- mysqldump
+# BUGS: ---
+# NOTES: ---
+# AUTHOR: Ross Melin <rdmelin@gmail.com>
+# COMPANY:
+# VERSION: 1.0
+# CREATED: 03/06/2008 11:51:19 AM PST
+# REVISION: ---
+#===============================================================================
+
+# Edit these to suit your configuration
+ZM_CONFIG=/etc/zm.conf
+MYSQLDUMP=/usr/bin/mysqldump
+EVENTSDIR=/srv/zoneminder/www/events
+
+# The rest should not need editing
+
+# Get the mysql user and password
+source $ZM_CONFIG
+MYDUMPOPTS="--user=$ZM_DB_USER --password=$ZM_DB_PASS --skip-opt --compact --quick --no-create-info"
+
+
+for tag in $(find $EVENTSDIR -amin -65 -name ".[0-9]*")
+ do
+ EVENT_PATH=$(echo $tag |cut -f 1 -d .)
+ EVENT_ID=$(echo $tag |cut -f 2 -d .)
+ # Dump the sql statements needed to reload the Events, Frames and Stats tables
+
+ echo "-- ZM_DB_VERSION=$ZM_VERSION
+" > $EVENT_PATH.sql
+
+ $MYSQLDUMP $MYDUMPOPTS --where="Id=$EVENT_ID" zm Events >> $EVENT_PATH.sql
+ $MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Frames >> $EVENT_PATH.sql
+ $MYSQLDUMP $MYDUMPOPTS --where="Eventid=$EVENT_ID" zm Stats >> $EVENT_PATH.sql
+
+done
diff --git a/pcr/zoneminder/zminit.arch b/pcr/zoneminder/zminit.arch
new file mode 100644
index 000000000..01b6658a7
--- /dev/null
+++ b/pcr/zoneminder/zminit.arch
@@ -0,0 +1,143 @@
+#!/bin/sh
+
+
+ZM_CONFIG=/etc/zm.conf
+
+
+
+loadcfg() {
+ if [ -f $ZM_CONFIG ]; then
+ . $ZM_CONFIG
+ else
+ echo "ERROR: $ZM_CONFIG not found."
+ exit 1
+ fi
+ }
+chkmysql(){
+ #FIXME
+ /etc/rc.d/mysqld restart || (echo "mysql is not availible" && exit 1 )
+ }
+
+getmylogin(){
+ echo "Enter MySQL Administrator username"
+ echo "(Default: root and password is blank)"
+ echo -n "MySQL Admin: "
+ read MYADMIN
+ echo -n "Password: "
+ read MYPASS
+ if [ "X$MYPASS" != "X" ]; then MYPASS="-p$MYPASS"; fi
+ echo "\q" |mysql -u $MYADMIN $MYPASS || exit 0
+
+ }
+
+checkdb()
+{
+ # Check database exisits and version
+ exists=$(echo "show databases" |mysql -u $MYADMIN "$MYPASS" |grep zm)
+ if [ "$exists" = "zm" ]; then
+ OLD_VERSION=$(echo "select Value from Config where Name = 'ZM_DYN_DB_VERSION';" | mysql -u $MYADMIN $MYPASS zm |grep -v '^Value')
+
+ case $OLD_VERSION in
+ "")
+ echo "A zm database exists, but the version is unknown"
+ echo "Updating is unlikely to succeed"
+ ;;
+ "$ZM_VERSION")
+ echo "The zm database appears to be up to date"
+ echo "If this is incorrect, edit $ZM_CONFIG to reflect the current version"
+ ;;
+ *)
+ echo "A database fron zm-$OLD_VERSION exists already"
+ ;;
+ esac
+
+ while [ true ]
+ do
+ echo "Choose one of the following options:"
+ echo "[U]pdate the database"
+ echo "[D]rop the old database and reinitialize"
+ echo "[E]xit and do nothing"
+ read OPTION
+ case $OPTION in
+ "U"|"u")
+ /etc/rc.d/zm restart
+ exit 0
+ ;;
+ "D"|"d")
+ echo "drop database zm;"|mysql -u $MYADMIN $MYPASS
+ return
+ ;;
+ "E"|"e")
+ exit 0
+ ;;
+ esac
+ done
+ fi
+}
+
+checkcfg(){
+for n in ZM_DB_HOST ZM_DB_NAME ZM_DB_USER ZM_DB_PASS; do
+ eval "val=\$$n"
+ if [ "$val" = "" ]; then
+ echo "ERROR($ZM_CONFIG): $n should not be empty."
+ echo "Enter a $n for ZM to use the Database."
+ if [ "$n" = "ZM_DB_PASS" ]; then
+ echo -n "Will not echo on screen $n : "
+ stty -echo # Turns off screen echo.
+ read newval
+ stty echo # Restores screen echo.
+ echo ""
+ ### The following can be used to generate a random password
+ # randstr newval 16
+ else
+ echo -n "$n : "
+ read newval
+ fi
+ cp $ZM_CONFIG /tmp/$$ &&
+ sed 's/^'$n='.*$/'$n=$newval'/g' /tmp/$$ >$ZM_CONFIG
+
+ fi
+done
+
+if [ "$ZM_DB_HOST" = "localhost" ]; then
+ ClientHost=localhost
+else
+ ClientHost=`hostname`
+fi
+}
+
+reloadcfg(){
+loadcfg
+}
+
+initdb(){
+sql=/tmp/zm.crdb.sql
+echo "" >$sql
+chmod 600 $sql
+
+echo "CREATE DATABASE $ZM_DB_NAME;" >>$sql
+echo "USE $ZM_DB_NAME;" >>$sql
+
+echo "GRANT all on $ZM_DB_NAME.* TO '$ZM_DB_USER'@'$ClientHost' IDENTIFIED BY '$ZM_DB_PASS';" >>$sql
+
+cat $sql | mysql -B -h $ZM_DB_HOST -u $MYADMIN $MYPASS
+rm -f $sql
+
+cat $ZM_PATH_UPDATE/zm_create.sql | mysql -h $ZM_DB_HOST -u $ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME
+( cd $ZM_PATH_UPDATE; perl $ZM_PATH_BIN/zmupdate.pl -f )
+
+ $ZM_PATH_UPDATE/customdb $ZM_DB_HOST $ZM_DB_NAME $ZM_DB_USER $ZM_DB_PASS
+}
+
+
+
+loadcfg
+getmylogin
+checkdb
+checkcfg
+reloadcfg
+initdb
+
+
+
+
diff --git a/pcr/zoneminder/zoneminder-1.25.0-kernel35.patch b/pcr/zoneminder/zoneminder-1.25.0-kernel35.patch
new file mode 100644
index 000000000..51bc1288d
--- /dev/null
+++ b/pcr/zoneminder/zoneminder-1.25.0-kernel35.patch
@@ -0,0 +1,21 @@
+diff -up ./src/zm_local_camera.cpp.kernel35 ./src/zm_local_camera.cpp
+--- ./src/zm_local_camera.cpp.kernel35 2012-07-16 15:01:22.182614878 -0500
++++ ./src/zm_local_camera.cpp 2012-07-16 15:02:16.491941730 -0500
+@@ -740,7 +740,7 @@ void LocalCamera::Terminate()
+ {
+ Debug( 3, "Terminating video stream" );
+ //enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+- enum v4l2_buf_type type = v4l2_data.fmt.type;
++ enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type;
+ if ( vidioctl( vid_fd, VIDIOC_STREAMOFF, &type ) < 0 )
+ Error( "Failed to stop capture stream: %s", strerror(errno) );
+
+@@ -1520,7 +1520,7 @@ int LocalCamera::PrimeCapture()
+
+ Debug( 3, "Starting video stream" );
+ //enum v4l2_buf_type type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+- enum v4l2_buf_type type = v4l2_data.fmt.type;
++ enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type;
+ if ( vidioctl( vid_fd, VIDIOC_STREAMON, &type ) < 0 )
+ Fatal( "Failed to start capture stream: %s", strerror(errno) );
+ }
diff --git a/pcr/zoneminder/zoneminder.install b/pcr/zoneminder/zoneminder.install
new file mode 100644
index 000000000..be449a5ca
--- /dev/null
+++ b/pcr/zoneminder/zoneminder.install
@@ -0,0 +1,57 @@
+# zoneminder.install
+
+## arg 1: the new package version
+post_install() {
+ ln -s /usr/share/cambozola/cambozola.jar /srv/zoneminder/www/
+ chown -R http.http /srv/zoneminder
+ chown http.http /etc/zm.conf
+ mkdir /srv/zoneminder/backup
+ mkdir /srv/zoneminder/socks
+ cat << EOF
+Note:
+==> To initialize the ZoneMinder database run (as root)
+==> /srv/zoneminder/bin/zminit
+EOF
+
+ cat << EOF
+==> Check /etc/php/php.ini and make sure these are uncommented
+==> extension=gd.so
+==> extension=gettext.so
+==> extension=mcrypt.so
+==> extension=mysql.so
+==> extension=mysqli.so
+==> extension=session.so
+==> extension=sockets.so
+EOF
+ cat << EOF
+==> Check /etc/php/php.ini and make sure short_open_tag = On
+EOF
+
+
+ cat /etc/php/php.ini |grep "^open_basedir.*/etc/" | \
+grep "/srv/zoneminder/www">/dev/null || cat << EOF
+==> You must edit /etc/php/php.ini and add to open_basedir "/etc/" and
+==> "/srv/zoneminder/" like so
+==> open_basedir = /home/:/tmp/:/usr/share/pear/:/etc/:/srv/zoneminder/
+==> Otherwise ZoneMinder will be unable to read /etc/zm.conf
+==> or display its own web directory
+EOF
+
+ cat << EOF
+Note:
+==> You must edit /etc/httpd/conf/httpd.conf and uncomment/add the line
+==> LoadModule php5_module modules/libphp5.so
+==> You must also add these lines:
+==> Include conf/extra/php5_module.conf
+==> Include /etc/httpd/conf/extra/httpd-zm.conf
+EOF
+ touch /srv/zoneminder/zm_backup.sql
+}
+
+
+## arg 1: the new package version
+## arg 2: the old package version
+post_upgrade() {
+ /srv/zoneminder/bin/zmupdate.pl -f >/dev/null
+}
+# vim:set ts=2 sw=2 et: