Major config fetching refactor

pull/2/head
riley 1 year ago
parent b092cf5333
commit c0c81ad1cd

@ -6,11 +6,11 @@ config frigate_config 'docker'
option storage './frigate/storage' option storage './frigate/storage'
config frigate_config 'mqtt' config frigate_config 'mqtt'
option mqtt '0' option enabled '0'
option host 'mqtt.server.com' option host 'mqtt.server.com'
config frigate_config 'detectors' config frigate_config 'tpu'
option coral '1' option enabled '1'
option type 'edgetpu' option type 'edgetpu'
option device 'usb' option device 'usb'

@ -10,28 +10,48 @@ get_image() {
} }
do_install_detail() { do_install_detail() {
local config port IMAGE_NAME username password LAN_IP local config port IMAGE_NAME LAN_IP
local usbcoral hwaccel storage mqtt host coral type device local usbcoral hwaccel storage mqtt host coral type device
port=$(uci get frigate.@frigate_config[0].port 2>/dev/null) echo "Fetching port from configuration..."
IMAGE_NAME=$(uci get frigate.@frigate_config[0].image 2>/dev/null) port=$(uci get frigate.docker.port 2>/dev/null)
usbcoral=$(uci get frigate.@frigate_config[0].usbcoral 2>/dev/null) [ -z "$port" ] && { echo "Error: Port not found in configuration."; exit 1; }
hwaccel=$(uci get frigate.@frigate_config[0].hwaccel 2>/dev/null)
storage=$(uci get frigate.@frigate_config[0].storage 2>/dev/null)
mqtt=$(uci get frigate.@frigate_config[0].mqtt 2>/dev/null) echo "Fetching image name from configuration..."
host=$(uci get frigate.@frigate_config[0].host 2>/dev/null) IMAGE_NAME=$(uci get frigate.docker.image 2>/dev/null)
[ -z "$IMAGE_NAME" ] && { echo "Error: Image name not found in configuration."; exit 1; }
coral=$(uci get frigate.@frigate_config[0].coral 2>/dev/null) echo "Fetching USB Coral path from configuration..."
type=$(uci get frigate.@frigate_config[0].type 2>/dev/null) usbcoral=$(uci get frigate.docker.usbcoral 2>/dev/null)
device=$(uci get frigate.@frigate_config[0].device 2>/dev/null) [ -z "$usbcoral" ] && { echo "Error: USB Coral path not found in configuration."; exit 1; }
username=$(uci get frigate.@frigate_config[0].username 2>/dev/null) echo "Fetching hardware acceleration path from configuration..."
password=$(uci get frigate.@frigate_config[0].password 2>/dev/null) hwaccel=$(uci get frigate.docker.hwaccel 2>/dev/null)
APP_NAME="frigate" [ -z "$hwaccel" ] && { echo "Error: Hardware acceleration path not found in configuration."; exit 1; }
echo "Fetching storage path from configuration..."
storage=$(uci get frigate.docker.storage 2>/dev/null)
[ -z "$storage" ] && { echo "Error: Storage path not found in configuration."; exit 1; }
echo "Fetching MQTT status from configuration..."
mqtt=$(uci get frigate.mqtt.enabled 2>/dev/null)
[ -z "$mqtt" ] && { echo "Error: MQTT status not found in configuration."; exit 1; }
echo "Fetching MQTT host from configuration..."
host=$(uci get frigate.mqtt.host 2>/dev/null)
[ -z "$host" ] && { echo "Error: MQTT host not found in configuration."; exit 1; }
GEN_PASS=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 14; echo) echo "Fetching Coral status from configuration..."
GEN_PASS2=$(< /dev/urandom tr -dc A-Za-z0-9 2>/dev/null | head -c 14; echo) coral=$(uci get frigate.detectors.coral 2>/dev/null)
[ -z "$coral" ] && { echo "Error: Coral status not found in configuration."; exit 1; }
echo "Fetching Coral type from configuration..."
type=$(uci get frigate.detectors.type 2>/dev/null)
[ -z "$type" ] && { echo "Error: Coral type not found in configuration."; exit 1; }
echo "Fetching Coral device from configuration..."
device=$(uci get frigate.detectors.device 2>/dev/null)
[ -z "$device" ] && { echo "Error: Coral device not found in configuration."; exit 1; }
LAN_IP=$(uci get network.lan.ipaddr) LAN_IP=$(uci get network.lan.ipaddr)
LAN_IP="${LAN_IP%/*}" LAN_IP="${LAN_IP%/*}"
@ -44,16 +64,6 @@ do_install_detail() {
mkdir -p /opt/docker2/compose/frigate mkdir -p /opt/docker2/compose/frigate
touch /opt/docker2/compose/frigate/config.yml touch /opt/docker2/compose/frigate/config.yml
# Write global settings to config.yml using yq
# Replace these uci get commands with actual commands to get these variables
local usbcoral=$(uci get frigate.@frigate_config[0].usbcoral)
local hwaccel=$(uci get frigate.@frigate_config[0].hwaccel)
local storage=$(uci get frigate.@frigate_config[0].storage)
local mqtt=$(uci get frigate.@frigate_config[0].mqtt)
local host=$(uci get frigate.@frigate_config[0].host)
local coral=$(uci get frigate.@frigate_config[0].coral)
local type=$(uci get frigate.@frigate_config[0].type)
yq eval ".usbcoral = \"$usbcoral\"" -i /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 ".hwaccel = \"$hwaccel\"" -i /opt/docker2/compose/frigate/config.yml
yq eval ".storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml yq eval ".storage = \"$storage\"" -i /opt/docker2/compose/frigate/config.yml

Loading…
Cancel
Save