From c2325242b3c325b902e6025a99300832a1fb75ba Mon Sep 17 00:00:00 2001 From: MacRimi <123239993+MacRimi@users.noreply.github.com> Date: Fri, 31 Jan 2025 20:20:54 +0100 Subject: [PATCH] Update install_coral_lxc.sh --- scripts/install_coral_lxc.sh | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/scripts/install_coral_lxc.sh b/scripts/install_coral_lxc.sh index 8e7c087..d249802 100644 --- a/scripts/install_coral_lxc.sh +++ b/scripts/install_coral_lxc.sh @@ -75,22 +75,19 @@ select_container() { } +# Validate that the selected container is valid validate_container_id() { if [ -z "$CONTAINER_ID" ]; then msg_error "$(translate 'Container ID not defined. Make sure to select a container first.')" exit 1 fi - + # Check if the container is running and stop it before configuration if pct status "$CONTAINER_ID" | grep -q "running"; then msg_info "$(translate 'Stopping the container before applying configuration...')" pct stop "$CONTAINER_ID" msg_ok "$(translate 'Container stopped.')" fi - if [ -z "$CONTAINER_ID" ]; then - msg_error "$(translate 'Container ID not defined. Make sure to select a container first.')" - exit 1 - fi } @@ -116,19 +113,6 @@ configure_lxc_hardware() { msg_ok "$(translate 'The container is already privileged.')" fi - # Configure Coral TPU (USB and M.2) - if ! grep -Pq "^lxc.cgroup2.devices.allow: c 189:\* rwm # Coral USB$" "$CONFIG_FILE"; then - echo "lxc.cgroup2.devices.allow: c 189:* rwm # Coral USB" >> "$CONFIG_FILE" - fi - - if ! grep -Pq "^lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dir$" "$CONFIG_FILE"; then - echo "lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dir" >> "$CONFIG_FILE" - fi - - if ! grep -Pq "^lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=file$" "$CONFIG_FILE"; then - echo "lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=file" >> "$CONFIG_FILE" - fi - # Configure iGPU if ! grep -q "features: nesting=1" "$CONFIG_FILE"; then echo "features: nesting=1" >> "$CONFIG_FILE" @@ -149,6 +133,19 @@ configure_lxc_hardware() { echo "lxc.mount.entry: /dev/fb0 dev/fb0 none bind,optional,create=file" >> "$CONFIG_FILE" fi + # Configure Coral TPU (USB and M.2) + if ! grep -Pq "^lxc.cgroup2.devices.allow: c 189:\* rwm # Coral USB$" "$CONFIG_FILE"; then + echo "lxc.cgroup2.devices.allow: c 189:* rwm # Coral USB" >> "$CONFIG_FILE" + fi + + if ! grep -Pq "^lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dir$" "$CONFIG_FILE"; then + echo "lxc.mount.entry: /dev/bus/usb dev/bus/usb none bind,optional,create=dir" >> "$CONFIG_FILE" + fi + + if ! grep -Pq "^lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=file$" "$CONFIG_FILE"; then + echo "lxc.mount.entry: /dev/apex_0 dev/apex_0 none bind,optional,create=file" >> "$CONFIG_FILE" + fi + msg_ok "$(translate 'Coral TPU and iGPU configuration added to container') $CONTAINER_ID." }