## Description ##
An iSpy (DVR) server resource for running it on RockyLinux 9.x


## Installation ##
<details>
<summary>To setup your iSpy/DVR server start out with a fresh RockyLinux 9.x server/vps/LXC -  i use a ProxMox (https://www.proxmox.com/en/proxmox-ve) LXC,
and will assumes that your server has:</summary>
  
* (atleast) 4Gb of memory available.<br>
* If you have firewall running enable Default HTTP(80),STUN(3478 both TCP/UDP) and 50000-50010 (both TCP/UDP) for sessions open in firewall.<br>
* SSH acccess to the box -> by default the ProxMox RockyLinux 9.x template does not have openssh-server package installed, so manually add it.<br>

Out of scope:
* reverse proxy with SSL in front of iSpy/DVR to make it available on default HTTPS port.(these capabillities are licenced options).<br>


</details>
</br>


###### Install/Enable additional repositories (epel) and packages.
```
dnf install epel-release
dnf makecache
dnf install wget nano nginx unzip tar xz
```

###### Setup nginx directories for multisite as it makes it more versatile, reference: [https://docs.rockylinux.org/guides/web/nginx-multisite/](https://docs.rockylinux.org/guides/web/nginx-multisite/)


###### Create a nginx configuration-file for the DVR resource in /etc/nginx/sites-available/ with the following content.
```
server {
    listen 80;
    server_name your.server.name.sometld;
    location / {
        proxy_pass http://localhost:8090;

        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}
```

###### Enable the above configuration to be loaded on nginx startup
```
ln -s /etc/nginx/sites-available/your_configfile.conf /etc/nginx/sites-enabled/
```

###### Download and execute the dvr Agent installation, and set it as system service. (this also creates the AgentDVR directory)
```
cd /opt
bash <(curl -s "https://raw.githubusercontent.com/ispysoftware/agent-install-scripts/main/v2/install.sh")

# lots of packages are going to be installed - skipping this in output.

To run Agent either call ./Agent from the terminal or install it as a system service.
Setup AgentDVR as system service (y/n)? y
```

###### Setup ffmpeg6 directory manually (i never got a good result with DVR installer, just an empty directory)
```
cd /opt/AgentDVR
mkdir ffmpeg6
wget -O ffmpeg.tar.xz https://ispyrtcdata.blob.core.windows.net/downloads/ffmpeg6-linuxx64.tar.xz
tar -xvf ffmpeg.tar.xz --strip-components=1 -C ffmpeg6
```

###### Start and enable the AgentDVR service
```
systemctl enable AgentDVR --now
```

At this point the AgentDVR shoult be running on port 8090, you can check this with the command below, or just point a browser to http://yourserver:8090 , assuming you have allowed this port in the firewall.
```
ss -at '( dport = :8090 or sport = :8090 )'

# result should be similar to below

State       Recv-Q      Send-Q           Local Address:Port                   Peer Address:Port     Process
LISTEN      0           500                    0.0.0.0:opsmessaging                0.0.0.0:*
```

###### Start nginx to make the application available on the default HTTP port.
```
systemctl enable nginx --now
```

**You now have a basic working iSpy/AgentDVR installation accessible via http://yourserver**