diff options
Diffstat (limited to 'pcr/zoneminder')
-rw-r--r-- | pcr/zoneminder/Controls_Orbit.sql | 3 | ||||
-rw-r--r-- | pcr/zoneminder/PKGBUILD | 139 | ||||
-rw-r--r-- | pcr/zoneminder/arm-context.patch | 18 | ||||
-rwxr-xr-x | pcr/zoneminder/customdb | 31 | ||||
-rw-r--r-- | pcr/zoneminder/httpd-zm.conf | 20 | ||||
-rw-r--r-- | pcr/zoneminder/patch-ffmpeg-0.11.patch | 60 | ||||
-rw-r--r-- | pcr/zoneminder/patch-ffmpeg-configure.patch | 26 | ||||
-rw-r--r-- | pcr/zoneminder/patch-libavcodec-detection.patch | 11 | ||||
-rw-r--r-- | pcr/zoneminder/zm.rc.d | 63 | ||||
-rw-r--r-- | pcr/zoneminder/zm.service | 9 | ||||
-rwxr-xr-x | pcr/zoneminder/zmeventbackup | 48 | ||||
-rw-r--r-- | pcr/zoneminder/zminit.arch | 143 | ||||
-rw-r--r-- | pcr/zoneminder/zoneminder-1.25.0-kernel35.patch | 21 | ||||
-rw-r--r-- | pcr/zoneminder/zoneminder.install | 97 | ||||
-rw-r--r-- | pcr/zoneminder/zoneminder.service | 14 |
15 files changed, 703 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..bb850eec2 --- /dev/null +++ b/pcr/zoneminder/PKGBUILD @@ -0,0 +1,139 @@ +# Maintainer: Vojtech Aschenbrenner <v@asch.cz> +# Contributor: Jason Gardner <buhrietoe@gmail.com> +# Contributor: Ross melin <rdmelin@gmail.com> +# Maintainer (Parabola): Márcio Silva <coadde@lavabit.com> +# Contributor (Parabola): André Silva <emulatorman@lavabit.com> + +# based of debian squeeze package + +pkgname=zoneminder +pkgver=1.25.0 +pkgrel=17 +pkgdesc='Capture, analyse, record and monitor video security cameras' +arch=(i686 x86_64 mips64el) +backup=(etc/zm.conf etc/httpd/conf/extra/httpd-zm.conf) +url=http://www.$pkgname.com +license=(GPL) +depends=( + apache cambozola ffmpeg-static gnutls mysql perl-archive-zip perl-date-manip + perl-dbd-mysql perl-dbi perl-expect perl-libwww perl-mime-lite + perl-mime-tools perl-php-serialization perl-net-sftp-foreign perl-sys-mmap + perl-time-modules perl-x10 php php-apache php-gd php-mcrypt +) +makedepends=(netpbm) +install=$pkgname.install +source=( + http://www.$pkgname.com/downloads/ZoneMinder-$pkgver.tar.gz + httpd-zm.conf + zm.rc.d + $pkgname.service + patch-ffmpeg-0.11.patch +) +md5sums=( + eaefa14befd482154970541252aa1a39 + 25ad042b501aaad98cbe4e05ca0a96c2 + 034b61cda8849fc3001849e76ef26041 + 7487cc72ead82aea0bc78f2e4106ae1a + 81c8be870260142e2633eedf73c72040 +) +build() { + cd $srcdir/ZoneMinder-$pkgver + + export CPPFLAGS=-D__STDC_CONSTANT_MACROS \ + ZM_SSL_LIB=gnutls + + # Patch for GCC 4.7.x + sed -i -e 's/^#include <errno.h>/#include <errno.h>\n#include <unistd.h>/' src/zm_logger.cpp + sed -i -e 's/^#include <pthread.h>/#include <pthread.h>\n#include <unistd.h>/' src/zm_thread.h + + # Patch for disable ZM_CHECK_FOR_UPDATES + sed -i -e '/ZM_CHECK_FOR_UPDATES/,+1 s/yes/no/' scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in + + # Patch for support html5 video and flv + sed -i -e '/ZM_MPEG_LIVE_FORMAT/,+1 s/swf/webm/;/ZM_MPEG_REPLAY_FORMAT/,+1 s/swf/webm/; + /ZM_FFMPEG_FORMATS/,+1 s/mpg mpeg wmv asf avi\* mov swf 3gp\*\*/mpg mpeg wmv asf avi\* mov flv swf 3gp\*\* webm ogg h254/'\ + scripts/ZoneMinder/lib/ZoneMinder/ConfigData.pm.in + + # Patch for wrong "suppported" + sed -i -e 's/suppported/supported/' src/zm_local_camera.cpp + + # Patch for type cast in linux-libre kernel 3.5 + sed -i -e 's/enum v4l2_buf_type type = v4l2_data.fmt.type;/enum v4l2_buf_type type = (v4l2_buf_type)v4l2_data.fmt.type;/'\ + src/zm_local_camera.cpp + + # Patch for drop custom perl install paths + sed -i -e '/# Slight hack for non-standard perl install paths/,+10 d; + s/^AC_SUBST(ZM_CONFIG,"$SYSCONFDIR\/zm.conf")/AC_SUBST(ZM_CONFIG,"$SYSCONFDIR\/zm.conf")\n\nEXTRA_PERL_LIB="# Include from system perl paths only"\nPERL_MM_PARMS="INSTALLDIRS=vendor"/'\ + configure.ac + + # Patch for support new ffmpeg + patch -p1 < $srcdir/patch-ffmpeg-0.11.patch +# sed -i -e 's/if ( av_open_input_file( \&mFormatContext, mPath.c_str(), NULL, 0, NULL ) !=0 )/if ( avformat_open_input( \&mFormatContext, mPath.c_str(), NULL, NULL ) !=0 )/; +# s/if ( avcodec_open( mCodecContext, mCodec ) < 0 )/if ( avcodec_open2( mCodecContext, mCodec, NULL ) < 0 )/'\ +# src/zm_ffmpeg_camera.cpp +# sed -i -e 's/if ( av_set_parameters(ofc, NULL) < 0 )/\/\*\n \* Removed in last ffmpeg\n \* if ( av_set_parameters(ofc, NULL) < 0 )/; +# /Panic( "Invalid output format parameters" );/,+1 s/}/}\*/; +# /if ( avio_open(&ofc->pb, filename, URL_WRONLY) < 0 )/ s/URL_WRONLY/AVIO_FLAG_WRITE/; +# s/av_write_header(ofc);/avformat_write_header(ofc, NULL);/'\ +# src/zm_mpeg.cpp + sed -i -e 's/avcodec_init/avcodec_open/'\ + configure{,.ac} + + # Patch for support ffmpeg with <libavutil/mathematics.h> and C library + sed -i -e 's/^extern "C" {/extern "C" {\n#ifdef _STDINT_H\n#undef _STDINT_H\n#endif\n#include <stdint.h>/ + s/^#include <libavutil\/avutil.h>/#include <libavutil\/avutil.h>\n#include <libavutil\/mathematics.h>/'\ + src/zm_ffmpeg.h + sed -i -e 's/^AM_CONFIG_HEADER(config.h)/AM_CONFIG_HEADER(config.h)\n\nAC_SUBST([AM_CXXFLAGS], [-D__STDC_CONSTANT_MACROS])/; + s/^AC_CHECK_HEADERS(mysql\/mysql.h,,AC_MSG_ERROR(zm requires MySQL headers - check that MySQL development packages are installed),)/AC_CHECK_HEADERS(mysql\/mysql.h,,AC_MSG_ERROR(zm requires MySQL headers - check that MySQL development packages are installed),)\nAC_LANG_PUSH([C])/; + s/^AC_CHECK_HEADERS(libswscale\/swscale.h,,,)/AC_CHECK_HEADERS(libswscale\/swscale.h,,,)\nAC_LANG_POP([C])/'\ + configure.ac + + # Patch for wrong install run, tmp and log dir + sed -i -e '/ install-data-hook/d;/install-data-hook:/d;/# Yes, you are correct. This is a HACK!/d; + / ( cd $(DESTDIR)$(sysconfdir); chown $(webuser):$(webgroup) $(sysconf_DATA); chmod 600 $(sysconf_DATA) )/d; + / ( if ! test -e $(ZM_RUNDIR); then mkdir -p $(ZM_RUNDIR); fi; if test "$(ZM_RUNDIR)" != "\/var\/run"; then chown $(webuser):$(webgroup) $(ZM_RUNDIR); chmod u+w $(ZM_RUNDIR); fi )/d; + / ( if ! test -e $(ZM_TMPDIR); then mkdir -m 700 -p $(ZM_TMPDIR); fi; if test "$(ZM_TMPDIR)" != "\/tmp"; then chown $(webuser):$(webgroup) $(ZM_TMPDIR); chmod u+w $(ZM_TMPDIR); fi )/d; + / ( if ! test -e $(ZM_LOGDIR); then mkdir -p $(ZM_LOGDIR); fi; if test "$(ZM_LOGDIR)" != "\/var\/log"; then chown $(webuser):$(webgroup) $(ZM_LOGDIR); chmod u+w $(ZM_LOGDIR); fi )/,+1 d' \ + Makefile.{am,in} + + ./configure --prefix=/usr \ + --build \ + --enable-crashtrace=no \ + --enable-debug=no \ + --enable-mmap=yes \ + --sysconfdir=/etc \ + --with-cgidir=/usr/lib/$pkgname/cgi-bin \ + --with-ffmpeg=/usr \ + --with-libarch=lib \ + --with-mysql=/usr \ + --with-webdir=/usr/share/$pkgname/www \ + --with-webgroup=http \ + --with-webhost=localhost \ + --with-webuser=http + + make V=0 +} + +package() { + cd $srcdir/ZoneMinder-$pkgver + + make DESTDIR=$pkgdir install + + mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},usr/{lib/{systemd/system,$pkgname/cgi-bin},share/{license/$pkgname,$pkgname/{db,www}}},var/{cache/$pkgname,log/zm}} + + chown -R http.http $pkgdir/{etc/zm.conf,var/{cache/$pkgname,log/zm}} + + for i in events images temp; do + mv $pkgdir/usr/share/$pkgname/www/$i $pkgdir/var/cache/$pkgname/$i + ln -s /var/cache/$pkgname/$i $pkgdir/usr/share/$pkgname/www/$i + done + + ln -s /usr/lib/$pkgname/cgi-bin $pkgdir/usr/share/$pkgname/www + ln -s /usr/share/cambozola/cambozola.jar $pkgdir/usr/share/$pkgname/www + + install -D -m 644 $srcdir/httpd-zm.conf $pkgdir/etc/httpd/conf/extra + install -D -m 644 $srcdir/zm.rc.d $pkgdir/etc/rc.d/zm + install -D -m 644 $srcdir/$pkgname.service $pkgdir/usr/lib/systemd/system + install -D -m 644 COPYING $pkgdir/usr/share/license/$pkgname + install -D -m 644 db/zm*.sql $pkgdir/usr/share/$pkgname/db +} 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..8c6356aec --- /dev/null +++ b/pcr/zoneminder/httpd-zm.conf @@ -0,0 +1,20 @@ +# /etc/httpd/conf/extra/httpd-zm.conf +# Config for zoneminder web app + +Alias /zm "/usr/share/zoneminder/www" +<Directory "/usr/share/zoneminder/www"> + Options -Indexes MultiViews FollowSymLinks + AllowOverride None + Order allow,deny + Allow from all + # The code unfortunately uses short tags in many places + php_value short_open_tag On +</Directory> + +ScriptAlias /zm/cgi-bin "/usr/lib/zoneminder/cgi-bin" +<Directory "/usr/lib/zoneminder/cgi-bin"> + AllowOverride None + Options ExecCGI FollowSymLinks + 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..ac56e4c69 --- /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
+@@ -91,7 +91,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
+@@ -122,7 +122,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
+@@ -130,10 +130,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);
+ }
+
+@@ -222,7 +224,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
+@@ -241,7 +243,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 )
diff --git a/pcr/zoneminder/patch-ffmpeg-configure.patch b/pcr/zoneminder/patch-ffmpeg-configure.patch new file mode 100644 index 000000000..ba1674a4a --- /dev/null +++ b/pcr/zoneminder/patch-ffmpeg-configure.patch @@ -0,0 +1,26 @@ +--- configure.old 2011-08-23 12:10:37.000000000 -0300 ++++ configure 2012-09-26 16:23:33.211940267 -0300 +@@ -3026,8 +3026,8 @@ + fi + + +-FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" +-FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" ++FFMPEG_LIBS=`pkg-config --cflags libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswscale` ++FFMPEG_CFLAGS=`pkg-config --cflags libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswscale` + + + +--- configure.ac.old 2011-08-23 12:10:32.000000000 -0300 ++++ configure.ac 2012-09-26 18:16:44.146848335 -0300 +@@ -88,8 +88,8 @@ + e.g. --with-ffmpeg=/usr/local]) + ) + AC_SUBST(FFMPEG_PREFIX) +-FFMPEG_LIBS="-L${FFMPEG_PREFIX}/${LIB_ARCH}" +-FFMPEG_CFLAGS="-I${FFMPEG_PREFIX}/include" ++FFMPEG_LIBS=`pkg-config --libs libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswscale` ++FFMPEG_CFLAGS=`pkg-config --libs libavcodec libavdevice libavfilter libavformat libavutil libpostproc libswscale` + AC_SUBST(FFMPEG_LIBS) + AC_SUBST(FFMPEG_CFLAGS) + 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..c4cbf4d3f --- /dev/null +++ b/pcr/zoneminder/zm.rc.d @@ -0,0 +1,63 @@ +#!/bin/bash + +daemon_name=zm + +. /etc/rc.conf +. /etc/rc.d/functions + +case "$1" in + start) + stat_busy "Starting Zoneminder" + /usr/bin/zmfix -a + if /usr/bin/zmpkg.pl start >/dev/null ; then + add_daemon $daemon_name + stat_done + else + stat_fail + exit 1 + fi + ;; + + stop) + stat_busy "Stopping Zoneminder" + if /usr/bin/zmpkg.pl stop >/dev/null ; then + rm_daemon $daemon_name + stat_done + else + stat_fail + exit 1 + fi + ;; + + reload) + stat_busy "Reloading Zoneminder" + if /usr/bin/zmpkg.pl graceful >/dev/null ; then + add_daemon $daemon_name + stat_done + else + stat_fail + exit 1 + fi + ;; + + restart) + stat_busy "Restarting Zoneminder" + if /usr/bin/zmpkg.pl restart >/dev/null ; then + add_daemon $daemon_name + stat_done + else + stat_fail + exit 1 + fi + ;; + + status) + stat_busy "Checking Zoneminder status"; + ck_status $daemon_name + ;; + + *) + echo "usage: $0 {start|stop|reload|restart|status}" +esac + +exit 0 diff --git a/pcr/zoneminder/zm.service b/pcr/zoneminder/zm.service new file mode 100644 index 000000000..ccf1f3334 --- /dev/null +++ b/pcr/zoneminder/zm.service @@ -0,0 +1,9 @@ +[Unit] +Description=Capture, analyse, record and monitor video security cameras + +[Service] +Type=forking +ExecStart=/usr/sbin/zm + +[Install] +WantedBy=multi-user.target 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..9939dc5c3 --- /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 +@@ -739,7 +739,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) ); + +@@ -1519,7 +1519,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..922aaad9b --- /dev/null +++ b/pcr/zoneminder/zoneminder.install @@ -0,0 +1,97 @@ +pre_install() { + set -e + abort=false + if [ -L /usr/share/zoneminder/www/events ]; then + l=$(readlink /usr/share/zoneminder/www/events) + if [ $l != /var/cache/zoneminder/events ]; then + abort=true + fi + fi + if [ -L /usr/share/zoneminder/www/images ]; then + l=$(readlink /usr/share/zoneminder/www/images ) + if [ $l != /var/cache/zoneminder/images ]; then + abort=true + fi + fi + if [ $abort = true ]; then + cat >&2 << EOF +Aborting installation of zoneminder due to non-default symlinks in +/usr/share/zoneminder/www for the images and/or events directory, which could +result in loss of data. Please move your data in each of these directories to +/var/cache/zoneminder before installing zoneminder from the package. +EOF + exit 1 + fi + exit 0 +} + +post_install() { + mkdir /usr/share/zoneminder/www/backup + mkdir /usr/share/zoneminder/www/socks + cat << EOF +Note: +==> To run Zoneminder, you must install the database running mysql service (as root): +==> "rc.d start mysqld" (in initscripts) or "systemctl start mysqld.service" (in systemd) +==> and add Zoneminder database typing: +==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f reload" +==> "cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf -p" +==> "echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql" + +Note: +==> You must uncomment that line in /etc/php/php.ini: +==> "extension=mysql.so" +==> check and make sure these are uncommented: +==> "extension=gd.so" +==> "extension=gettext.so" +==> "extension=mcrypt.so" +==> "extension=mysqli.so" +==> "extension=session.so" +==> "extension=sockets.so" + +==> You must edit /etc/php/php.ini and add to open_basedir "/etc" and +==> "/usr/share/zoneminder" like so +==> "open_basedir = /home:/tmp:/usr/share/pear:/etc:/usr/share/zoneminder/www" +==> Otherwise ZoneMinder will be unable to read /etc/zm.conf +==> or display its own web directory + +Note: +==> You must edit /etc/httpd/conf/httpd.conf and add the line: +==> "LoadModule php5_module modules/libphp5.so" +==> and: +==> "Include /etc/httpd/conf/extra/php5_module.conf" +==> "Include /etc/httpd/conf/extra/httpd-zm.conf" +EOF +} + +post_upgrade() { + /usr/bin/zmupdate.pl -f >/dev/null +} + +post_remove() { + cat << EOF +Note: +==> To clean Zoneminder mysql database, run as root: +==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql" +==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf -p mysql" +==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -p -f drop zm" + +==> Disable http with php if it isn't needed with others servers, +==> comment or remove that lines in /etc/httpd/conf/httpd.conf: +==> "LoadModule php5_module modules/libphp5.so" +==> "Include /etc/httpd/conf/extra/php5_module.conf" +==> "Include /etc/httpd/conf/extra/httpd-zm.conf" + +==> Disable php with mysql if it isn't needed with others servers, +==> comment that lines in /etc/php/php.ini: +==> "extension=mysql.so" +==> "extension=gd.so" +==> "extension=gettext.so" +==> "extension=mcrypt.so" +==> "extension=mysqli.so" +==> "extension=session.so" +==> "extension=sockets.so" + +==> edit /etc/php/php.ini and remove "/etc" and "/usr/share/zoneminder/www" +==> in the open_basedir. +EOF +} diff --git a/pcr/zoneminder/zoneminder.service b/pcr/zoneminder/zoneminder.service new file mode 100644 index 000000000..ba41e8926 --- /dev/null +++ b/pcr/zoneminder/zoneminder.service @@ -0,0 +1,14 @@ +[Unit] +Description=Capture, analyse, record and monitor video security cameras +After=network.target remote-fs.target +Required=mysqld.service + +[Service] +Type=forking +PIDFile=/run/zm.pid +ExecStart=/usr/bin/zmpkg.pl start +ExecRestart=/usr/bin/zmpkg.pl restart +ExecStop=/usr/bin/zmpkg.pl stop + +[Install] +WantedBy=multi-user.target |