-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall_moxa_driver_centos.sh
98 lines (84 loc) · 2 KB
/
install_moxa_driver_centos.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
#!/bin/bash
echo "Running CentOS Moxa Driver Installer 0.0.1"
# root check
if [ "$EUID" -ne 0 ]
then
echo "Please run as root"
read -r -p "Proceed anyway? [y/N] " response
if [[ ! "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
exit
fi
fi
# download the driver into /tmpt/moxa/
echo "Downloading the moxa driver..."
cd /tmp/
wget https://bit.ly/36QZKL0
file 36QZKL0
mv 36QZKL0 moxa.tgz
tar zxvf moxa.tgz
cd moxa/
# print the kernel version
echo "Kernel Version:"
uname -a
uname -r
# update all packages
echo "Updating Packages..."
yum check-update
yum update
# install the driver requirements
echo "Installing required Packages..."
yum install -y make
yum install -y gcc
yum install -y ld
yum install -y libc
yum install -y binutils
yum install -y gunzip
yum install -y gawk
yum install -y openssl
yum install -y libssl-dev
yum install -y libssl
yum install -y elfutils-libelf-devel
yum install -y openssl-devel
# check if kernel headers are installed
echo "Currently installed Kernel Headers:"
cd /usr/src/kernels/
ls -l
read -r -p "Install Kernel Headers? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
# install kernel headers
echo "Installing Kernel Headers..."
yum install -y kernel-devel
yum install -y kernel-headers
echo "Installed Kernel Headers:"
cd /usr/src/kernels/
ls -l
fi
echo "Current Kernel Headers Installed"
ls -l /usr/src/kernels/$(uname -r)
read -r -p "Move Kernel Header? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
mv /usr/src/kernels/? /usr/src/kernels/$(uname -r)
ls -l /usr/src/kernels/$(uname -r)
fi
# ./mxinst
read -rsp $"Press any key to install the driver (runs './mxinst')" -n 1 key
echo "Installing..."
status=$?
cmd="./mxinst"
$cmd
status=$?
if [ $status -eq 0 ]
then
echo "Installed successfully"
exit
fi
read -r -p "Disable Module Validation (runs 'mokutil --disable-validation')? [y/N] " response
if [[ "$response" =~ ^([yY][eE][sS]|[yY])$ ]]
then
echo "Disabling Module Validation..."
yum install -y mokutil
mokutil --disable-validation
fi