|
|
@ -59,48 +59,6 @@ do_install_detail() {
|
|
|
|
[ -z "$port" ] && port=1880
|
|
|
|
[ -z "$port" ] && port=1880
|
|
|
|
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="ghcr.io/blakeblackshear/frigate:stable"
|
|
|
|
[ -z "$IMAGE_NAME" ] && IMAGE_NAME="ghcr.io/blakeblackshear/frigate:stable"
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize counter
|
|
|
|
|
|
|
|
local i=0
|
|
|
|
|
|
|
|
mkdir -p /opt/docker2/compose/frigate
|
|
|
|
|
|
|
|
touch /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
yq eval ".usbcoral = \"$usbcoral\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".mqtt.enabled = $mqtt" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".mqtt.host = \"$host\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".detectors.coral.type = \"$type\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".detectors.coral.device = \"$coral\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Write each camera's configuration to config.yml
|
|
|
|
|
|
|
|
local camera_index=0
|
|
|
|
|
|
|
|
while : ; do
|
|
|
|
|
|
|
|
# Try to fetch camera configuration
|
|
|
|
|
|
|
|
local name=$(uci get frigate.@camera_config[$camera_index].name 2>/dev/null)
|
|
|
|
|
|
|
|
# Exit loop if no more cameras are found
|
|
|
|
|
|
|
|
[[ -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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Write to config.yml using yq
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs[0].path = \"$path\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg.inputs[0].roles[0] = \"detect\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.detect.width = 1280" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.detect.height = 720" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.record.enabled = $record" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.snapshots.enabled = $snapshots" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.motion.mask[0] = \"$mask\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
camera_index=$((camera_index+1))
|
|
|
|
|
|
|
|
done
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
rm -r /opt/docker2/compose/frigate 2>/dev/null
|
|
|
|
rm -r /opt/docker2/compose/frigate 2>/dev/null
|
|
|
|
mkdir -p /opt/docker2/compose/frigate
|
|
|
|
mkdir -p /opt/docker2/compose/frigate
|
|
|
|
|
|
|
|
|
|
|
@ -137,6 +95,49 @@ services:
|
|
|
|
FRIGATE_RTSP_PASSWORD: "password"
|
|
|
|
FRIGATE_RTSP_PASSWORD: "password"
|
|
|
|
EOF
|
|
|
|
EOF
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize the base structure
|
|
|
|
|
|
|
|
echo "{}" > /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Set global configurations
|
|
|
|
|
|
|
|
yq eval ".usbcoral = \"$usbcoral\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".mqtt.enabled = $mqtt" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".mqtt.host = \"$host\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".detectors.coral.type = \"$type\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".detectors.coral.device = \"$coral\"" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize cameras structure
|
|
|
|
|
|
|
|
yq eval ".cameras = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Write each camera's configuration to config.yml
|
|
|
|
|
|
|
|
local camera_index=0
|
|
|
|
|
|
|
|
while : ; do
|
|
|
|
|
|
|
|
# Try to fetch camera configuration
|
|
|
|
|
|
|
|
local name=$(uci get frigate.@camera_config[$camera_index].name 2>/dev/null)
|
|
|
|
|
|
|
|
# Exit loop if no more cameras are found
|
|
|
|
|
|
|
|
[[ -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)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Initialize camera structure
|
|
|
|
|
|
|
|
yq eval ".cameras.$name = {}" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Write to config.yml using yq
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.ffmpeg = { inputs: [{ path: \"$path\", roles: [\"detect\"] }] }" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.detect = { width: 1280, height: 720 }" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.record = { enabled: $record }" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.snapshots = { enabled: $snapshots }" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
yq eval ".cameras.$name.motion = { mask: [\"$mask\"] }" -i /opt/docker2/compose/frigate/config.yml
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
uci add shortcutmenu lists
|
|
|
|
uci add shortcutmenu lists
|
|
|
@ -174,7 +175,7 @@ case "${ACTION}" in
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
"start" | "stop" | "restart")
|
|
|
|
"start" | "stop" | "restart")
|
|
|
|
APP_NAME="frigate"
|
|
|
|
APP_NAME="frigate"
|
|
|
|
CONTAINER_IDS=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.ID}}')
|
|
|
|
CONTAINER_IDS=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.ID}}')
|
|
|
|
for ID in $CONTAINER_IDS; do
|
|
|
|
for ID in $CONTAINER_IDS; do
|
|
|
|
docker "${ACTION}" "${ID}"
|
|
|
|
docker "${ACTION}" "${ID}"
|
|
|
|
done
|
|
|
|
done
|
|
|
@ -184,18 +185,18 @@ case "${ACTION}" in
|
|
|
|
CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
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" }')
|
|
|
|
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
|
|
|
|
if [ -z "$CONTAINER_NAME" ]; then
|
|
|
|
echo "${APP_NAME} is not installed"
|
|
|
|
echo "${APP_NAME} is not installed"
|
|
|
|
else
|
|
|
|
else
|
|
|
|
echo "${CONTAINER_STATUS}"
|
|
|
|
echo "${CONTAINER_STATUS}"
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
"port")
|
|
|
|
"port")
|
|
|
|
APP_NAME="frigate"
|
|
|
|
APP_NAME="frigate"
|
|
|
|
CONTAINER_NAMES=$(docker ps -a --filter "ancestor=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
CONTAINER_NAME=$(docker ps -a --filter "name=${APP_NAME}" --format '{{.Names}}')
|
|
|
|
docker ps --all -f "name=${CONTAINER_NAMES}" --format '{{.Ports}}' | grep -o -m1 '0.0.0.0:[0-9]*' | sed 's/0.0.0.0://'
|
|
|
|
# Fetch the port from UCI configuration
|
|
|
|
;;
|
|
|
|
uci_port=$(uci get frigate.docker.port 2>/dev/null)
|
|
|
|
*)
|
|
|
|
[ -z "$uci_port" ] && exit 1 # Exit silently if UCI port is not found
|
|
|
|
usage
|
|
|
|
# Use the UCI port to filter the docker ps output and return only the external port
|
|
|
|
exit 1
|
|
|
|
docker ps --all -f "name=${CONTAINER_NAME}" --format '{{.Ports}}' | grep -o "0.0.0.0:$uci_port->[0-9]*/tcp" | sed "s/0.0.0.0://;s/->[0-9]*\/tcp//"
|
|
|
|
;;
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
esac
|