[docker] use --device instead of --privileged for USB

also "autodetect" potentially interesting /dev/ttyUSB? and /dev/ttyACM? devices and pass them by default.
This commit is contained in:
Felix Ruess
2015-02-09 17:31:40 +01:00
parent 09c73d4fee
commit 6b3e71d415
2 changed files with 12 additions and 7 deletions
-5
View File
@@ -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
+12 -2
View File
@@ -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 \