forked from mobile-insight/mobileinsight-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
install-ubuntu.sh
executable file
·158 lines (134 loc) · 5.12 KB
/
install-ubuntu.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
146
147
148
149
150
151
152
153
154
155
156
157
158
#!/bin/bash
# Installation script for mobileinsight-core on Ubuntu
# It installs package under /usr/local folder
# Author : Zengwen Yuan, Haotian Deng
# Date : 2020-10-20
# Version : 4.0
# set -e
# set -u
echo "** Installer Script for mobileinsight-core on Ubuntu **"
echo " "
echo " Author : Zengwen Yuan (zyuan [at] cs.ucla.edu), Haotian Deng (deng164 [at] purdue.edu)"
echo " Date : 2020-10-20"
echo " Rev : 4.0"
echo " Usage : ./install-ubuntu.sh"
echo " "
echo "Upgrading MobileInsight..."
yes | ./uninstall.sh
# Wireshark version to install
ws_ver=3.2.7
# Use local library path
#TODO
PREFIX=/usr/local
MOBILEINSIGHT_PATH=$(pwd)
WIRESHARK_SRC_PATH=${MOBILEINSIGHT_PATH}/wireshark-${ws_ver}
PYTHON=python3
PIP=pip3
echo "Installing dependencies for compiling Wireshark libraries"
sudo apt-get -y install pkg-config wget libglib2.0-dev bison flex libpcap-dev
echo "Checking Wireshark sources to compile ws_dissector"
if [ ! -d "${WIRESHARK_SRC_PATH}" ]; then
echo "You do not have source codes for Wireshark version ${ws_ver}, downloading..."
wget https://www.wireshark.org/download/src/all-versions/wireshark-${ws_ver}.tar.xz
tar -xf wireshark-${ws_ver}.tar.xz
rm wireshark-${ws_ver}.tar.xz
fi
echo "Configuring Wireshark sources for ws_dissector compilation..."
cd ${WIRESHARK_SRC_PATH}
cmake -DBUILD_wireshark=OFF . > /dev/null 2>&1
if [ $? != 0 ]; then
echo "Error when executing '${WIRESHARK_SRC_PATH}/cmake -DBUILD_wireshark .'"
echo "You need to manually fix it before continuation. Exiting with status 3"
exit 3
fi
echo "Check if proper version of wireshark dynamic library exists in system path..."
FindWiresharkLibrary=true
if readelf -d "/usr/local/lib/libwireshark.so" | grep "SONAME" | grep "libwireshark.so.13" ; then
echo "Found libwireshark.so.13 being used"
else
echo "Didn't find libwireshark.so.13"
FindWiresharkLibrary=false
fi
if readelf -d "/usr/local/lib/libwiretap.so" | grep "SONAME" | grep "libwiretap.so.10" ; then
echo "Found libwiretap.so.10 being used"
else
echo "Didn't find libwiretap.so.10"
FindWiresharkLibrary=false
fi
if readelf -d "/usr/local/lib/libwsutil.so" | grep "SONAME" | grep "libwsutil.so.11" ; then
echo "Found libwsutil.so.11 being used"
else
echo "Didn't find libwsutil.so.11"
FindWiresharkLibrary=false
fi
if [ "$FindWiresharkLibrary" = false ] ; then
echo "Compiling wireshark-${ws_ver} from source code, it may take a few minutes..."
make -j $(grep -c ^processor /proc/cpuinfo)
if [ $? != 0 ]; then
echo "Error when compiling wireshark-${ws_ver} from source code'."
echo "You need to manually fix it before continuation. Exiting with status 2"
exit 2
fi
echo "Installing wireshark-${ws_ver}"
sudo make install > /dev/null 2>&1
if [ $? != 0 ]; then
echo "Error when installing wireshark-${ws_ver} compiled from source code'."
echo "You need to manually fix it before continuation. Exiting with status 2"
exit 2
fi
fi
echo "Reload ldconfig cache, your password may be required..."
sudo rm /etc/ld.so.cache
sudo ldconfig
echo "Compiling Wireshark dissector for mobileinsight..."
cd ${MOBILEINSIGHT_PATH}/ws_dissector
if [ -e "ws_dissector" ]; then
rm -f ws_dissector
fi
g++ ws_dissector.cpp packet-aww.cpp -o ws_dissector `pkg-config --libs --cflags glib-2.0` \
-I"${WIRESHARK_SRC_PATH}" -L"${PREFIX}/lib" -lwireshark -lwsutil -lwiretap
strip ws_dissector
echo "Installing Wireshark dissector to ${PREFIX}/bin"
sudo cp ws_dissector ${PREFIX}/bin/
sudo chmod 755 ${PREFIX}/bin/ws_dissector
echo "Installing dependencies for mobileinsight GUI..."
sudo apt-get -y install python-wxgtk3.0
which pip3
if [ $? != 0 ]; then
sudo apt-get -y install python3-pip
fi
if ${PIP} install matplotlib pyserial > /dev/null; then
echo "pyserial and matplotlib are successfully installed!"
else
echo "Installing pyserial and matplotlib using sudo, your password may be required..."
sudo ${PIP} install pyserial matplotlib
echo "pyserial and matplotlib are successfully installed!"
fi
echo "Installing mobileinsight-core..."
cd ${MOBILEINSIGHT_PATH}
echo "Installing mobileinsight-core using sudo, your password may be required..."
sudo ${PYTHON} setup.py install
echo "Installing GUI for MobileInsight..."
cd ${MOBILEINSIGHT_PATH}
sudo mkdir -p ${PREFIX}/share/mobileinsight/
sudo cp -r gui/* ${PREFIX}/share/mobileinsight/
sudo ln -s ${PREFIX}/share/mobileinsight/mi-gui ${PREFIX}/bin/mi-gui
echo "Testing the MobileInsight offline analysis example."
cd ${MOBILEINSIGHT_PATH}/examples
${PYTHON} offline-analysis-example.py
if [ $? -eq 0 ]; then
echo "Successfully ran the offline analysis example!"
else
echo "Failed to run offline analysis example!"
echo "Exiting with status 4."
exit 4
fi
# echo "Testing MobileInsight GUI (you need to be in a graphic session)..."
# mi-gui
# if [[ $? == 0 ]] ; then
# echo "Successfully ran MobileInsight GUI!"
# echo "The installation of mobileinsight-core is finished!"
# else
# echo "There are issues running MobileInsight GUI, you need to fix them manually"
# echo "The installation of mobileinsight-core is finished!"
# fi