|
|
|
@ -119,11 +119,11 @@ EOF
|
|
|
|
|
[[ -z "$name" ]] && break
|
|
|
|
|
|
|
|
|
|
# Retrieve the rest of the camera settings here...
|
|
|
|
|
local path=$(uci get frigate.@camera_config[$camera_index].path)
|
|
|
|
|
local roles=$(uci get frigate.@camera_config[$camera_index].roles)
|
|
|
|
|
local record=$(uci get frigate.@camera_config[$camera_index].record)
|
|
|
|
|
local snapshots=$(uci get frigate.@camera_config[$camera_index].snapshots)
|
|
|
|
|
local mask=$(uci get frigate.@camera_config[$camera_index].mask)
|
|
|
|
|
local path=$(uci get frigate.@camera_config[$camera_index].path 2>/dev/null)
|
|
|
|
|
local roles=$(uci get frigate.@camera_config[$camera_index].roles 2>/dev/null)
|
|
|
|
|
local record=$(uci get frigate.@camera_config[$camera_index].record 2>/dev/null)
|
|
|
|
|
local snapshots=$(uci get frigate.@camera_config[$camera_index].snapshots 2>/dev/null)
|
|
|
|
|
local mask=$(uci get frigate.@camera_config[$camera_index].mask 2>/dev/null)
|
|
|
|
|
|
|
|
|
|
# Initialize camera structure
|
|
|
|
|
yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
@ -133,7 +133,7 @@ EOF
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs = []" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
# Add path and roles to the inputs
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs[0].path = $path" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs[0].path = \"$path\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs[0].roles = [\"detect\"]" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
# Add other camera settings
|
|
|
|
@ -147,13 +147,19 @@ EOF
|
|
|
|
|
yq eval ".cameras.$name.snapshots = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
yq eval ".cameras.$name.snapshots.enabled = $snapshots" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
# Check if the mask is not empty
|
|
|
|
|
if [ -n "$mask" ]; then
|
|
|
|
|
# Run the yq commands to update the YAML file
|
|
|
|
|
yq eval ".cameras.$name.motion = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
yq eval ".cameras.$name.motion.mask = [\"$mask\"]" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
else
|
|
|
|
|
echo "Mask is empty, ignoring."
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
camera_index=$((camera_index+1))
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
docker-compose -f /opt/docker2/compose/frigate/docker-compose.yml up -d
|
|
|
|
|
docker-compose -f /opt/docker2/compose/frigate/docker-compose.yml up -d --force-recreate
|
|
|
|
|
|
|
|
|
|
uci add shortcutmenu lists
|
|
|
|
|
uci set shortcutmenu.@lists[-1].webname="$APP_NAME"
|
|
|
|
@ -189,14 +195,12 @@ case "${ACTION}" in
|
|
|
|
|
rm -r /opt/docker2/compose/frigate 2>/dev/null
|
|
|
|
|
;;
|
|
|
|
|
"start" | "stop" | "restart")
|
|
|
|
|
APP_NAME="frigate"
|
|
|
|
|
CONTAINER_IDS=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.ID}}')
|
|
|
|
|
for ID in $CONTAINER_IDS; do
|
|
|
|
|
docker "${ACTION}" "${ID}"
|
|
|
|
|
done
|
|
|
|
|
;;
|
|
|
|
|
"status")
|
|
|
|
|
APP_NAME="frigate"
|
|
|
|
|
CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
|
CONTAINER_STATUS=$(docker ps --all --filter "name=${CONTAINER_NAME}" --format '{{.Status}}' | awk '/^Up/ { print "up " substr($0, 4) } !/^Up/ && /.+/ { print "down" }')
|
|
|
|
|
if [ -z "$CONTAINER_NAME" ]; then
|
|
|
|
@ -206,7 +210,6 @@ case "${ACTION}" in
|
|
|
|
|
fi
|
|
|
|
|
;;
|
|
|
|
|
"port")
|
|
|
|
|
APP_NAME="frigate"
|
|
|
|
|
CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
|
# Fetch the port from UCI configuration
|
|
|
|
|
uci_port=$(uci get frigate.docker.port 2>/dev/null)
|
|
|
|
|