diff --git a/docker/Makefile b/docker/Makefile index dc7b7f8db8..271ac50ab1 100644 --- a/docker/Makefile +++ b/docker/Makefile @@ -8,7 +8,6 @@ help: @echo " 1. make pull - pull all pprz images" @echo " 1. make clean - remove all pprz images" @echo " 2. make bash - run bash on pprz-dev" - @echo " 2. make bash_usb - run bash and enable USB" @echo " 2. make paparazzi - run paparazzi center on pprz-dev" @echo "" @@ -27,9 +26,5 @@ clean: bash: @bash run.sh -i -t flixr/pprz-dev bash -bash_usb: - @ENABLE_USB=1 bash ./run.sh -i -t flixr/pprz-dev bash - - paparazzi: @bash run.sh -i -t flixr/pprz-dev ./paparazzi diff --git a/docker/run.sh b/docker/run.sh index 92c2f8d02a..f6d1acb15b 100755 --- a/docker/run.sh +++ b/docker/run.sh @@ -34,11 +34,21 @@ PULSE_AUDIO_OPTS="--volume=/run/user/${USER_UID}/pulse:/run/pulse" # give the container access to USB, WARNING runs it as priviliged container! # use it if ENABLE_USB variable is non-empty/zero -if [ -n "$ENABLE_USB" ]; then - echo "INFO: running as priviliged container to enable USB access!" +if [ -n "$PRIVILEGED_USB" ]; then + echo "WARNING: running as priviliged container to enable complete USB access!" + echo "Better pass devices explicitly: ./run.sh -i -t --device=/dev/ttyUSB0 flixr/pprz-dev bash" USB_OPTS="--privileged --volume=/dev/bus/usb:/dev/bus/usb" fi +# try to detect which USB devices to pass to the container automatically +# set DISABLE_USB=1 to turn it off +if [ -z "$DISABLE_USB" ]; then + USB_OPTS=$(find /dev -maxdepth 1 \( -name "ttyACM?" -or -name "ttyUSB?" \) -printf "--device=%p ") + if [ -n "$USB_OPTS" ]; then + echo Passing auto-detected USB devices: $USB_OPTS + fi +fi + # share the paparazzi directory and set it as working directory SHARE_PAPARAZZI_HOME_OPTS="--volume=$PAPARAZZI_HOME:$PPRZ_HOME_CONTAINER \ --env=PAPARAZZI_HOME=$PPRZ_HOME_CONTAINER \