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 +