Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Docker and Vagrant support #32

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.vagrant
.git
21 changes: 21 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM ubuntu:latest
LABEL maintainer="David Manouchehri"

RUN useradd -m lglaf
WORKDIR /home/lglaf
ENV HOME /home/lglaf

RUN apt-get -y update && \
DEBIAN_FRONTEND=noninteractive apt-get -y install git python-pip usbutils udev && \
pip install --upgrade pip && \
pip install pyusb && \
su - lglaf -c "git clone https://github.com/Lekensteyn/lglaf.git" && \
cp -v ~/lglaf/rules.d/42-usb-lglaf.rules /etc/udev/rules.d/ && \
udevadm control --reload-rules || true && \
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this || true looks wrong.

Since you have an isolated container anyway, you could also consider a chgrp lglaf /dev/usb/*/* I guess.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's just so Dockerhub doesn't bail out on building.

Won't that break hotplugging?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I hoped that inotify works also in Docker containers, then you do not need any udevadm command. If you can do hotplugging, try checking for events with udevadm monitor while your container has started.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

udevadm monitor sees the kernel plug events, but doesn't apply udev rules. udev seems to refuse since it detects that it's a container.

udevadm trigger

# udev is sadly broken..
# USER lglaf
ENV PATH /home/lglaf/lglaf:$PATH

CMD ["/bin/bash"]
30 changes: 30 additions & 0 deletions Vagrantfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Author: David Manouchehri

Vagrant.configure("2") do |config|
config.vm.box = "bento/ubuntu-16.04"

# config.vm.synced_folder ".", "/vagrant", disabled: true

config.vm.provision "docker" do |d|
d.build_image '/vagrant/.', args: "-t lglaf"
d.run "lglaf",
args: "--privileged -it -v '/dev/bus/usb:/dev/bus/usb'"
end

%w(vmware_fusion vmware_workstation vmware_appcatalyst).each do |provider|
config.vm.provider provider do |v|
# v.vmx["memsize"] = "2048"
v.vmx['ethernet0.virtualDev'] = 'vmxnet3'
v.vmx["usb.vbluetooth.startConnected"] = "FALSE"
v.vmx["usb.present"] = "TRUE"
v.vmx["usb_xhci.present"] = "FALSE"
v.vmx["usb.generic.autoconnect"] = "FALSE"
v.vmx["usb.autoConnect.device0"] = "0x1004:0x633E"
v.vmx["usb.autoConnect.device1"] = "0x1004:0x627F"
v.vmx["usb.autoConnect.device2"] = "0x1004:0x6298"
v.vmx["usb.autoConnect.device3"] = "0x1004:0x633A"
end
end
end