-
Notifications
You must be signed in to change notification settings - Fork 18
/
installCH341.sh
executable file
·36 lines (33 loc) · 1.18 KB
/
installCH341.sh
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
#!/bin/bash
# Install the CH341 module
# First, does the module version magic match the current kernel version?
MAGICVERSION=$(modinfo ch341.ko | grep vermagic)
MODULEVERSION=$(echo $MAGICVERSION | cut -d " " -f 2)
KERNELVERSION=$(uname -r)
if [ "$MODULEVERSION" == "$KERNELVERSION" ]
then
echo "Kernel and Module Versions Match; Installing ..."
else
echo "The Kernel version does not match the Module Version"
echo "Kernel Version: " $KERNELVERSION
echo "Module Version: " $MODULEVERSION
while true; do
read -p "Would you still like to install the module? [Y/n] " response
case $response in
[Yy]* ) break ;;
[Nn]* ) exit;;
* ) echo "Please answer Yes or no. " ;;
esac
done
# The module version did not match the kernel version, but user selected to install anyway
echo "You may have to force the module to be inserted, i.e. "
echo "$ sudo modprobe -f cp210x"
fi
# Install the ch341 module
# Make sure that the drivers/usb/serial directory exists
INSTALLDIRECTORY=/lib/modules/$(uname -r)/kernel/drivers/usb/serial
sudo mkdir -p "$INSTALLDIRECTORY"
# Then copy over the module file
sudo cp -v ch341.ko $INSTALLDIRECTORY
sudo depmod -a
echo "Installed ch341 Module"