<<CONTRIBUTORS>>
<<PACKAGE_VERSION_DATA>>
backup=( etc/zm.conf )
url="https://github.com/ZoneMinder/ZoneMinder/releases"
license=( GPL )
<<DEPENDENCIES>>
install=$_pkgname.install
<<SOURCES>>
<<BUILD>>
<<PACKAGE>>
<<httpd-zoneminder.conf>>
<<zoneminder.service>>
<<zoneminder.install>>
<<PHP.INI.SED>>
<<HTTPD.CONF.SED>>
- fix /tmp/zoneminder
<<CONTRIBUTORS>>
<<PACKAGE_VERSION_DATA_GIT>>
backup=( etc/zm.conf )
url="https://github.com/ZoneMinder/ZoneMinder/releases"
license=( GPL )
<<DEPENDENCIES>>
install=$_pkgname.install
<<SOURCES-GIT>>
<<pkgver-git>>
<<BUILD-GIT>>
<<PACKAGE-GIT>>
<<httpd-zoneminder.conf>>
<<zoneminder.service>>
<<zoneminder.install>>
<<PHP.INI.SED>>
<<HTTPD.CONF.SED>>
- fix /tmp/zoneminder
# Maintainer: Troy Will <troydwill at gmail dot com>
# Contributor: Charles Spence IV <[email protected]>
# Contributor: /dev/rs0 </dev/[email protected]>
# Contributor: Jacek Burghardt <[email protected]>
# Contributor: Vojtech Aschenbrenner <[email protected]>
# Contributor: Jason Gardner <[email protected]>
# Contributor: Ross melin <[email protected]>
# Contributor (Parabola): Márcio Silva <[email protected]>
# Contributor (Parabola): André Silva <[email protected]>
# Orginally based on a Debian Squeeze package
See https://wiki.archlinux.org/index.php/VCS_package_guidelines#The_pkgver.28.29_function
pkgver() {
cd "$_pkgname"
printf "%s.r%s.%s.%s" "$pkgver" "$(git rev-list --count HEAD)" "$pkgrel" "$(git rev-parse --short HEAD)"
}
_pkgname=zoneminder
pkgname=zoneminder
pkgver=1.28.0
pkgrel=11
pkgdesc='Capture, analyse, record and monitor video security cameras'
<<ARCH>>
_pkgname=zoneminder
pkgname=zoneminder-git
pkgver=1.28.0
pkgrel=11
pkgdesc='Capture, analyse, record and monitor video security cameras'
<<ARCH>>
arch=( i686 x86_64 mips64el arm armv7h )
depends=(
mariadb perl-dbd-mysql perl-dbi
apache php php-apache php-gd php-mcrypt perl-php-serialization
perl-libwww perl-net-sftp-foreign
ffmpeg vlc perl-sys-mmap
gnutls polkit
perl-expect perl-archive-zip perl-date-manip
perl-mime-lite perl-mime-tools
)
makedepends=(
cmake make gcc netpbm
)
optdepends=(
netpbm
cambozola
perl-time-modules
perl-x10-zoneminder
perl-astro-suntime-zoneminder
)
See https://github.com/ZoneMinder/ZoneMinder/releases
source=(
https://github.com/ZoneMinder/ZoneMinder/archive/v$pkgver.tar.gz
httpd-zoneminder.conf
zoneminder.service
)
sha256sums=('b9ee65635753e094dcad6cdb480acc42bff8b8f023ee008790883a4308273ca2'
'6e7155fc145e29351ec97f2b0c8d493fff871129a7e4c139d07bf6a9fc977919'
'7eb2f26246e240e23502da44854d5ed14485aa11bc448ad73e9b57fee13f00a3')
source=(
git://github.com/$_pkgname/$_pkgname.git
httpd-zoneminder.conf
zoneminder.service
)
# Because the source is not static, skip Git checksum:
sha256sums=('SKIP'
'6e7155fc145e29351ec97f2b0c8d493fff871129a7e4c139d07bf6a9fc977919'
'7eb2f26246e240e23502da44854d5ed14485aa11bc448ad73e9b57fee13f00a3')
# /etc/httpd/conf/extra/httpd-zoneminder.conf
# Config for zoneminder web app
Alias /zm "/srv/http/zoneminder"
<Directory "/srv/http/zoneminder">
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 /cgi-bin "/srv/http/cgi-bin"
<Directory "/srv/http/cgi-bin">
AllowOverride None
Options +ExecCGI +FollowSymLinks
Order allow,deny
Allow from all
</Directory>
# Provide PHP access to important directories
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/zm.conf:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks/:/var/log/zoneminder/"
# ZoneMinder systemd unit file for Arch Linux
[Unit]
Description=ZoneMinder CCTV recording and security system
After=network.target mysqld.service httpd.service
Requires=mysqld.service httpd.service
[Service]
User=http
Type=forking
ExecStart=/usr/bin/zmpkg.pl start
ExecReload=/usr/bin/zmpkg.pl restart
ExecStop=/usr/bin/zmpkg.pl stop
PIDFile="/srv/zoneminder/zm.pid"
[Install]
WantedBy=multi-user.target
post_install() {
# edit /etc/php.ini for Zoneminder
sed -e '
<<PHP.INI.SED>>
' /etc/php/php.ini > /etc/php/php.ini.zoneminder
# edit /etc/httpd/conf/httpd.conf for Zoneminder
sed -e '
<<HTTPD.CONF.SED>>
' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.zoneminder
cat << EOF
<<POST_INSTALL_MYSQL_INSTRUCTIONS_CHUNK>>
<<POST_INSTALL_PHP_INSTRUCTIONS_CHUNK>>
<<POST_INSTALL_APACHE_INSTRUCTIONS_CHUNK>>
EOF
}
post_upgrade() {
post_install
/usr/bin/zmupdate.pl -f >/dev/null
}
<<POST_REMOVE_CHUNK>>
Zoneminder database setup:
--------------------------
Zoneminder operation requires a database named 'zm' which is defined in /usr/share/zoneminder/db/zm_create.sql
Create the Zoneminder database (with a password):
"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"
(or without a password):
"mysqladmin --defaults-file=/etc/mysql/my.cnf -f reload"
"cat /usr/share/zoneminder/db/zm_create.sql | mysql --defaults-file=/etc/mysql/my.cnf"
"echo 'grant lock tables, alter,select,insert,update,delete on zm.* to 'zmuser'@localhost identified by "zmpass";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
PHP configuration
-----------------
* Check and make sure these are uncommented in /etc/php/php.ini:
extension=ftp.so
extension=gd.so
extension=gettext.so
extension=mcrypt.so
extension=openssl.so
extension=pdo_mysql.so
extension=sockets.so
extension=zip.so
* Add /etc/zm.conf, /srv/http/zoneminder, /var/cache/zoneminder, and /srv/zoneminder/socks to open_basedir in the zoneminder vhosts configuration file in apache:
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/:/etc/zm.conf:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks/:/var/log/zoneminder/"
* Set your timezone in php.ini:
date.timezone = <your_country>/<your_city>
Apache configuration
--------------------
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-zoneminder.conf"
- fix /tmp/zoneminder
post_remove() {
if [[ -d /tmp/zoneminder ]]; then
rm -vr /tmp/zoneminder
fi
# sed -i -e '
# /^open_basedir/ s/:\/srv\/http\/zoneminder//;
# /^open_basedir/ s/:\/srv\/http\/zoneminder\///;
# ' /etc/php/php.ini || read
# sed -i -e '
# /^# ZoneMinder/d;
# /Include \/etc\/httpd\/conf\/extra\/httpd-zoneminder.conf/d;
# ' /etc/httpd/conf/httpd.conf || read
cat << EOF
Note:
==> To clean Zoneminder mysql database, run as root (with password):
==> "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"
==> (or without password):
==> "echo 'delete from user where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "echo 'delete from db where User="zmuser";' | mysql --defaults-file=/etc/mysql/my.cnf mysql"
==> "mysqladmin --defaults-file=/etc/mysql/my.cnf -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"
==> Remove line in /etc/httpd/conf/httpd.conf:
==> "Include /etc/httpd/conf/extra/httpd-zoneminder.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=sockets.so"
==> "date.timezone = <my_country>/<my_city>"
==> Remove log files and "zoneminder" directory in "/var/log/zoneminder".
==> Backup and remove "events", "images" and "temp" dirs in "/var/cache/zoneminder".
EOF
}
Arch Linux | Debian Sid | |
---|---|---|
–prefix | /usr | /usr |
–enable-crashtrace | no | no |
–enable-debug | no | |
–enable-mmap | yes | yes |
–sysconfdir | /etc | /etc/zm |
–with-cgidir | /srv/http/cgi-bin | /usr/lib/cgi-bin |
–with-extralibs | ‘-L/usr/lib -L/usr/lib/mysql’ | |
–with-libarch | lib | |
–with-ffmpeg | /usr | |
–with-mysql | /usr | /usr |
–with-webdir | /srv/http/$pkgname | /usr/share/zoneminder |
–with-webgroup | http | www-data |
–with-webhost | localhost | |
–with-webuser | http | www-data |
–host | $(DEB_HOST_GNU_TYPE) | |
–build | $(DEB_BUILD_GNU_TYPE) | |
–mandir | \$${prefix}/share/man | |
–infodir | \$${prefix}/share/info | |
–ffmpeg | /usr |
./configure | Arch Linux ./configure | CMAKE | CMAKE Default | Debian Sid | |
---|---|---|---|---|---|
–prefix | /usr | Y | CMAKE_INSTALL_PREFIX | /usr | |
–enable-crashtrace | no | Y | no | ||
–enable-debug | no | N | |||
–enable-mmap | yes | Y | ZM_NO_MMAP | default: OFF | yes |
–sysconfdir | /etc | N | /etc/zm | ||
–with-cgidir | /srv/http/cgi-bin | Y | ZM_CGIDIR | <prefix>/libexec/zoneminder/cgi-bin | /usr/lib/cgi-bin |
–with-extralibs | ‘-L/usr/lib -L/usr/lib/mysql’ | N | CMAKE_LIBRARY_PATH | ||
–with-libarch | lib | N | |||
–with-ffmpeg | /usr | N | |||
–with-mysql | /usr | N | /usr | ||
–with-webdir | /srv/http/zoneminder | Y | ZM_WEBDIR | /usr/share/zoneminder/www | /usr/share/zoneminder |
–with-webgroup | http | N | |||
–with-webuser | http | Y | ZM_WEB_USER | www-data | |
–host | $(DEB_HOST_GNU_TYPE) | ||||
–build | $(DEB_BUILD_GNU_TYPE) | ||||
–mandir | \$${prefix}/share/man | ||||
–infodir | \$${prefix}/share/info | ||||
–ffmpeg | /usr | ||||
ZM_RUNDIR /var/run/zm | |||||
ZM_TMPDIR /tmp/zm | |||||
ZM_LOGDIR /var/log/zm | |||||
ZM_WEBDIR | <prefix>/share/zoneminder/www | ||||
/var/cache/zoneminder | X | ZM_CONTENTDIR (events and images) | /var/lib/zoneminder | ||
ZM_DB_HOST localhost | |||||
ZM_DB_NAME zm | |||||
ZM_DB_USER zmuser | |||||
ZM_DB_PASS zmpass | |||||
ZM_WEB_GROUP |
build() {
cd $srcdir/ZoneMinder-$pkgver
<<CMAKE_CHUNK>>
}
build() {
cd $srcdir/$_pkgname
<<CMAKE_CHUNK>>
}
# ZM_PERL_SUBPREFIX=/lib/perl5 flag added to force Perl modules
# to /usr/lib/perl5/ on non i686 architectures
cmake -DCMAKE_INSTALL_PREFIX=/usr \
-DZM_PERL_SUBPREFIX=/lib/perl5 \
-DZM_WEBDIR=/srv/http/zoneminder \
-DZM_CGIDIR=/srv/http/cgi-bin \
-DZM_WEB_USER=http \
-DZM_CONTENTDIR=/var/cache/zoneminder \
-DZM_LOGDIR=/var/log/zoneminder \
-DZM_RUNDIR=/srv/zoneminder \
-DZM_TMPDIR=/srv/zoneminder/tmp \
-DZM_SOCKDIR=/srv/zoneminder/socks .
make V=0
package() {
cd $srcdir/$_pkgname
DESTDIR=$pkgdir make install
<<POLKIT_PERMISSIONS_CHUNK>>
<<CREATE_ZONEMINDER_DIRECTORIES>>
<<CREATE_AND_LINK_CONTENT_FOLDERS>>
<<CREATE_CGI_BIN_LINK>>
<<CHANGE_OWNER_AND_GROUP>>
<<LINK_CAMBOZOLA>>
<<INSTALL_CONF_FILES>>
}
package() {
cd $srcdir/ZoneMinder-$pkgver
DESTDIR=$pkgdir make install
<<POLKIT_PERMISSIONS_CHUNK>>
<<CREATE_ZONEMINDER_DIRECTORIES>>
<<CREATE_AND_LINK_CONTENT_FOLDERS>>
<<CREATE_CGI_BIN_LINK>>
<<CHANGE_OWNER_AND_GROUP>>
<<LINK_CAMBOZOLA>>
<<INSTALL_CONF_FILES>>
}
# BEGIN CREATE_ZONEMINDER_DIRECTORIES
mkdir -pv $pkgdir/var/{cache/zoneminder,log/zoneminder}
chown -Rv http.http $pkgdir/var/{cache/zoneminder,log/zoneminder}
mkdir -pv $pkgdir/srv/zoneminder/socks
chown -v http.http $pkgdir/srv/zoneminder/socks
mkdir -pv $pkgdir/srv/zoneminder/tmp
chown -v http.http $pkgdir/srv/zoneminder/tmp
chown -v http.http $pkgdir/etc/zm.conf
chmod 0700 $pkgdir/etc/zm.conf
# END CREATE_ZONEMINDER_DIRECTORIES
/srv |
/srv/http |
/srv/http/cgi-bin |
/etc |
/etc/rc.d |
/etc/httpd |
/etc/httpd/conf |
/etc/httpd/conf/extra |
/usr |
/usr/share |
/usr/share/db |
/usr/share/license |
/usr/lib |
/usr/lib/systemd |
/usr/lib/systemd/system |
/var |
/var/cache |
/var/log |
removed
mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},srv/http/{cgi-bin,$pkgname},usr/{lib/systemd/system,share/{license/$pkgname,$pkgname/db}},var/{cache/$pkgname,log/$pkgname}}
and replaced with
mkdir -p $pkgdir/var/{cache/$pkgname,log/$pkgname}
# Make content directories in /var/cache/zoneminder and to link them in /srv/http/zoneminder
for i in events images temp; do
mkdir $pkgdir/var/cache/$_pkgname/$i
chown -v http.http $pkgdir/var/cache/$_pkgname/$i
ln -s /var/cache/$_pkgname/$i $pkgdir/srv/http/$_pkgname/$i
chown -v --no-dereference http.http $pkgdir/srv/http/$_pkgname/$i
done
# Create a link to the Zoneminder cgi binaries
ln -sv /srv/http/cgi-bin $pkgdir/srv/http/$_pkgname
chown -h http.http $pkgdir/srv/http/{cgi-bin,$_pkgname,$_pkgname/cgi-bin}
# Link Cambozola
# ln -s /usr/share/cambozola/cambozola.jar $pkgdir/srv/http/$_pkgname
# Install configuration files
mkdir -p $pkgdir/etc/httpd/conf/extra
install -D -m 644 $srcdir/httpd-$_pkgname.conf $pkgdir/etc/httpd/conf/extra
mkdir -p $pkgdir/usr/lib/systemd/system
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
# Change Polkit directory permissions to Arch Linux policy
chmod -v 700 $pkgdir/usr/share/polkit-1/rules.d/
chown -v polkitd $pkgdir/usr/share/polkit-1/rules.d/
ERROR | FIX | ||
---|---|---|---|
0919 | 1105 | mv: cannot stat ‘/home/troy/rcs/zoneminder-aur/FRI/pkg/zoneminder/srv/http/zoneminder/events’: No such file or directory | # mv $pkgdir/srv/http/$pkgname/$i $pkgdir/var/cache/$pkgname/$i |
0919 | 1113 | test and document mkdir -p $pkgdir/{etc/{httpd/conf/extra,rc.d},srv/http/{cgi-bin,$pkgname},usr/{lib/systemd/system,share/{license/$pkgname,$pkgname/db}},var/{cache/$pkgname,log/$pkgname}} |
<<MOD_MPM_PREFORK.SED>>
<<MOD_CGI.SED>>
<<LIBPHP5.SED>>
<<HTTPD-ZONEMINDER.CONF.SED>>
# Use mod_mpm_prefork instead of mod_mpm_event.so (FS#39218).
s|^LoadModule mpm_event_module modules/mod_mpm_event.so$|#&\nLoadModule mpm_prefork_module modules/mod_mpm_prefork.so|;
# Zoneminder requires cgi
\|^#LoadModule cgi_module modules/mod_cgi.so$| s|#||;
# libphp5
\|^LoadModule php5_module modules/libphp5.so$|d;
s|^#*LoadModule rewrite_module modules/mod_rewrite.so$|&\nLoadModule php5_module modules/libphp5.so|;
\|^Include /etc/httpd/conf/extra/php5_module.conf|d;
s|^Include conf/extra/httpd-default.conf$|&\nInclude /etc/httpd/conf/extra/php5_module.conf|;
# Include httpd-zoneminder.conf
\|^Include /etc/httpd/conf/extra/httpd-zoneminder.conf$|d;
s|^# Server-pool management (MPM specific)$|\nInclude /etc/httpd/conf/extra/httpd-zoneminder.conf\n&|;
# Enable these libraries by removing the leading comment character
\|^;extension=ftp.so$| s|^;||;
\|^;extension=gd.so$| s|^;||;
\|^;extension=gettext.so$| s|^;||;
\|^;extension=mcrypt.so$| s|^;||;
\|^;extension=openssl.so$| s|^;||;
\|^;extension=pdo_mysql.so$| s|^;||;
\|^;extension=sockets.so$| s|^;||;
\|^;extension=zip.so$| s|^;||;
# Enable these libraries by removing the leading comment character
\|^;extension=pdo_mysql.so$| s|^;||;
\|^;extension=gd.so$| s|^;||;
\|^;extension=gettext.so$| s|^;||;
\|^;extension=mcrypt.so$| s|^;||;
\|^;extension=sockets.so$| s|^;||;
\|^;extension=openssl.so$| s|^;||;
\|^;extension=ftp.so$| s|^;||;
\|^;extension=zip.so$| s|^;||;
- Removed open_basedir sed transformation
# Add zoneminder paths to open_basedir s|^open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/$|&:/etc:/srv/http/zoneminder/:/var/cache/zoneminder/:/srv/zoneminder/socks:/var/log/zoneminder|;
-DZM_PERL_SUBPREFIX=/lib/perl5 with help of Charles Spence IV to force Perl modules
I noticed that while installing the package with pacman, a couple warnings appear:
warning: directory permissions differ on usr/share/polkit-1/rules.d filesystem: 700 package: 755 warning: directory ownership differs on usr/share/polkit-1/rules.d filesystem: 102:0 package: 0:0
These warnings can be fixed by including these three lines on the end of the package() section:
chmod 700 $pkgdir/usr/share/polkit-1/rules.d/ chown polkitd $pkgdir/usr/share/polkit-1/rules.d/