From d4e05a6da9094e9bf5e9dffeb7d2d60ad90a05e6 Mon Sep 17 00:00:00 2001 From: Allen Hill Date: Mon, 22 Jun 2026 17:33:58 -0700 Subject: [PATCH] Update devcontainer startup to consistently chown passed-thru usb devices --- .devcontainer/devcontainer.json | 1 + scripts/chown-usb.sh | 6 ++++++ scripts/install-toolchain.sh | 7 +------ 3 files changed, 8 insertions(+), 6 deletions(-) create mode 100755 scripts/chown-usb.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8587b77..611bfe3 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -10,6 +10,7 @@ // "forwardPorts": [], // Use 'postCreateCommand' to run commands after the container is created. "postCreateCommand": "bash scripts/install-toolchain.sh", + "postAttachCommand": "bash scripts/chown-usb.sh", // Configure tool-specific properties. "customizations": { "vscode": { diff --git a/scripts/chown-usb.sh b/scripts/chown-usb.sh new file mode 100755 index 0000000..08784af --- /dev/null +++ b/scripts/chown-usb.sh @@ -0,0 +1,6 @@ +if [[ -c /dev/ttyUSB0 ]]; then + sudo chown root:$(id -gn $(whoami)) /dev/ttyUSB0 +fi +if [[ -c /dev/ttyUSB1 ]]; then + sudo chown root:$(id -gn $(whoami)) /dev/ttyUSB1 +fi diff --git a/scripts/install-toolchain.sh b/scripts/install-toolchain.sh index fe1a10a..f4db467 100644 --- a/scripts/install-toolchain.sh +++ b/scripts/install-toolchain.sh @@ -1,7 +1,2 @@ sudo apk add make cmake avrdude avr-libc gcc-avr -if [[ -c /dev/ttyUSB0 ]]; then - sudo chown root:$(id -gn $(whoami)) /dev/ttyUSB0 -fi -if [[ -c /dev/ttyUSB1 ]]; then - sudo chown root:$(id -gn $(whoami)) /dev/ttyUSB1 -fi +