-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall_dahengdriver.sh
More file actions
executable file
·60 lines (46 loc) · 1.82 KB
/
install_dahengdriver.sh
File metadata and controls
executable file
·60 lines (46 loc) · 1.82 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
#!/bin/bash -eu
# install_dahengdriver.sh
sudo apt-get install -y python3 python3-pip python3-setuptools
# Create the udev rules directory
mkdir -p /etc/udev/rules.d
for file in /usr/lib/python*/EXTERNALLY-MANAGED; do
sudo mv "$file" "$file.old"
done
# Download and install the appropriate Daheng driver based on architecture
cd /tmp
# Auto-detect architecture and set appropriate download URLs
ARCH=$(uname -m)
if [ "$ARCH" = "aarch64" ]; then
DAHENG_ZIP="Galaxy_Linux-armhf_Gige-U3_32bits-64bits_1.5.2303.9202.zip"
DAHENG_URL="https://github.com/openUC2/ImSwitchDockerInstall/releases/download/imswitch-master/${DAHENG_ZIP}"
DAHENG_DIR="Galaxy_Linux-armhf_Gige-U3_32bits-64bits_1.5.2303.9202"
elif [ "$ARCH" = "x86_64" ]; then
DAHENG_ZIP="Galaxy_Linux-x86_Gige-U3_32bits-64bits_2.4.2503.9201.zip"
DAHENG_URL="https://dahengimaging.com/downloads/${DAHENG_ZIP}"
DAHENG_DIR="Galaxy_Linux-x86_Gige-U3_32bits-64bits_2.4.2503.9201"
else
echo "Unsupported architecture: $ARCH"
exit 1
fi
# Download Python API (same for both architectures)
wget https://dahengimaging.com/downloads/Galaxy_Linux_Python_2.0.2106.9041.tar_1.gz
# Download architecture-specific driver
wget "$DAHENG_URL"
# Extract files
unzip "$DAHENG_ZIP"
tar -zxvf Galaxy_Linux_Python_2.0.2106.9041.tar_1.gz
# Set permissions and install the Galaxy camera driver
cd "$DAHENG_DIR"
chmod +x Galaxy_camera.run
# Build and install the Python API
cd /tmp/Galaxy_Linux_Python_2.0.2106.9041/api
python3 setup.py build
sudo python3 setup.py install
# Run the installer script using expect to automate Enter key presses
echo "Y En Y" | sudo "/tmp/$DAHENG_DIR/Galaxy_camera.run"
# Set the library path
export LD_LIBRARY_PATH="/usr/lib:/tmp/$DAHENG_DIR:${LD_LIBRARY_PATH:-}"
# Install Python packages
pip3 install pillow numpy
# Source the bashrc file
source ~/.bashrc