Skip to content

Latest commit

 

History

History
392 lines (276 loc) · 12.3 KB

install.cameras.ubuntu.24.04.md

File metadata and controls

392 lines (276 loc) · 12.3 KB

Instructions for installing Ubuntu 24.04 on cameras (the Zoneminder NVR system)

Note that this was the result of an install of 22.04 upgraded to 24.04 so it may not be perfect.

Base install and configs

NOTE: This did not set up the 2 drives the same way, so the data is redundant, but we can't boot off the second drive. Needs a rebuild, likely when I move to new hardware which can process more streams more efficiently.

  1. Install Ubuntu server as normal from an Ubuntu server install CD. I selected the minimal option for a headless server.

    Partition as follows, for both disks - which we're going to RAID.

    • /boot - 1GB (physical RAID)

    • rest (physical RAID)

      • Make this RAID LVM, partitioned as follows:

        /     - 100GB
        /tmp  - 50GB
        /var  - 100GB
        swap  - 10GB
        /home - rest
        

    When it asks for what to install, install "OpenSSH server" and leave everything else blank.

    Networking is already set up with a reserved DHCP lease on the router. It is accessible as cameras. No need for a static IP.

  2. After machine is up, edit /etc/apt/sources.list and make sure the following are enabled:

    Suites: noble noble-updates noble-backports
    Components: main restricted universe multiverse
    
    Suites: noble-security
    Components: main restricted universe multiverse
    

    (they were after install for me)

  3. Make sure all is up to date.

     sudo apt update
     sudo apt dist-upgrade
    
  4. Install more useful things

    sudo apt install net-tools tree atop nmap iotop emacs emacs-goodies-el elpa-go-mode elpa-rust-mode elpa-f elpa-let-alist elpa-markdown-mode elpa-yaml-mode elpa-flycheck lm-sensors ntp ssmtp gdisk git gitk iftop mailutils ppa-purge xsltproc smartmontools
    
  5. Add any necessary user accounts

  6. Set the timezone, if necessary:

    sudo timedatectl set-timezone America/New_York
    
  7. Make ssh work:

    1. For an old machine, use the old keys - you did save /etc, didn't you?

    2. For a new machine, use the new keys generated by the distro.

      • make sure to add to the firewall

        sudo ufw allow ssh
        
      • edit /etc/ssh/sshd_config and set:

        PermitRootLogin no
        
      • once you've set up public key auth, turn off password access - edit /etc/ssh/sshd_config and set

        PasswordAuthentication no
        
      • restart ssh to apply changes

        sudo service ssh restart
        
  8. Enable firewall, bit first, disable firewally logging (it can be quite verbose on a busy network), then turn on the firewall.

     sudo ufw logging off
     sudo ufw enable
    
  9. Set up sensors for ASUS i7 board (I forget the model)

    add the following to /etc/modules:

      coretemp
      i5500_temp
      w83627ehf
    
  10. Set up ssmtp

     cd /etc/ssmtp
     mv ssmtp.conf ssmtp.conf.old
     cp ~/system_stuff/ssmtp/ssmtp.conf .
     chgrp mail ssmtp.conf
    
  11. Add monitoring (sortof):

    make sure landscape is installed (to get landscape-sysinfo):

    sudo apt install landscape-common
    

    Then add the following to my crontab:

    @daily               /usr/bin/ntpq -p; echo; df -lh; echo; cat /proc/mdstat; landscape-sysinfo
    

Zoneminder basic set up:

  1. Refs:

  2. Install deps:

    sudo apt-get install tasksel
    sudo tasksel install web-server
    
  3. Add the PPA and do the basic install (TODO - this will eventually officially be released and we should change the PPA accordingly to get off the bleeding edge):

    sudo add-apt-repository ppa:iconnor/zoneminder-proposed
    sudo apt install zoneminder
    
  4. Fix some perms and ownership:

    sudo chmod 740 /etc/zm/zm.conf
    sudo chown root:www-data /etc/zm/zm.conf
    sudo chown -R www-data:www-data /usr/share/zoneminder/
    
  5. Enable apache modules Zoneminder config:

    sudo a2enmod cgi
    sudo a2enmod rewrite
    sudo a2enmod expires
    sudo a2enmod headers
    sudo a2enmod php8.3
    sudo a2enconf zoneminder
    sudo systemctl reload apache2
    
  6. Let it through the firewall

    sudo ufw allow http
    
  7. Enable and start zoneminder:

    sudo systemctl enable zoneminder
    sudo systemctl start zoneminder
    
  8. Reload apache:

    sudo systemctl reload apache2
    
  9. Going to http://cameras/zm should now work.

Configure the server

This is all under Options

All changes noted are from the defaults.

  1. System:

    1. LANG_DEFAULT = en_us
    2. DATE_FORMAT_PATTERN = yyyyMMdd
    3. TODO - enable logins
    4. OPT_USE_LEGACY_API_AUTH = unchecked
    • Because it's a new installation
    1. TIMEZONE = (GMT-05:00) America, New York
    2. OPT_CONTROL = unchecked
    • Because we don't have any PTZ cameras.
    1. TODO - OPT_TRIGGERS will be handy for SMTP uploads + triggers
    2. CHECK_FOR_UPDATES = unchecked
    • Redundant with the package manager having updates.
  2. API

    1. TODO - Per-user API is going to be useful.
  3. Email

    1. TODO - Various notifications here may be useful.
  4. Users

    1. TODO - Add users, then enable authentication.
  5. Because the server is set up with most of the space in /home:

    1. sudo mkdir /home/zm-storage
    2. sudo chown www-data:www-data /home/zm-storage
    3. Then go in and add it in Options->Storage. I called mine Bulk Storage.
    4. Do not delete the default storage It's still the default. We'll just set up cameras to not use it anymore.

Add Neolink

So Reolink wireless cameras work.

Compiling Neolink

I did this on my desktop, not the server. Since both run the same OS and it's a (mostly) statically compiled rust binary, I just plan to copy it over from dev box to server.

  1. Clone it from its repo:

    git clone https://github.com/thirtythreeforty/neolink.git
    
  2. Make sure rust and cargo are updated:

    rustup update
    
  3. Make sure dependencies are installed (this is non-exhaustive, these are just the ones I had to add)

    sudo apt install libgstreamer1.0-dev libgstreamer-plugins-bad1.0-dev libgstreamer-plugins-good1.0-dev libgstrtspserver-1.0-dev
    
  4. Then one can build it successfully with:

    cargo build
    

Install on server

  1. Install dependencies:

    sudo apt install libgstrtspserver-1.0-0 libgstreamer1.0-0  libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-good gstreamer1.0-plugins-bad
    
  2. Copy the binary over to the server.

  3. Copy over the sample_config.toml (I called it neolink_config.toml) and adjust as follows:

    1. Set bind to 127.0.0.1, because we don't need anyone other than this server to be able to get those streams.

    2. Because it's localhost access only, we're not going to bother with credentials or encryption, as there's little point when it's two daemons talking to each other across the same system bus.

    3. The cameras have limited user functionality, so their username is always admin. The password is saved in Keepass.

  4. Create a config section for each camera (see below).

  5. Set it up to start on boot

Installing on the server

Set up cameras

Reolink RLC-520A

Camera Config

  1. Connect it to power and network, let it boot up, then go to the router to see what MAC is has. Give it a static IP assignment on the router and reboot it. It should be at the new IP.

  2. Go to https:// and login. Default username is admin with no password.

  3. Configure the camera however. You like. Of note:

    1. https://support.reolink.com/hc/en-us/articles/360005238413-The-Difference-Between-Clear-Fluent-and-Balanced explains the difference between the different streams.
  4. Other settings to change on the camera from defaults:

    1. Camera:
      1. Display:
        1. Camera Name: Hide
        2. Date & Time: Hide
        3. Watermark: Off
        4. Anti-flicker: 60Hz
      2. Stream
        1. Set the Clear resolution to 2304*1296
          • Anything HD and better is good enough, and the more pixels, the more disk usage and CPU needed for processing.
          • Turning down the FPS is also a good way to save CPU time - 15 and over are good enough.
      3. Audio and Light
        1. Record Audio: On
      4. Info
        1. Set the name
    2. Surveillance:
      1. Record:
        1. Record: Off
      2. Email:
        1. Enable Email Alerts: Off
      3. FTP:
        1. Enable FTP: Off
      4. Push:
        1. Disable Push
    3. Network Settings -> Advanced drop down:
      1. Enable UID: Off
        1. We use this for the battery cameras, but not this type.
      2. Port Settings click "Set Up"
        1. RTSP: On
        2. ONVIF: Off
          • ONVIF autodiscovery didn't work, and I'm not going to mess with it right now. Might turn it on later.
    4. System:
      1. Maintenance:
        1. Auto Reboot: Off
      2. User Management:
        1. Set the admin password.
        2. Add another normal user for zoneminder.
          • Note that the password for the zoneminder user is passed in a URL, so can't contain special characters.
        • I saved both of these in Keepass.

Zoneminder Config

  1. Add the camera in Zoneminder as follows (only non-default values are noted):
    1. General:
      1. Function: Modect
      2. Reference Image Blend: 12.5% (Outdoor)
      3. Alarm Reference Image Blend: 12.5%
    2. Source:
      1. Source Path: rtsp://user:pass@hostname/h264Preview_01_main and replace hostname, user and pass appropriately.
      2. Method: UDP
      3. Capture Resolution 2560 x 1920 (Custom)
    3. Storage:
      1. Storage Area: Bulk Storage
      2. Video Writer: Camera Passthrough
      3. Tick the box to store audio too
    4. Timestamp
      1. Timestamp Label Format = %N - %Y%m%d %I:%M:%S %p
      2. Font Size = Extra Large

Reolink Argus Eco

Notes

  1. This is a battery powered camera.

  2. The only way I could figure out to do initial setup is with the app - this gets it connected to the network.

  3. It only works via the Neolink RTSP bridge software (see above).

  4. References: https://github.com/thirtythreeforty/neolink

Camera Config

  1. Set up the camera using the app - follow the voice prompts, scan the barcode, etc.

  2. Once it's connected to the router, you can set the static DHCP reservation and DNS - though we won't actually use it.

  3. In the app, configure it as follows (these are changes from default)

    1. Under Display:
      1. Camera Name: Hide
      2. Date: Hide
      3. Watermark: Off
    2. Camera Recording: Off
      1. There is no SD card.
    3. Email Alerts: Off
  4. In the neolink config, add a section like this:

    [[cameras]]
    name = "batterycamera1"
    username = "admin"
    password = "something super secret"
    uid = "ABCD01234567890EFG"
    stream = "mainStream"
    

Name should match what is set in the camera (but is probably not strictly necessary), username is always admin, password is what we set it to, and uid can be gotten from Device Info (which shows up if you tap on the gear icon and then the camera's name). stream can be either mainStream (which is the HD stream) or subStream (which is the low res stream).

Zoneminder Config

  1. Add the camera in Zoneminder as follows (only non-default values are noted):
    1. General:
      1. Function: Modect
      2. Reference Image Blend: 12.5% (Outdoor)
      3. Alarm Reference Image Blend: 12.5%
    2. Source:
      1. Source Path: rtsp://localhost:8554/camera-name replace camera-name with the camera name
      2. Method: UDP
      3. Capture Resolution 1080p
    3. Storage:
      1. Storage Area: Bulk Storage
      2. Video Writer: Camera Passthrough
      3. Tick the box to store audio too
    4. Timestamp
      1. Timestamp Label Format = %N - %Y%m%d %I:%M:%S %p
      2. Font Size = Extra Large