diff options
-rw-r--r-- | .SRCINFO | 10 | ||||
-rw-r--r-- | PKGBUILD | 52 | ||||
-rw-r--r-- | zoneminder-httpd.conf | 54 | ||||
-rw-r--r-- | zoneminder-nginx.conf | 9 | ||||
-rw-r--r-- | zoneminder.install | 190 | ||||
-rw-r--r-- | zoneminder.service | 5 |
6 files changed, 239 insertions, 81 deletions
@@ -1,7 +1,7 @@ pkgbase = zoneminder pkgdesc = A full-featured, open source, state-of-the-art video surveillance software system. pkgver = 1.32.1 - pkgrel = 2 + pkgrel = 3 url = https://zoneminder.com/ install = zoneminder.install arch = x86_64 @@ -41,23 +41,27 @@ pkgbase = zoneminder depends = perl-php-serialization depends = perl-sys-cpu depends = perl-uri-encode + optdepends = apache: alternative web server optdepends = vlc: provides libvlc (may achieve better performance with some cameras) optdepends = ffmpeg-full: provides libavresample (dropped from the official ffmpeg package) conflicts = zoneminder-git backup = etc/nginx/sites-available/zoneminder.conf + backup = etc/httpd/conf/extra/zoneminder.conf source = https://github.com/ZoneMinder/ZoneMinder/archive/1.32.1.tar.gz source = https://github.com/FriendsOfCake/crud/archive/v3.2.0.tar.gz source = https://github.com/ZoneMinder/CakePHP-Enum-Behavior/archive/1.0-zm.tar.gz source = zoneminder-nginx.conf + source = zoneminder-httpd.conf source = zoneminder-php.ini source = zoneminder.service source = zoneminder-tmpfile.conf sha256sums = a10c0c416e2127111b4d72f0046ed3a1f56708e3f4b48680848d755b01811d3c sha256sums = 55be29e1eccb44d4ad0db8b23c37cec50f5341f8e498583d472ed1f0493876e3 sha256sums = dbd231e97b950c698f0f501d6a53c7291c9985e766b09e3afe00cfe69a969f44 - sha256sums = fed9010e55426cf05779c6161936655c7423c177c3b0b466a93853a61c79f7fe + sha256sums = 7b14652fa05ed07043abb082ab699b36ea76c5bfc0fb6fbc4418cbd66e4e3181 + sha256sums = 1944e27db3b17edac152209b2b35e914ed9700a2ffe0255b012661197a328178 sha256sums = 7905ceddbb049de0f9bf4f1eb58779dfe310a65c4d2ec44854d592d4f31b6a72 - sha256sums = aa34c9414341eecbda4cba1a3446cf5062ab5fddc06a7f999e71916437d5f88d + sha256sums = 3e4de227e3154dffa887f2286c339ab3cf456f6d74a400b2786192b7e2b129c0 sha256sums = d1341338538f2ac771e6b1eee9aa48e8b0da4a140024c74bc33a9f6b52443bdd pkgname = zoneminder @@ -14,21 +14,23 @@ -### Important notes for version 1.32 ### +### Important notes for version 1.32.x ### # # 1) git-clone for CakePHP and Crud sources was replaced with published precompiled packages, as follows: # - CakePHP-Enum-Behaviour is pulled from the ZoneMinder repo, because a change is needed that has not yet been merged upstream. # - Crud is pulled from its official repo, since Pull Request #582 has been merged as required by the ZoneMinder devs. # -# 2) Apache was switched out in favor of Nginx. +# 2) By default, ZoneMinder now runs at localhost:8095 instead of localhost/zm (this can be changed by editing the provided conf files). # -# 3) By default, ZoneMinder now runs at localhost:8095 instead of localhost/zm (this can be changed by editing the provided Nginx conf file). +# 3) Apache was switched out in favor of Nginx, but remains as an optional dependency. # -# 4) For the time being Nginx and MariaDB are hard-coded as dependencies. In the future I'll look into supporting different use cases. +# 4) Nginx and MariaDB are hard-coded as dependencies, but can be easily removed in order to achieve a web server agnostic and/or database-less PKGBUILD. ####################################################################################################################### # # +# If you're upgrading from v1.30.4 or earlier: # +# # # Due to the many breaking changes in this release (both upstream and in the packaging), it's recommended to backup # # any existing ZoneMinder databases and perform a clean installation. Failure to do so may have very weird results. # # # @@ -38,13 +40,17 @@ pkgname=zoneminder pkgver=1.32.1 -pkgrel=2 +pkgrel=3 pkgdesc='A full-featured, open source, state-of-the-art video surveillance software system.' arch=('x86_64') url='https://zoneminder.com/' license=('GPLv2') depends=('polkit' 'ffmpeg' 'libmp4v2' - 'mariadb' 'nginx-mainline' 'fcgiwrap' 'php-apcu' 'php-fpm' 'php-gd' + # Remove the following line if you want to install ZoneMinder without a local database server, e.g. as part of a Multi-Server setup + 'mariadb' + # Remove the following line if you don't need Nginx + 'nginx-mainline' 'fcgiwrap' + 'php-apcu' 'php-fpm' 'php-gd' 'perl-archive-zip' 'perl-data-dump' 'perl-date-manip' 'perl-dbd-mysql' 'perl-device-serialport' 'perl-file-slurp' 'perl-image-info' 'perl-json-any' 'perl-libwww' 'perl-mime-lite' 'perl-mime-tools' 'perl-number-bytes-human' 'perl-sys-meminfo' 'perl-sys-mmap' # Needed for ONVIF support @@ -56,24 +62,33 @@ depends=('polkit' 'ffmpeg' 'libmp4v2' # Unverified dependencies. So far not installing them hasn't raised any red flags, but I can't be 100% sure whether they're leftovers from previous ZoneMinder incarnations or if they're needed for proper operation during runtime, so for the time being I'm leaving them in. 'perl-net-sftp-foreign' 'perl-php-serialization' 'perl-sys-cpu' 'perl-uri-encode') makedepends=('cmake') -optdepends=('vlc: provides libvlc (may achieve better performance with some cameras)' +optdepends=('apache: alternative web server' + 'vlc: provides libvlc (may achieve better performance with some cameras)' 'ffmpeg-full: provides libavresample (dropped from the official ffmpeg package)') conflicts=('zoneminder-git') -backup=("etc/nginx/sites-available/$pkgname.conf") +backup=("etc/nginx/sites-available/$pkgname.conf" + "etc/httpd/conf/extra/$pkgname.conf") install=$pkgname.install source=("https://github.com/ZoneMinder/ZoneMinder/archive/$pkgver.tar.gz" "https://github.com/FriendsOfCake/crud/archive/v3.2.0.tar.gz" "https://github.com/ZoneMinder/CakePHP-Enum-Behavior/archive/1.0-zm.tar.gz" "zoneminder-nginx.conf" + "zoneminder-httpd.conf" "zoneminder-php.ini" "zoneminder.service" "zoneminder-tmpfile.conf") sha256sums=('a10c0c416e2127111b4d72f0046ed3a1f56708e3f4b48680848d755b01811d3c' '55be29e1eccb44d4ad0db8b23c37cec50f5341f8e498583d472ed1f0493876e3' 'dbd231e97b950c698f0f501d6a53c7291c9985e766b09e3afe00cfe69a969f44' - 'fed9010e55426cf05779c6161936655c7423c177c3b0b466a93853a61c79f7fe' + # zoneminder-nginx.conf + '7b14652fa05ed07043abb082ab699b36ea76c5bfc0fb6fbc4418cbd66e4e3181' + # zoneminder-httpd.conf + '1944e27db3b17edac152209b2b35e914ed9700a2ffe0255b012661197a328178' + # zoneminder-php.ini '7905ceddbb049de0f9bf4f1eb58779dfe310a65c4d2ec44854d592d4f31b6a72' - 'aa34c9414341eecbda4cba1a3446cf5062ab5fddc06a7f999e71916437d5f88d' + # zoneminder.service + '3e4de227e3154dffa887f2286c339ab3cf456f6d74a400b2786192b7e2b129c0' + # zoneminder-tmpfile.conf 'd1341338538f2ac771e6b1eee9aa48e8b0da4a140024c74bc33a9f6b52443bdd') prepare () { @@ -134,21 +149,22 @@ package() { chmod 644 $pkgdir/etc/$pkgname/zm.conf chmod 644 $pkgdir/etc/$pkgname/conf.d/* - # Setup Nginx - install -Dm644 $srcdir/$pkgname-nginx.conf $pkgdir/etc/nginx/sites-available/$pkgname.conf - install -dm755 $pkgdir/etc/nginx/sites-enabled - ln -s /etc/nginx/sites-available/$pkgname.conf $pkgdir/etc/nginx/sites-enabled/$pkgname.conf + # Install Nginx conf file + install -Dm644 $srcdir/$pkgname-nginx.conf $pkgdir/etc/nginx/sites-available/$pkgname.conf + + # Install Apache conf file + install -Dm644 $srcdir/$pkgname-httpd.conf $pkgdir/etc/httpd/conf/extra/$pkgname.conf - # Setup PHP-FPM + # Install PHP-FPM ini file install -Dm644 $srcdir/$pkgname-php.ini $pkgdir/etc/php/conf.d/$pkgname.ini - # Setup systemd service + # Install systemd service install -Dm644 $srcdir/$pkgname.service $pkgdir/usr/lib/systemd/system/$pkgname.service - # Setup systemd tmpfile + # Install systemd tmpfile install -Dm644 $srcdir/$pkgname-tmpfile.conf $pkgdir/usr/lib/tmpfiles.d/$pkgname.conf - # Setup logrotate + # Install logrotate conf file install -Dm644 misc/logrotate.conf $pkgdir/etc/logrotate.d/$pkgname # Copy license and database schemas diff --git a/zoneminder-httpd.conf b/zoneminder-httpd.conf new file mode 100644 index 000000000000..7ef3a7731744 --- /dev/null +++ b/zoneminder-httpd.conf @@ -0,0 +1,54 @@ +Listen 8095 + +<VirtualHost localhost:8095> + ServerName localhost:8095 + DocumentRoot /srv/zoneminder/www + + # PHP handler + <FilesMatch \.php$> + SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/" + </FilesMatch> + + ScriptAlias /cgi-bin /srv/zoneminder/cgi-bin + <Directory /srv/zoneminder/cgi-bin> + Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch + AllowOverride None + Require all granted + </Directory> + + Alias /cache /var/lib/zoneminder/cache + <Directory /var/lib/zoneminder/cache> + Options -Indexes +FollowSymLinks + AllowOverride None + Require all granted + </Directory> + + <Directory /srv/zoneminder/www> + Options -Indexes +FollowSymLinks + AllowOverride None + Require all granted + DirectoryIndex index.php + </Directory> + + <Directory /srv/zoneminder/www/api> + RewriteEngine On + RewriteRule ^$ app/webroot/ [L] + RewriteRule (.*) app/webroot/$1 [L] + RewriteBase /api + </Directory> + + <Directory /srv/zoneminder/www/api/app> + RewriteEngine On + RewriteRule ^$ webroot/ [L] + RewriteRule (.*) webroot/$1 [L] + RewriteBase /api + </Directory> + + <Directory /srv/zoneminder/www/api/app/webroot> + RewriteEngine On + RewriteCond %{REQUEST_FILENAME} !-d + RewriteCond %{REQUEST_FILENAME} !-f + RewriteRule ^ index.php [L] + RewriteBase /api + </Directory> +</VirtualHost>
\ No newline at end of file diff --git a/zoneminder-nginx.conf b/zoneminder-nginx.conf index 33fe7ab94d13..29fc1dde40b7 100644 --- a/zoneminder-nginx.conf +++ b/zoneminder-nginx.conf @@ -11,9 +11,14 @@ server { location / { try_files $uri $uri/ /index.php?$args =404; - + + location ~ /api/(css|img) { + rewrite ^/api(.+)$ /api/app/webroot/$1 break; + try_files $uri $uri/ =404; + } + location /api { - rewrite ^/api(.+)$ /api/app/webroot/index.php?p=\$1 last; + rewrite ^/api(.+)$ /api/app/webroot/index.php?p=$1 last; } location /cgi-bin { diff --git a/zoneminder.install b/zoneminder.install index 4777e2d90a2a..0c7a838ca247 100644 --- a/zoneminder.install +++ b/zoneminder.install @@ -1,76 +1,133 @@ post_install() { echo - systemctl daemon-reload + systemctl daemon-reload - - ### Nginx ### - - # Configure it with the folder structure used in Debian-based distributions - if [ -f /etc/nginx/nginx.conf ] + ### Apache ### + if [ -f /usr/lib/systemd/system/httpd.service ] then - if ( ! grep -q 'sites-enabled' /etc/nginx/nginx.conf ) + # Check if the main conf file is present + if [ -f /etc/httpd/conf/httpd.conf ] then - sed -i 's|http {|http {\'$'\n include sites-enabled/*.conf;|g' /etc/nginx/nginx.conf + # Enable mod_proxy + sed -i 's|#LoadModule proxy_module modules/mod_proxy.so|LoadModule proxy_module modules/mod_proxy.so|g' /etc/httpd/conf/httpd.conf + # Enable mod_proxy_fcgi + sed -i 's|#LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so|LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so|g' /etc/httpd/conf/httpd.conf + # Enable mod_rewrite + sed -i 's|#LoadModule rewrite_module modules/mod_rewrite.so|LoadModule rewrite_module modules/mod_rewrite.so|g' /etc/httpd/conf/httpd.conf + # Enable mod_cgid + sed -i 's|#LoadModule cgid_module modules/mod_cgid.so|LoadModule cgid_module modules/mod_cgid.so|g' /etc/httpd/conf/httpd.conf + + # Enable ZoneMinder's VirtualHost + if ( ! grep -q 'zoneminder.conf' /etc/httpd/conf/httpd.conf ) + then + echo "Include conf/extra/zoneminder.conf" >> /etc/httpd/conf/httpd.conf + fi + fi + + # Check if Nginx is running and if not (re)start Apache + if [ "$(systemctl is-active nginx)" != "active" ] + then + systemctl is-active --quiet httpd && systemctl stop httpd + systemctl start httpd fi - systemctl is-active --quiet nginx && systemctl stop nginx - systemctl start nginx fi - ### PHP-FPM ### - - # Set local timezone in /etc/php/conf.d/zoneminder.ini - sed -i 's|PLACEHOLDER|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini - systemctl is-active --quiet php-fpm && systemctl stop php-fpm - systemctl start php-fpm + ### Nginx ### + if [ -f /usr/lib/systemd/system/nginx.service ] + then + # Check if the main conf file is present + if [ -f /etc/nginx/nginx.conf ] + then + # Configure it with the folder structure used in Debian-based distributions + if ( ! grep -q 'sites-enabled' /etc/nginx/nginx.conf ) + then + sed -i 's|http {|http {\'$'\n include sites-enabled/*.conf;|g' /etc/nginx/nginx.conf + fi + + # Enable ZoneMinder's server block + if [ ! -d /etc/nginx/sites-enabled ] + then + mkdir -p /etc/nginx/sites-enabled + fi + + if [ ! -f /etc/nginx/sites-enabled/zoneminder.conf ] + then + ln -s /etc/nginx/sites-{available,enabled}/zoneminder.conf + fi + fi + + # Check if Apache is running and if not (re)start Nginx + if [ "$(systemctl is-active httpd)" != "active" ] + then + systemctl is-active --quiet nginx && systemctl stop nginx + systemctl start nginx + fi + fi ### fcgiwrap ### - systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket - systemctl is-active --quiet fcgiwrap && systemctl stop fcgiwrap - systemctl start fcgiwrap.socket - + if [ -f /usr/lib/systemd/system/fcgiwrap.service ] + then + systemctl is-active --quiet fcgiwrap.socket && systemctl stop fcgiwrap.socket + systemctl is-active --quiet fcgiwrap && systemctl stop fcgiwrap + systemctl start fcgiwrap.socket + fi - ### MariaDB ### - systemctl is-active --quiet mariadb && systemctl stop mariadb + ### PHP-FPM ### + # Set local timezone in /etc/php/conf.d/zoneminder.ini + sed -i 's|PLACEHOLDER|'`timedatectl | grep "Time zone" | tr -s ' ' | cut -f4 -d ' '`'|g' /etc/php/conf.d/zoneminder.ini - # Initialize MariaDB's default database if it's not already initialized - if [ ! -d /var/lib/mysql/mysql ] + if [ -f /usr/lib/systemd/system/php-fpm.service ] then - # NOTE: This will need to be changed when MariaDB 10.2 hits the repos, as mysql_install_db has been deprecated in favor of mysqld - mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 2> /dev/null + systemctl is-active --quiet php-fpm && systemctl stop php-fpm + systemctl start php-fpm fi - systemctl start mariadb - - - ### ZoneMinder ### + + ### MariaDB ### - # Create ZoneMinder's database & user if they do not exist - if [ ! -d /var/lib/mysql/zm ] + if [ -f /usr/lib/systemd/system/mariadb.service ] then - # Check for database root password - if [[ "$(mysql -uroot -e "select * from mysql.user;" 2>&1)" = *"Access denied"* ]] + # Initialize MariaDB's default database if it's not already initialized + if [ ! -d /var/lib/mysql/mysql ] + then + systemctl is-active --quiet mariadb && systemctl stop mariadb + # NOTE: This will need to be changed when MariaDB 10.2 hits the repos, as mysql_install_db has been deprecated in favor of mysqld + mysql_install_db --user=mysql --basedir=/usr --datadir=/var/lib/mysql 2> /dev/null + fi + + systemctl is-active --quiet mariadb || systemctl start mariadb + + # Create ZoneMinder's database & user if they do not exist + if [ ! -d /var/lib/mysql/zm ] then - # If a database root password is set - echo \* Secure MariaDB installation found, please enter the database root password when prompted. - echo - mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql - echo - echo \* One more time... - echo - mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" - echo - else - # If a database root password is not set - mysql -uroot < /usr/share/zoneminder/db/zm_create.sql - mysql -uroot -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" + # Check for database root password + if [[ "$(mysql -uroot -e "select * from mysql.user;" 2>&1)" = *"Access denied"* ]] + then + # If a database root password is set + echo \* Secure MariaDB installation found, please enter the database root password when prompted. + echo + mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql + echo + echo \* One more time... + echo + mysql -uroot -p -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" + echo + else + # If a database root password is not set + mysql -uroot < /usr/share/zoneminder/db/zm_create.sql + mysql -uroot -e "grant select,insert,update,delete,create,alter,index,lock tables on zm.* to 'zmuser'@localhost identified by 'zmpass';" + fi fi fi + + ### ZoneMinder ### + systemctl is-active --quiet zoneminder && systemctl stop zoneminder systemd-tmpfiles --create systemctl start zoneminder @@ -102,12 +159,35 @@ post_upgrade() { post_remove() { systemctl daemon-reload && systemctl is-active --quiet zoneminder && systemctl stop zoneminder - echo - echo ZoneMinder\'s database and user have been left intact. You can remove them by running the following: - echo - echo mysql -uroot -p -e \"drop database zm\;\" - echo mysql -uroot -p -e \"drop user \'zmuser\'@localhost\;\" - echo - echo If you haven\'t yet configured a password for the database root user, omit the \'-p\' option. - echo + # Disable ZoneMinder's Apache VirtualHost + if [ -f /etc/httpd/conf/httpd.conf ] + then + sed -i '/zoneminder.conf/d' /etc/httpd/conf/httpd.conf + fi + + # Disable ZoneMinder's Nginx server block + if [ -h /etc/nginx/sites-enabled/zoneminder.conf ] + then + rm /etc/nginx/sites-enabled/zoneminder.conf + + # If the sites-enabled directory is empty, remove it as well and also remove reference in nginx.conf + if [ -z "$(ls -A /etc/nginx/sites-enabled)" ] + then + rm -r /etc/nginx/sites-enabled + sed -i '/sites-enabled/d' /etc/nginx/nginx.conf + fi + fi + + # Notify user about ZoneMinder's database and user not being removed + if [ -d /var/lib/mysql/zm ] + then + echo + echo ZoneMinder\'s database and user have been left intact. You can remove them by running the following: + echo + echo mysql -uroot -p -e \"drop database zm\;\" + echo mysql -uroot -p -e \"drop user \'zmuser\'@localhost\;\" + echo + echo If you haven\'t yet configured a password for the database root user, omit the \'-p\' option. + echo + fi } diff --git a/zoneminder.service b/zoneminder.service index f825d6cee757..46ec4b2452df 100644 --- a/zoneminder.service +++ b/zoneminder.service @@ -1,8 +1,7 @@ [Unit] Description=ZoneMinder - CCTV Monitoring and Recording System -Requires=mariadb.service -Wants= nginx.service php-fpm.service fcgiwrap.socket -After=network.target mariadb.service nginx.service +After=network.target mariadb.service +Wants=mariadb.service [Service] User=http |