#!/bin/bash

read -p "going to: https://github.com/scottlamb/moonfire-nvr/blob/master/guide/install.md as /etc/moonfire-nvr.toml"
echo '
[[binds]]
ipv4 = "0.0.0.0:29898"
allowUnauthenticatedPermissions = { viewVideo = true }

[[binds]]
unix = "/var/lib/moonfire-nvr/sock"
ownUidIsPrivileged = true
' | sudo tee /etc/moonfire-nvr.toml

sudo mkdir -p /var/lib/moonfire-nvr
sudo chmod -R 777 /var/lib/moonfire-nvr

moonfire-nvr init

read -p "1. create a SAMPLE DIR first,"
read -p "2. use like rtsp://192.168.0.83:8554/unicast with RECORD and DIR for MAIN and SUB"
read -p "3. modify SAMPLE DIR to retain N Mbps_/_8_*_120s disk (wyze at home is 5Mbps, so 75MB per 2min file (54GB per day) if noisy?)"
moonfire-nvr config

open http://localhost:29898
read -p "moonfire-nvr run"
