Skip to content

Instantly share code, notes, and snippets.

@baudneo
Last active February 14, 2024 19:30
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save baudneo/d352c5a944a5d1371c9dfe455056e0a2 to your computer and use it in GitHub Desktop.
Save baudneo/d352c5a944a5d1371c9dfe455056e0a2 to your computer and use it in GitHub Desktop.
Ubuntu 22.04 - Build, install/upgrade ZoneMinder 1.37.x (DEV) branch

Prepare a build environment

  1. Provision and boot an ubuntu 22.04 installation (Bare metal or LXC), issue these commands to build a .deb package from ZM Dev branch.
apt update && apt dist-upgrade -y
apt install -y git curl gpg build-essential devscripts pkg-config cmake
wget https://raw.githubusercontent.com/ZoneMinder/zoneminder/master/utils/do_debian_package.sh
chmod +x do_debian_package.sh
mv do_debian_package.sh /usr/local/bin/zm-builder
mkdir ~/zm-build
cd ~/zm-build
git clone  --recurse-submodules https://github.com/zoneminder/zoneminder ZoneMinder_ZoneMinder.git
zm-builder --snapshot=NOW --type=local --dput=no --interactive=no

# It will ask to install all required dependancies (build and runtime).

NOTE: The ZoneMinder_ZoneMinder.git directory will house the ZM source code, on upgrades it will pull any new commits in.

The .deb packages will start being built, this may take some time depending on your hardware.

Several files will be in the build dir ~/zm-build, look for a file similar to: zoneminder_1.37.xx-{TIMESTAMP}-{RELEASE_NAME}-{ARCH}.deb

  • (TIMESTAMP} is the date of whenever that package was built by you
  • {RELEASE_NAME} is the name of the Ubuntu release (22.04 is jammy)
  • {ARCH} is the host architecture

Example ls output of the build dir after building .deb packages.

root@zm-test-lxc:~/zm-build# ll
total 52024
drwxr-xr-x 2 root root     4096 May 22 21:37 ./
drwx------ 6 root root     4096 May 22 21:30 ../
-rw-r--r-- 1 root root     5810 May 22 21:31 zoneminder-build-deps_1.37.40~20230522213038-jammy_amd64.buildinfo
-rw-r--r-- 1 root root     1327 May 22 21:31 zoneminder-build-deps_1.37.40~20230522213038-jammy_amd64.changes
-rw-r--r-- 1 root root 24524914 May 22 21:36 zoneminder-dbg_1.37.40~20230522213038-jammy_amd64.deb
-rw-r--r-- 1 root root  4931104 May 22 21:36 zoneminder-doc_1.37.40~20230522213038-jammy_all.deb
-rw-r--r-- 1 root root  2846925 May 22 21:37 zoneminder_1.37.40~20230522213038-jammy_amd64.build
-rw-r--r-- 1 root root    20346 May 22 21:36 zoneminder_1.37.40~20230522213038-jammy_amd64.buildinfo
-rw-r--r-- 1 root root     1969 May 22 21:36 zoneminder_1.37.40~20230522213038-jammy_amd64.changes
-rw-r--r-- 1 root root  5731506 May 22 21:36 zoneminder_1.37.40~20230522213038-jammy_amd64.deb
-rw-r--r-- 1 root root 15180697 May 22 21:30 zoneminder_1.37.40~20230522213038.orig.tar.gz

The file we are looking for in the example shown is zoneminder_1.37.40~20230522213038-jammy_amd64.deb. Obviously, your filename will differ from this. At a minimum, the timestamp will be different.

  1. Install ZoneMinder from the .deb package
cd ~/zm-build
apt install ./zoneminder_1.37.40~20230522213038-jammy_amd64.deb
  1. Enable Apache modules, zoneminder WWW config and restart apache2 for the changes to take effect.
a2enmod rewrite headers cgi
a2enconf zoneminder
systemctl restart apache2.service
  1. Setup TimeZone data for distro, php and mysql.

NOTE: All 3 must match or weird issues will occur!

  • Distro TZ setup
dpkg-reconfigure tzdata
  • MySQL TZ setup
    • Edit /etc/mysql/mysql.conf.d/mysqld.cnf and add this line to the file with your TZ data
default-time-zone='-06:00'
  • PHP/ZM TZ setup
    • Navigate to ZoneMinder web GUI @ http://<ZM host machine IP>/zm
    • Select "Options" in the top navigation bar, this will bring you to Options>System
    • Scrool down until you find TIMEZONE and set it to your TZ
  1. Enable/start zoneminder.service
systemctl enable zoneminder.service --now

How to update the ZoneMinder dev branch install

# Just cd into the build dir, remove old .deb packages (or keep them, they are timestamped) and run the shell script with those same args

# rm -f ~/zm-build/zoneminder*
cd ~/zm-build
zm-builder --snapshot=NOW --type=local --dput=no --interactive=no

# Wait for it to build, then install the .deb package

apt install ./zoneminder_1.37.XYZ-LMNOP.deb
@baudneo
Copy link
Author

baudneo commented May 23, 2023

Re-running the shell script will pull the ZM repo again (with any new commits) and build a .deb package for installation.

@connortechnology
Copy link

If you git clone to a directory called ZoneMinder_ZoneMinder.git it will use that instead of pulling fresh.

@baudneo
Copy link
Author

baudneo commented May 23, 2023

I'll integrate that into it this evening. I will also add the timezone stuff and enabling the apache mods/confs.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment