Armbian

Machinery

Install package

Update system and install dependency avcodec. These installation instructions assume that a fresh Armbian 5.24 or 5.25 installed.

sudo apt-get update && sudo apt-get install libav-tools

Download the debian file from the machinery repository; This should work on all Armbian supported boards. If not: inform us!.

sudo wget https://github.com/kerberos-io/machinery/releases/download/v2.3.1/armbian-machinery-kerberosio-armhf-2.3.1.deb

Unpackage the file

sudo dpkg -i armbian-machinery-kerberosio-armhf-2.3.1.deb     

Start the machinery on start-up, and reboot the system.

 sudo systemctl enable kerberosio && sudo reboot

Configure

The configuration files can be found at /etc/opt/kerberosio/config. By default the Raspberry Pi Camera module is set as capture device. This must be changed in the config.xml to USBCamera or IPCamera depending on your camera. Images / videos are stored in the /etc/opt/kerberosio/capture directory by default; this location can be changed by editing the io.xml file.

Run

After kerberos is installed a binary is available at /usr/bin/kerberosio. Just run following command in your terminal to start kerberosio

kerberosio

In case kerberosio does not start and complains about missing libraries, install the following libraries.

sudo apt-get install pkg-config libavcodec-dev libavformat-dev libswscale-dev

Web

Install webserver + PHP (optional)

Add Raspbian package repo and update the packages and kernel.

echo "deb http://mirrordirector.raspbian.org/raspbian/ stretch main contrib non-free rpi" | sudo tee --append /etc/apt/sources.list
sudo apt-get update && sudo apt-get upgrade

Install Nginx and PHP (+extension).

sudo apt-get install nginx php7.0 php7.0-curl php7.0-gd php7.0-fpm php7.0-cli php7.0-opcache php7.0-mbstring php7.0-xml php7.0-zip php7.0-mcrypt nodejs npm

Creating a Nginx config.

sudo rm -f /etc/nginx/sites-enabled/default
sudo nano /etc/nginx/sites-enabled/default

Copy and paste following config file; this file tells nginx where the web will be installed and that it requires PHP.

server
{
    listen 80 default_server;
    listen [::]:80 default_server;
    root /var/www/web/public;
    index index.html index.htm index.nginx-debian.html;
    server_name kerberos.rpi kerberos.rpi;
    index index.php index.html index.htm;
    location /
    {
            autoindex on;
            try_files $uri $uri/ /index.php?$query_string;
    }
    location ~ \.php$
    {
            fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
    }
}

Restart nginx and reboot system

sudo service nginx restart && sudo reboot

Install source

Create a www location.

sudo mkdir -p /var/www/web && cd /var/www/web

Get the source code from Github.

sudo wget https://github.com/kerberos-io/web/releases/download/v2.3.2/web.tar.gz

Unpack

sudo tar xvf web.tar.gz

Change write permission on the storage directory.

sudo chmod -R 777 storage
sudo chmod -R 777 bootstrap/cache
sudo chmod 777 config/kerberos.php

Reboot

sudo reboot

Auto removal

By default images or videos aren't removed automatically. This means that Kerberos.io will keep writing to disk, even if there is no more space available on your SD card. When your SD card is full you'll be experiencing strange errors: a corrupt web interface, blank images or corrupt videos.

To resolve this your should install a simple bash script and initiate a cronjob which continuously poll your filesystem, and start removing media when your disk is getting full.

Create a bash script and copy following script.

nano /home/pi/autoremoval.sh

Copy following script (make sure the partition is correct, this is the default one for a Raspberry Pi).

partition=/dev/root
imagedir=/etc/opt/kerberosio/capture/
if [[ $(df -h | grep $partition | head -1 | awk -F' ' '{ print $5/1 }' | tr ['%'] ["0"]) -gt 90 ]];
then
    echo "Cleaning disk"
    find $imagedir -type f | sort | head -n 100 | xargs -r rm -rf;
fi;

Make the script executable.

chmod +x /home/pi/autoremoval.sh

Initiate a cronjob, and select the nano editor.

crontab -e

Append following line, to execute the autoremoval.sh script every 5min.

*/5 * * * * /bin/bash /home/pi/autoremoval.sh