forked from vtr0n/emotiv-lsl
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_emotiv_docker.sh
More file actions
executable file
·63 lines (49 loc) · 1.66 KB
/
setup_emotiv_docker.sh
File metadata and controls
executable file
·63 lines (49 loc) · 1.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/bash
# Mot-clé pour identifier le dongle Emotiv dans la description lsusb
EMOTIV_KEYWORD="Emotiv"
echo "Recherche du dongle Emotiv dans lsusb..."
# Trouver la ligne contenant le dongle Emotiv
DEVICE_INFO=$(lsusb | grep "$EMOTIV_KEYWORD")
if [ -z "$DEVICE_INFO" ]; then
echo "Erreur : Dongle Emotiv introuvable. Vérifiez qu'il est bien connecté."
exit 1
fi
echo "Périphérique Emotiv détecté : $DEVICE_INFO"
# Extraire Bus, Device et ID
BUS=$(echo "$DEVICE_INFO" | awk '{print $2}')
DEVICE=$(echo "$DEVICE_INFO" | awk '{print $4}' | sed 's/://')
USB_ID=$(echo "$DEVICE_INFO" | awk '{print $6}')
# Construire le chemin complet
DEVICE_PATH="/dev/bus/usb/$BUS/$DEVICE"
# Vérifier si le périphérique existe
if [ ! -e "$DEVICE_PATH" ]; then
echo "Erreur : Le chemin du périphérique ($DEVICE_PATH) n'existe pas."
exit 1
fi
echo "Chemin USB détecté : $DEVICE_PATH"
echo "ID USB détecté : $USB_ID"
# Générer ou mettre à jour docker-compose.yml
DOCKER_COMPOSE_FILE="docker-compose.yml"
cat > $DOCKER_COMPOSE_FILE <<EOF
version: '3.8'
services:
python-app:
devices:
- /dev/hidraw0:/dev/hidraw0
- /dev/hidraw1:/dev/hidraw1
- ${DEVICE_PATH}:${DEVICE_PATH}
build: .
container_name: python_pylsl_emotiv
privileged: true
volumes:
- .:/app
environment:
- PYTHONUNBUFFERED=1
- USB_DEVICE=$USB_ID
command: ["conda", "run", "-n", "lsl_env", "python", "main.py"]
EOF
echo "Fichier $DOCKER_COMPOSE_FILE mis à jour avec succès !"
echo "Le dongle Emotiv est configuré pour Docker."
# Lancer Docker Compose avec le périphérique détecté
echo "Lancement de Docker Compose..."
docker-compose up --build