Fixed non working sed commands for devices section in the compose.yaml
This commit is contained in:
@@ -109,7 +109,7 @@ hardware_detection() {
|
|||||||
TARGET_GRAPHICS="false"
|
TARGET_GRAPHICS="false"
|
||||||
fi
|
fi
|
||||||
echo -e "\n\n 🔎 Detecting transconding acceleration on target host..."
|
echo -e "\n\n 🔎 Detecting transconding acceleration on target host..."
|
||||||
if ssh_to_host "ls /dev/dri/renderD128 2>/dev/null"; then
|
if ssh_to_host "ls /dev/dri/renderD128" 2>/dev/null; then
|
||||||
echo -e " ✅ Transcoding capable card detected."
|
echo -e " ✅ Transcoding capable card detected."
|
||||||
TARGET_GRAPHICS_RENDERER="true"
|
TARGET_GRAPHICS_RENDERER="true"
|
||||||
else
|
else
|
||||||
@@ -117,7 +117,7 @@ hardware_detection() {
|
|||||||
TARGET_GRAPHICS_RENDERER="false"
|
TARGET_GRAPHICS_RENDERER="false"
|
||||||
fi
|
fi
|
||||||
echo -e "\n\n 🔎 Detecting USB Google Coral TPU on target host..."
|
echo -e "\n\n 🔎 Detecting USB Google Coral TPU on target host..."
|
||||||
if ssh_to_host "lsusb | grep -iq 'google' 2>/dev/null"; then
|
if ssh_to_host "lsusb | grep -iq 'google'" 2>/dev/null; then
|
||||||
echo -e " ✅ USB Google Coral TPU detected."
|
echo -e " ✅ USB Google Coral TPU detected."
|
||||||
TARGET_USB_CORAL="true"
|
TARGET_USB_CORAL="true"
|
||||||
else
|
else
|
||||||
@@ -125,7 +125,7 @@ hardware_detection() {
|
|||||||
TARGET_USB_CORAL="false"
|
TARGET_USB_CORAL="false"
|
||||||
fi
|
fi
|
||||||
echo -e "\n\n 🔎 Detecting Zigbee coordinator on target host..."
|
echo -e "\n\n 🔎 Detecting Zigbee coordinator on target host..."
|
||||||
if ssh_to_host "ls /dev/serial/by-id/ | grep -i 'zigbee' 2>/dev/null"; then
|
if ssh_to_host "ls /dev/serial/by-id/ | grep -i 'zigbee'" 2>/dev/null; then
|
||||||
echo -e " ✅ Zigbee device found in /dev/serial/by-id/."
|
echo -e " ✅ Zigbee device found in /dev/serial/by-id/."
|
||||||
TARGET_ZIGBEE_DEVICE=$(ssh_to_host "ls /dev/serial/by-id/ | grep -i 'zigbee'")
|
TARGET_ZIGBEE_DEVICE=$(ssh_to_host "ls /dev/serial/by-id/ | grep -i 'zigbee'")
|
||||||
TARGET_ZIGBEE="true"
|
TARGET_ZIGBEE="true"
|
||||||
@@ -171,64 +171,26 @@ files_generation() {
|
|||||||
sed -i s+HOME_ROUTER_IP+$HOME_ROUTER_IP+g configuration.nix
|
sed -i s+HOME_ROUTER_IP+$HOME_ROUTER_IP+g configuration.nix
|
||||||
|
|
||||||
echo -e "\n\n ✅ Adapting the docker configuration to your hardware..."
|
echo -e "\n\n ✅ Adapting the docker configuration to your hardware..."
|
||||||
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" && "$TARGET_USB_CORAL" == "true" ]]; then
|
DEVICES_BLOCK=""
|
||||||
sed -i.bak '
|
if [[ "$TARGET_GRAPHICS_RENDERER" == "true" ]]; then
|
||||||
/^[[:space:]]*# ----------------------------------------- #/{
|
DEVICES_BLOCK+=" - /dev/dri/renderD128:/dev/dri/renderD128\n"
|
||||||
N;
|
|
||||||
/DEVICES SECTION WILL APPEAR HERE IF CORAL/{
|
|
||||||
N;
|
|
||||||
/TPU OR INTEGRATED GRAPHICS ARE PRESENT/{
|
|
||||||
N;
|
|
||||||
/----------------------------------------- #/c\
|
|
||||||
devices:\
|
|
||||||
- /dev/dri/renderD128:/dev/dri/renderD128\
|
|
||||||
- /dev/bus/usb:/dev/bus/usb
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' docker/frigate.nix
|
|
||||||
elif [[ "$TARGET_GRAPHICS_RENDERER" == "true" && "$TARGET_USB_CORAL" == "false" ]]; then
|
|
||||||
sed -i.bak '
|
|
||||||
/^[[:space:]]*# ----------------------------------------- #/{
|
|
||||||
N;
|
|
||||||
/DEVICES SECTION WILL APPEAR HERE IF CORAL/{
|
|
||||||
N;
|
|
||||||
/TPU OR INTEGRATED GRAPHICS ARE PRESENT/{
|
|
||||||
N;
|
|
||||||
/----------------------------------------- #/c\
|
|
||||||
devices:\
|
|
||||||
- /dev/dri/renderD128:/dev/dri/renderD128\
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' docker/frigate.nix
|
|
||||||
elif [[ "$TARGET_GRAPHICS_RENDERER" == "false" && "$TARGET_USB_CORAL" == "true" ]]; then
|
|
||||||
sed -i.bak '
|
|
||||||
/^[[:space:]]*# ----------------------------------------- #/{
|
|
||||||
N;
|
|
||||||
/DEVICES SECTION WILL APPEAR HERE IF CORAL/{
|
|
||||||
N;
|
|
||||||
/TPU OR INTEGRATED GRAPHICS ARE PRESENT/{
|
|
||||||
N;
|
|
||||||
/----------------------------------------- #/c\
|
|
||||||
devices:\
|
|
||||||
- /dev/bus/usb:/dev/bus/usb
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}' docker/frigate.nix
|
|
||||||
fi
|
fi
|
||||||
|
if [[ "$TARGET_USB_CORAL" == "true" ]]; then
|
||||||
|
DEVICES_BLOCK+=" - /dev/bus/usb:/dev/bus/usb\n"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ -n "$DEVICES_BLOCK" ]]; then
|
||||||
|
REPLACEMENT="devices:\n${DEVICES_BLOCK%\\n}"
|
||||||
|
sed -i.bak "s|# --- frigate devices --- #|$REPLACEMENT|" docker/frigate.nix
|
||||||
|
else
|
||||||
|
sed -i.bak "/# --- frigate devices --- #/d" docker/frigate.nix
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ "$TARGET_ZIGBEE" == "true" ]]; then
|
if [[ "$TARGET_ZIGBEE" == "true" ]]; then
|
||||||
sed -i.bak \
|
REPLACEMENT="devices:\n - /dev/serial/by-id/${TARGET_ZIGBEE_DEVICE}:/dev/ttyUSB0"
|
||||||
'/^[[:space:]]*# ----------------------------------- #/{
|
sed -i.bak "s|# --- hass devices --- #|$REPLACEMENT|" docker/hass.nix
|
||||||
N;
|
else
|
||||||
/DEVICES SECTION WILL APPEAR HERE IF/{
|
sed -i.bak "/# --- hass devices --- #/d" docker/hass.nix
|
||||||
N;
|
|
||||||
/ZIGBEE USB DEVICE IS PRESENT/{
|
|
||||||
N;
|
|
||||||
/----------------------------------- #/c\'"
|
|
||||||
devices:\
|
|
||||||
- /dev/serial/by-id/${TARGET_ZIGBEE_DEVICE}:/dev/ttyUSB0
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}" docker/hass.nix
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo -e "\n\n ✅ Copying files to the new installation..."
|
echo -e "\n\n ✅ Copying files to the new installation..."
|
||||||
|
|||||||
+1
-8
@@ -35,16 +35,9 @@ in
|
|||||||
environment:
|
environment:
|
||||||
FRIGATE_MQTT_USER: $FRIGATE_MQTT_USER
|
FRIGATE_MQTT_USER: $FRIGATE_MQTT_USER
|
||||||
FRIGATE_MQTT_PASSWORD: $FRIGATE_MQTT_PASSWORD
|
FRIGATE_MQTT_PASSWORD: $FRIGATE_MQTT_PASSWORD
|
||||||
# ----------------------------------------- #
|
# --- frigate devices --- #
|
||||||
# DEVICES SECTION WILL APPEAR HERE IF CORAL #
|
|
||||||
# TPU OR INTEGRATED GRAPHICS ARE PRESENT #
|
|
||||||
# ----------------------------------------- #
|
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.http.services.frigate.loadbalancer.server.port=8971
|
|
||||||
- traefik.http.services.frigate.loadbalancer.server.scheme=https
|
|
||||||
- traefik.http.routers.frigate-https.entrypoints=websecure
|
|
||||||
- traefik.http.routers.frigate-https.rule=Host(`cctv.$DOMAIN_NAME`)
|
|
||||||
- traefik.http.routers.frigate-https.tls=true
|
- traefik.http.routers.frigate-https.tls=true
|
||||||
- traefik.http.routers.frigate-https.tls.certresolver=cloudflare
|
- traefik.http.routers.frigate-https.tls.certresolver=cloudflare
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
+1
-4
@@ -24,10 +24,7 @@ in
|
|||||||
- ${config-dir}/config:/config
|
- ${config-dir}/config:/config
|
||||||
- /etc/localtime:/etc/localtime:ro
|
- /etc/localtime:/etc/localtime:ro
|
||||||
- /run/dbus:/run/dbus:ro
|
- /run/dbus:/run/dbus:ro
|
||||||
# ----------------------------------- #
|
# --- hass devices --- #
|
||||||
# DEVICES SECTION WILL APPEAR HERE IF #
|
|
||||||
# ZIGBEE USB DEVICE IS PRESENT #
|
|
||||||
# ----------------------------------- #
|
|
||||||
labels:
|
labels:
|
||||||
- traefik.enable=true
|
- traefik.enable=true
|
||||||
- traefik.http.services.home-assistant.loadbalancer.server.port=8123
|
- traefik.http.services.home-assistant.loadbalancer.server.port=8123
|
||||||
|
|||||||
Reference in New Issue
Block a user