-
Notifications
You must be signed in to change notification settings - Fork 1
/
install-experimental.sh
145 lines (96 loc) · 4.03 KB
/
install-experimental.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/bin/bash
export LC_ALL=C
ERR='\033[0;31m'
INFO='\033[0;32m'
NC='\033[0m' # No Color
KERNEL=$(uname -r)
clear
WELCOME="These drivers will be compiled and installed:\n
- CAN driver (SocketCAN)\n
These software components will be installed:\n
- autoconf, libtool, unzip, libsocketcan, can-utils\n
Important: create a backup copy of the system before installation!\n
continue installation?"
if (whiptail --title "emPC-CX+ Installation Script" --yesno "$WELCOME" 20 60) then
echo ""
else
exit 0
fi
apt-get update -y
apt-get -y install bc build-essential unzip
if ! apt-get -y install linux-headers-$(uname -r); then
apt-get -y install linux-headers-amd64
fi
if [ ! -f "/lib/modules/$KERNEL/build" ]; then
ln -s /usr/src/linux-headers-$KERNEL/ /lib/modules/$KERNEL/build
fi
# get installed gcc version
GCCVERBACKUP=$(gcc --version | egrep -o '[0-9]+\.[0-9]+' | head -n 1)
# get gcc version of installed kernel
GCCVER=$(cat /proc/version | egrep -o 'gcc version [0-9]+\.[0-9]+' | egrep -o '[0-9.]+')
gcc --version | grep "$GCCVER" || (echo "$ERR Error: gcc $GCCVER not found! $NC"; exit 1);
rm -rf /tmp/empc-cxplus-linux-drivers
mkdir -p /tmp/empc-cxplus-linux-drivers
cd /tmp/empc-cxplus-linux-drivers
CPU=$(if uname -a | grep "x86_64" >/dev/null; then echo "x86_64"; else echo "x86"; fi)
# compile jhal driver
wget -nv https://github.com/janztec/empc-cxplus-linux-drivers/raw/master/src/jhal.zip -O jhal.zip
unzip jhal.zip
cd jhal
make driver install
cd /tmp/empc-cxplus-linux-drivers
if [ ! -f "/lib/modules/$KERNEL/kernel/drivers/misc/jhal.ko" ]; then
echo -e "$ERR Error: Installation failed! (driver module jhal build failed) $NC" 1>&2
whiptail --title "Error" --msgbox "Installation failed! (driver module jhal build failed)" 10 60
exit 1
fi
# compile jtec_can driver
wget -nv https://github.com/janztec/empc-x-linux-drivers/raw/master/src/jtec_can.zip -O jtec_can.zip
unzip jtec_can.zip
cd jtec_can
make driver install
if [ ! -f "/lib/modules/$KERNEL/kernel/drivers/net/can/sja1000/jtec_can.ko" ]; then
echo -e "$ERR Error: Installation failed! (driver module jtec_can build failed) $NC" 1>&2
whiptail --title "Error" --msgbox "Installation failed! (driver module jtec_can build failed)" 10 60
exit 1
fi
depmod -a
# Install jtec_can init service
wget -nv https://raw.githubusercontent.com/janztec/empc-cxplus-linux-drivers/master/src/jtec_can -O /etc/init.d/jtec_can
if [ ! -f "/etc/init.d/jtec_can" ]; then
echo -e "$ERR Error: Installation failed! (jtec_can not installed) $NC" 1>&2
whiptail --title "Error" --msgbox "Installation failed! (jtec_can not installed)" 10 60
exit 1
fi
chmod 755 /etc/init.d/jtec_can
update-rc.d jtec_can defaults
wget -nv https://raw.githubusercontent.com/janztec/empc-cxplus-linux-drivers/master/scripts/empc-can-configbaudrate.sh -O /usr/bin/empc-can-configbaudrate.sh
if [ ! -f "/usr/bin/empc-can-configbaudrate.sh" ]; then
echo -e "$ERR Error: Installation failed! (empc-can-configbaudrate not installed) $NC" 1>&2
whiptail --title "Error" --msgbox "Installation failed! (empc-can-configbaudrate not installed)" 10 60
exit 1
fi
chmod 755 /usr/bin/empc-can-configbaudrate.sh
bash /usr/bin/empc-can-configbaudrate.sh
if [ ! -f "/usr/local/bin/cansend" ]; then
if (whiptail --title "emPC-CX+ Installation Script" --yesno "Third party SocketCan library and utilities\n\n- libsocketcan-0.0.10\n- can-utils\n - candump\n - cansend\n - cangen\n\ninstall?" 16 60) then
apt-get -y install git
apt-get -y install autoconf
apt-get -y install libtool
cd /usr/src/
wget http://www.pengutronix.de/software/libsocketcan/download/libsocketcan-0.0.10.tar.bz2
tar xvjf libsocketcan-0.0.10.tar.bz2
rm -rf libsocketcan-0.0.10.tar.bz2
cd libsocketcan-0.0.10
./configure && make && make install
cd /usr/src/
git clone https://github.com/linux-can/can-utils.git
cd can-utils
./autogen.sh
./configure && make && make install
fi
fi
cd /
if (whiptail --title "emPC-CX+ Installation Script" --yesno "Installation completed! reboot required\n\nreboot now?" 12 60) then
reboot
fi