Difference between revisions of "Devuan Beowulf with Zoneminder 1.34 from ZM Repo"

From ZoneMinder Wiki
Jump to navigationJump to search
 
(21 intermediate revisions by one other user not shown)
Line 1: Line 1:
This install procedure was developed to use the Debian package developed by iconnor following Master.
Tested today with a migration from a fresh Raspbian Buster which was migrated to Beowulf. I did it a roundabout way, but users should be able to follow the same instructions for Ascii here: [[Devuan Ascii with Zoneminder 1.32.3 from ZM Repo]], except substituting release-1.34 for release in the zmrepo apt sources list. Please refer to zmrepo.zoneminder.com/debian for more details.


The errors with Devuan vs. Debian are superfluous errors, due to init script generators using systemctl. Sysvinit users must manually run the db creation script, and procure an /etc/init.d/zoneminder script (for new installs).
Make sure to add in the /etc/init.d/zoneminder file from [[Zoneminder_Init_Script]]


To begin, install Devuan Ascii along with Apache2, PHP and a database (Mariadb recommended).


Add the repro
Log: tested update from Devuan Jessie to Beowulf: 2020/06


sudo nano /etc/apt/sources.list
This is a guide for a Sysvinit based Devuan / [[Debian]] system. Debian Stretch / Devuan Ascii and Zoneminder Stable 1.34 from the ZMRepo. 1.35 is unstable (odd number).


Add the following line to the end of the file
'''Requirements:'''
* Debian 10 | buster /sysvinit
* Devuan Beowulf
* Zoneminder 1.34


deb https://zmrepo.zoneminder.com/debian/master buster/
==Install==


CTRL+o then [Enter] to save
install mariadb, apache2, php
based on:
https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-stretch/


CTRL+x to exit
apt-get install mariadb-server apache2 php7.3 libapache2-mod-php7.3


Install the following and retrieve the key from the repro
restart apache


  sudo apt install apt-transport-https gnupg
  service apache2 restart


Add zmrepo to /etc/apt/sources.list
deb https://zmrepo.zoneminder.com/debian/release-1.34/ buster/
NOTE: 1.34 is currently in release-1.34 folder on zmrepo. This is subject to change. Confirm it's there before installing.
NOTE: In order to make this guide, all the existing guides for [[Debian]] were parsed.
https://wiki.zoneminder.com/Debian_9_64-bit_with_Zoneminder_1.30.4_the_Easy_Way
https://wiki.zoneminder.com/Debian_10_Buster_with_Zoneminder_1.34.x_from_ZM_Repo
(these names are changed periodically, so refer to [[Debian]])
etc...
apt-get update
apt-get install apt-transport-https gnupg
  wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
  wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
apt-get update
apt-get install zoneminder  vlc-plugin-base php7.3-gd
adduser www-data video
apt-get install zoneminder
a2enmod cgi
a2enmod rewrite
a2enconf zoneminder
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
mysqladmin -uroot -p reload
The zmupdate.pl call may fail during install of zoneminder. Run it manually to update the db.
# zmupdate.pl
Then apt should complete successfully. Some systemctl commands will fail, but these can be ignored for now.
may need to set timezone in /etc/php/7.3/apache2/php.ini
(and In 1.34 in zm web console options)
e.g. date.timezone America/New_York
EDIT: actually, set the timezone in zoneminder. Because upon update of php,
the new php won't have the TZ configured properly.
service apache2 restart
At this point, you will not have an /etc/init.d/ file for zoneminder
You must copy one from an existing install, or from 1.29 or 1.30.4.
I'm going to put the init script from 1.30.4 in [[Zoneminder_Init_Script]]
after copying that in, and chmod +x /etc/init.d/zoneminder
zoneminder should start:
<pre>
# service zoneminder start
Starting ZoneMinder: 01/27/2020 12:27:42.776878 zmpkg[2722].INF [main:57] [Command: start]
01/27/2020 12:27:42.778627 zmpkg[2722].INF [main:305] [Sanity checking States table...]
01/27/2020 12:27:42.780839 zmpkg[2722].INF [main:97] [Command: start]
01/27/2020 12:27:44.231615 zmpkg[2722].INF [main:205] [Single server configuration detected. Starting up services.]
success
</pre>
double check by reviewing
ps auxw | grep zm
Now, navigate to the Apache server which hosts ZM gui at http://serverip/zm
Review syslog for any error messages.
==Upgrading DB==
NOTE: this covers DB upgrades only. Not upgrade steps. See install above for general upgrade.
If you are importing an existing db, now is a good time. Stop zm, and import the db.


'''Important - Make sure the above "wget" process completes without error! If it does not complete you will not get the most recent Zoneminder version this procedure is written for.'''
service zoneminder stop


  sudo apt update
  mysqldump -u root -p zm > dump.sql  (export old db)
mysql -uroot -p zm < dump.sql  (import old db)


Install mariadb-server, apache and php
After this is done, you need to update the db


  sudo apt install mariadb-server apache2 php
  # zmupdate.pl


Install Zoneminder
run this at least twice, as it tends to error out. If it's already updated, nothing new will happen.


sudo apt install zoneminder
you should see something like:
Database upgrade to version 1.32.3 successful.


'''Sysvinit specific changes''' Configure user in mysql for ZM if this is a new install
Then start zm


  cat /usr/share/zoneminder/db/zm_create.sql | sudo mysql --defaults-file=/etc/mysql/debian.cnf
  service zoneminder start


echo 'grant lock tables,alter,create,select,insert,update,delete,index on zm.* to 'zmuser'@localhost identified by "zmpass";'    | sudo mysql --defaults-file=/etc/mysql/debian.cnf mysql
you might want to run zmaudit.pl to delete non existing events on the new install


The reason this is done, is because the init script generator is using systemctl, and those without systemd don't have this command in the dpkg script at /var/lib/dpkg/info/zoneminder.postinst. So it must be run manually. An /etc/init.d/zoneminder script will also need to be grabbed from an earlier ZM install.


Users who have worked with ZM in the past may recognize these commands. In debian they are now automated, which can be good and bad (bad when it fails, and you don't know why).
==Troubleshooting==
'''End sysvinit section'''


If MySQL/MariaDB is not running during install run
* zmupdate.pl if apt-get fails db upgrade during install of zoneminder.
* You might have to install zoneminder again, instead of an update. Backup DB, and nothing will be lost.
* if localhost/zm says 'page not found' check /etc/apache/conf-available/ which points to /usr/share/zoneminder/www and which may not have the correct permissions (needs apache / www-data user) with 0755 / chown root:www-data
* also check that you enabled the conf in apache: a2enconf zoneminder
* unable to connect to db driver missing, is an issue with multiple php versions - see forums. (a2dismod php7.0, a2enmod php7.3)


sudo dpkg-reconfigure zoneminder
===Postinstall script Errors===
The /var/lib/dpkg/info/zoneminder.postinst script may fail due to lack of systemctl. The script can be edited similar to below to quiet the error messages (note: assumes an upgrade. Read the original script if you don't know what it's doing! Essentially, it's just stopping ZM, then running zmupdate.pl and changing possibly apache's zm config. )


Enable Zoneminder
<pre>
#! /bin/sh


sudo systemctl enable zoneminder.service
set +e


Enable Apache Modules
if [ "$1" = "configure" ]; then


sudo a2enconf zoneminder
  . /etc/zm/zm.conf
sudo a2enmod rewrite
  for CONFFILE in /etc/zm/conf.d/*.conf; do
sudo a2enmod cgi
    . "$CONFFILE"
  done


Add your timezone to PHP
  # The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group
  chown www-data:root /var/log/zm
  chown www-data:www-data /var/lib/zm
  if [ -z "$2" ]; then
    chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/*
  fi
  if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then
    echo "The cgi module is not enabled in apache2.  I am enabling it using a2enmod cgi."
    a2enmod cgi
  fi
  if [ ! -e "/etc/apache2/mods-enabled/rewrite.load" ] && [ "$(command -v a2enmod)" != "" ]; then
    echo "The rewrite module is not enabled in apache2.  I am enabling it using a2enmod rewrite."
    a2enmod rewrite
  fi


Easy way
  if [ "$ZM_DB_HOST" = "localhost" ]; then


sed -i "s/;date.timezone =/date.timezone = $(sed 's/\//\\\//' /etc/timezone)/g" /etc/php/7.3/apache2/php.ini
    if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ] || [ -e "/etc/init.d/mysql" ]; then
      # Ensure zoneminder is stopped
      #deb-systemd-invoke stop zoneminder.service || exit $?
      service zoneminder stop


Long way
      #
      # Get mysql started if it isn't running
      #


sudo nano /etc/php/7.3/apache2/php.ini
      if [ -e "/lib/systemd/system/mariadb.service" ]; then
        DBSERVICE="mariadb.service"
      else
        DBSERVICE="mysql.service"
      fi
      echo "Detected db service is $DBSERVICE"


Search for [Date] (Ctrl + w then type Date and press Enter) and change date.timezone for your time zone. Don’t forget to remove the ; from in front of date.timezone.
        zmupdate.pl --nointeractive
        zmupdate.pl --nointeractive -f


[Date]
        # Add any new PTZ control configurations to the database (will not overwrite)
; Defines the default timezone used by the date functions
        zmcamtool.pl --import >/dev/null 2>&1
; http://php.net/date.timezone
        echo "Done Updating; starting ZoneMinder."
date.timezone = America/New_York
      else
        echo 'NOTE: MySQL/MariaDB not running; please start mysql and run dpkg-reconfigure zoneminder when it is running.'
      fi
    else
      echo 'MySQL/MariaDB not found; assuming remote server.'
    fi


CTRL+o then [Enter] to save
  else
    echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)."
  fi
#  deb-systemd-invoke restart zoneminder.service
  service zoneminder restart


CTRL+x to exit
</pre>


Restart Apache and start Zoneminder
==1.34 Version Notes==
See: https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive


  sudo service apache2 reload
==1.34 source build==
  sudo systemctl start zoneminder   
  git clone github.com/zoneminder/zoneminder
  OR
  cd zoneminder
  sudo service zoneminder restart
  apt-get install python-sphinx
  apt-get install libjpeg-dev
  apt-get install javascript-common libnet-sftp-foreign-perl libdevice-serialport-perl \
libimage-info-perl libjson-maybexs-perl liburi-encode-perl libdatetime-perl \
libclass-std-fast-perl libsoap-wsdl-perl libio-socket-multicast-perl \
libsys-cpu-perl  libsys-meminfo-perl libnumber-bytes-human-perl \
libfile-slurp-perl  php-apcu php-apc policykit-1 zip
./utils/do_debian_package.sh --distro=beowulf -s=stable -t=binary


You will also want to add the timezone to the Options page in the web console of ZM.
WIP

Latest revision as of 00:26, 4 March 2023

Tested today with a migration from a fresh Raspbian Buster which was migrated to Beowulf. I did it a roundabout way, but users should be able to follow the same instructions for Ascii here: Devuan Ascii with Zoneminder 1.32.3 from ZM Repo, except substituting release-1.34 for release in the zmrepo apt sources list. Please refer to zmrepo.zoneminder.com/debian for more details.

Make sure to add in the /etc/init.d/zoneminder file from Zoneminder_Init_Script


Log: tested update from Devuan Jessie to Beowulf: 2020/06

This is a guide for a Sysvinit based Devuan / Debian system. Debian Stretch / Devuan Ascii and Zoneminder Stable 1.34 from the ZMRepo. 1.35 is unstable (odd number).

Requirements:

  • Debian 10 | buster /sysvinit
  • Devuan Beowulf
  • Zoneminder 1.34

Install

install mariadb, apache2, php based on: https://www.howtoforge.com/tutorial/install-apache-with-php-and-mysql-lamp-on-debian-stretch/

apt-get install mariadb-server apache2 php7.3 libapache2-mod-php7.3

restart apache

service apache2 restart

Add zmrepo to /etc/apt/sources.list

deb https://zmrepo.zoneminder.com/debian/release-1.34/ buster/

NOTE: 1.34 is currently in release-1.34 folder on zmrepo. This is subject to change. Confirm it's there before installing.

NOTE: In order to make this guide, all the existing guides for Debian were parsed.

https://wiki.zoneminder.com/Debian_9_64-bit_with_Zoneminder_1.30.4_the_Easy_Way https://wiki.zoneminder.com/Debian_10_Buster_with_Zoneminder_1.34.x_from_ZM_Repo (these names are changed periodically, so refer to Debian) etc...

apt-get update
apt-get install apt-transport-https gnupg
wget -O - https://zmrepo.zoneminder.com/debian/archive-keyring.gpg | sudo apt-key add -
apt-get update
apt-get install zoneminder  vlc-plugin-base php7.3-gd
adduser www-data video
apt-get install zoneminder
a2enmod cgi
a2enmod rewrite
a2enconf zoneminder
chmod 740 /etc/zm/zm.conf
chown root:www-data /etc/zm/zm.conf
mysql -uroot -p < /usr/share/zoneminder/db/zm_create.sql
mysql -uroot -p -e "grant all on zm.* to 'zmuser'@localhost identified by 'zmpass';"
mysqladmin -uroot -p reload

The zmupdate.pl call may fail during install of zoneminder. Run it manually to update the db.

# zmupdate.pl

Then apt should complete successfully. Some systemctl commands will fail, but these can be ignored for now.

may need to set timezone in /etc/php/7.3/apache2/php.ini (and In 1.34 in zm web console options)

e.g. date.timezone America/New_York EDIT: actually, set the timezone in zoneminder. Because upon update of php, the new php won't have the TZ configured properly.



service apache2 restart

At this point, you will not have an /etc/init.d/ file for zoneminder

You must copy one from an existing install, or from 1.29 or 1.30.4. I'm going to put the init script from 1.30.4 in Zoneminder_Init_Script


after copying that in, and chmod +x /etc/init.d/zoneminder

zoneminder should start:

# service zoneminder start
Starting ZoneMinder: 01/27/2020 12:27:42.776878 zmpkg[2722].INF [main:57] [Command: start]
01/27/2020 12:27:42.778627 zmpkg[2722].INF [main:305] [Sanity checking States table...]
01/27/2020 12:27:42.780839 zmpkg[2722].INF [main:97] [Command: start]
01/27/2020 12:27:44.231615 zmpkg[2722].INF [main:205] [Single server configuration detected. Starting up services.]
success

double check by reviewing

ps auxw | grep zm


Now, navigate to the Apache server which hosts ZM gui at http://serverip/zm

Review syslog for any error messages.

Upgrading DB

NOTE: this covers DB upgrades only. Not upgrade steps. See install above for general upgrade.

If you are importing an existing db, now is a good time. Stop zm, and import the db.

service zoneminder stop
mysqldump -u root -p zm > dump.sql  (export old db) 
mysql -uroot -p zm < dump.sql  (import old db)

After this is done, you need to update the db

# zmupdate.pl

run this at least twice, as it tends to error out. If it's already updated, nothing new will happen.

you should see something like: Database upgrade to version 1.32.3 successful.

Then start zm

service zoneminder start

you might want to run zmaudit.pl to delete non existing events on the new install


Troubleshooting

  • zmupdate.pl if apt-get fails db upgrade during install of zoneminder.
  • You might have to install zoneminder again, instead of an update. Backup DB, and nothing will be lost.
  • if localhost/zm says 'page not found' check /etc/apache/conf-available/ which points to /usr/share/zoneminder/www and which may not have the correct permissions (needs apache / www-data user) with 0755 / chown root:www-data
  • also check that you enabled the conf in apache: a2enconf zoneminder
  • unable to connect to db driver missing, is an issue with multiple php versions - see forums. (a2dismod php7.0, a2enmod php7.3)

Postinstall script Errors

The /var/lib/dpkg/info/zoneminder.postinst script may fail due to lack of systemctl. The script can be edited similar to below to quiet the error messages (note: assumes an upgrade. Read the original script if you don't know what it's doing! Essentially, it's just stopping ZM, then running zmupdate.pl and changing possibly apache's zm config. )

#! /bin/sh

set +e

if [ "$1" = "configure" ]; then

  . /etc/zm/zm.conf
  for CONFFILE in /etc/zm/conf.d/*.conf; do
    . "$CONFFILE"
  done

  # The logs can contain passwords, etc... so by setting group root, only www-data can read them, not people in the www-data group
  chown www-data:root /var/log/zm
  chown www-data:www-data /var/lib/zm
  if [ -z "$2" ]; then
    chown www-data:www-data /var/cache/zoneminder /var/cache/zoneminder/*
  fi
  if [ ! -e "/etc/apache2/mods-enabled/cgi.load" ] && [ "$(command -v a2enmod)" != "" ]; then
    echo "The cgi module is not enabled in apache2.  I am enabling it using a2enmod cgi."
    a2enmod cgi
  fi
  if [ ! -e "/etc/apache2/mods-enabled/rewrite.load" ] && [ "$(command -v a2enmod)" != "" ]; then
    echo "The rewrite module is not enabled in apache2.  I am enabling it using a2enmod rewrite."
    a2enmod rewrite
  fi

  if [ "$ZM_DB_HOST" = "localhost" ]; then

    if [ -e "/lib/systemd/system/mysql.service" ] || [ -e "/lib/systemd/system/mariadb.service" ] || [ -e "/etc/init.d/mysql" ]; then
      # Ensure zoneminder is stopped
      #deb-systemd-invoke stop zoneminder.service || exit $?
      service zoneminder stop

      #
      # Get mysql started if it isn't running
      #

      if [ -e "/lib/systemd/system/mariadb.service" ]; then
        DBSERVICE="mariadb.service"
      else
        DBSERVICE="mysql.service"
      fi
      echo "Detected db service is $DBSERVICE"

        zmupdate.pl --nointeractive
        zmupdate.pl --nointeractive -f

        # Add any new PTZ control configurations to the database (will not overwrite)
        zmcamtool.pl --import >/dev/null 2>&1
        echo "Done Updating; starting ZoneMinder."
      else
        echo 'NOTE: MySQL/MariaDB not running; please start mysql and run dpkg-reconfigure zoneminder when it is running.'
      fi
    else
      echo 'MySQL/MariaDB not found; assuming remote server.'
    fi

  else
    echo "Not doing database upgrade due to remote db server ($ZM_DB_HOST)."
  fi
#  deb-systemd-invoke restart zoneminder.service
  service zoneminder restart

1.34 Version Notes

See: https://wiki.zoneminder.com/Using_a_dedicated_Hard_Drive

1.34 source build

git clone github.com/zoneminder/zoneminder
cd zoneminder
apt-get install python-sphinx
apt-get install libjpeg-dev
apt-get install javascript-common libnet-sftp-foreign-perl libdevice-serialport-perl \
libimage-info-perl libjson-maybexs-perl liburi-encode-perl libdatetime-perl \
libclass-std-fast-perl libsoap-wsdl-perl libio-socket-multicast-perl \
libsys-cpu-perl  libsys-meminfo-perl libnumber-bytes-human-perl \
libfile-slurp-perl  php-apcu php-apc policykit-1 zip
./utils/do_debian_package.sh --distro=beowulf -s=stable -t=binary

WIP