mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[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:
@@ -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
@@ -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 \
|
||||
|
||||
Reference in New Issue
Block a user