Commit b65e90cb authored by Arturo Hernandez's avatar Arturo Hernandez

working docker image

parent a85883dd
# Instalación
## Requisitos
- Python 3 con pip
- pcscd
### En Ubuntu / Debian
```sh
sudo apt install pcscd pcsc-tools python3-pip python3-pyscard
# pip3 install pyscard #instalado con apt
pip3 install tornado
pip3 install pystray
```
#
This diff is collapsed.
This diff is collapsed.
# Pull base image
FROM python:3.6-slim
FROM python:3.8-slim
# Set environment varibles
ENV PYTHONDONTWRITEBYTECODE 1
......@@ -14,14 +14,15 @@ ADD requirements.txt /code/
# Install dependencies
RUN apt-get update && apt-get install -y psmisc pcscd libpcsclite-dev udev \
&& savedAptMark="$(apt-mark showmanual)" \
&& apt-get install -y --no-install-recommends git \
&& apt-get install -y --no-install-recommends \
python3-setuptools python3-dev python3-augeas gcc swig \
&& pip install --upgrade pip \
&& pip install -r requirements.txt \
&& apt-mark auto '.*' > /dev/null \
&& apt-mark manual $savedAptMark \
&& apt-get purge -y --auto-remove -o APT::AutoRemove::RecommendsImportant=false \
&& rm -rf /var/lib/apt/lists/*
&& rm -rf /var/lib/apt/lists/* \
&& useradd -ms /bin/bash user
#copy base files
run mkdir -p /code/cert/
......@@ -30,6 +31,8 @@ ADD ./cert/server.key /code/cert/
ADD src /code/src/
# USER user #pcscd requires root for now
ENV LOGFILE /dev/stdout
ENV MST_PORT 8000
ENV MST_CERT cert/server.crt
......
......@@ -23,13 +23,11 @@ Construir la imagen:
Iniciar docker con acceso a usb e iniciar el monitor usb (o iniciar manualmente pcscd en el contenedor)
```sh
docker run --rm -d -p 127.0.0.1:8000:8000 --device=/dev/bus/usb --device-cgroup-rule='c 189:* rmw' --name agetic_mst agetic_mst:1.0.0
docker run --rm -d -p 127.0.0.1:8000:8000 --device=/dev/bus/usb --device-cgroup-rule='c 189:* rmw' --name agetic_mst agetic_mst:1.0.0 && docker exec -t agetic_mst bash -c 'pcscd'
# luego iniciar el monitor USB (inicia pcscd en el cliente y permite reconectar)
# luego iniciar el monitor USB (permite reconectar)
./refresh_usb.sh # requiere python
# opcionalmente puede ejectuar una vez
# docker exec -t agetic_mst bash -c 'pcscd'
```
......@@ -49,7 +47,7 @@ docker stop agetic_mst
### 2. Compartir PCSCD
Requiere `pcscd libpcsclite-dev ` instalado en el anfitrion, permite reconectar sin necesidad de reiniciar pcscd
Requiere `pcscd libpcsclite-dev ` instalado en el anfitrion, permite reconectar sin necesidad de reiniciar pcscd. (Requiere que ambas versiones sean compatibles,revise el log del servicio `pcscd` si fuera necesario)
```sh
docker run --rm -d -p 127.0.0.1:8000:8000 -v /var/run/pcscd/pcscd.comm:/var/run/pcscd/pcscd.comm --name agetic_mst agetic_mst:1.0.0
......
......@@ -12,6 +12,7 @@ idString="${idVendor}:${idProduct}"
devWasConnected=$(lsusb | grep "ID ${idString}" | wc -l)
./docker-usb-sync.py
docker exec -t agetic_mst bash -c 'killall pcscd'
docker exec -t agetic_mst bash -c 'pcscd'
inotifywait -r -m /dev/bus/usb -e CREATE -e DELETE | while read e
......
#!/usr/bin/env python3
import os
import wx
import wx.adv
#change CWD to parent of src/
os.chdir(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
#print (os.getcwd())
TRAY_TOOLTIP = 'AGETIC MST'
TRAY_ICON = 'src/www/images.png'
def create_menu_item(menu, label, func):
item = wx.MenuItem(menu, -1, label)
menu.Bind(wx.EVT_MENU, func, id=item.GetId())
menu.Append(item)
return item
class TaskBarIcon(wx.adv.TaskBarIcon):
def __init__(self, frame):
self.frame = frame
super(TaskBarIcon, self).__init__()
self.set_icon(TRAY_ICON)
self.Bind(wx.adv.EVT_TASKBAR_LEFT_DOWN, self.on_left_down)
def CreatePopupMenu(self):
menu = wx.Menu()
create_menu_item(menu, 'Site', self.on_hello)
menu.AppendSeparator()
create_menu_item(menu, 'Exit', self.on_exit)
return menu
def set_icon(self, path):
icon = wx.Icon(path)
self.SetIcon(icon, TRAY_TOOLTIP)
def on_left_down(self, event):
print ('Tray icon was left-clicked.')
def on_hello(self, event):
print ('Hello, world!')
def on_exit(self, event):
wx.CallAfter(self.Destroy)
self.frame.Close()
class App(wx.App):
def OnInit(self):
frame=wx.Frame(None)
self.SetTopWindow(frame)
TaskBarIcon(frame)
return True
def main():
app = App(False)
app.MainLoop()
if __name__ == '__main__':
main()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment