-
Notifications
You must be signed in to change notification settings - Fork 7
/
install-gns3.sh
350 lines (305 loc) · 8.52 KB
/
install-gns3.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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
#!/usr/bin/env bash
# This is a simple bash script to quickly install GNS3 server/gui on Arch Linux and Arch-based distros.
# AUR access and YAY are required.
my_repo_folder="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
source "$my_repo_folder"/docs/colours.sh
my_separator="+----------------------------------------+"
latest_GNS3_release=2.2.31
yay_status_check() {
if [[ -z $(which yay) ]]; then
printf %b\\n "
Yay does not appear to be installed.
Would you like the script to install Yay pefore proceeding?
1 = yes, 2 = no"
read -r install_yay
if [[ $install_yay == 1 ]]; then
printf %b\\n "\n$my_separator\n${BCyan}Installing Yay${Color_Off}\n$my_separator"
sleep 2
git clone https://aur.archlinux.org/yay.git
cd yay || exit
makepkg -si
else
printf %b\\n "
Yay is required for this script. \
Either install it manually then re-run the script, \
or let the script install it for you.\n
Aborting the script...."
exit
fi
fi
}
intro() {
printf %b\\n "
$my_separator
${IWhite}The script will perform installation steps as described in
https://medium.com/@Ninja/install-gns3-on-arch-manjaro-linux-the-right-way-c5a3c4fa337d
You are encouraged to either read through the script or the article to
make sure you understand the steps involved.
Packages are only installed if not already present (--needed option).${Color_Off}
$my_separator\n"
read -n 1 -s -r -p "
Press any key to continue or CTRL+C to exit the script"
}
install_dynamips() {
# Install dynamips (Cisco router support)
printf %b\\n "
$my_separator
${BCyan}Installing dynamips${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S libelf libpcap cmake --noconfirm --needed
yay -S dynamips --needed --answerclean "A" --noconfirm
sudo setcap cap_net_admin,cap_net_raw=ep "$(command -v dynamips)"
cd "$HOME" || exit
if [[ -z $(which dynamips) ]]; then
printf %b\\n "${On_Red}
Unable to find dynamips after install....
Aborting the script${Color_Off}"
exit
fi
}
install_vpcs() {
# Install VPCS
printf %b\\n "
$my_separator
${BCyan}Installing VPCS${Color_Off}
$my_separator
"
sleep 2
cd "$my_repo_folder"/pkg/vpcs || exit
makepkg -sCf && sudo pacman -U vpcs-0.8beta1-1-x86_64.pkg.tar.zst --needed --noconfirm
cd "$HOME" || exit
if [[ -z $(which vpcs) ]]; then
printf %b\\n "${On_Red}
Unable to find VPCS after install....
Aborting the script${Color_Off}"
exit
fi
}
install_iouyap() {
# Install IOUYAP
printf %b\\n "
$my_separator
${BCyan}Installing IOUYAP${Color_Off}
$my_separator
"
sleep 2
cd "$my_repo_folder"/pkg || exit
sudo pacman -U iouyap-0.97-2-x86_64.pkg.tar.xz --needed --noconfirm
cd "$HOME" || exit
sudo setcap cap_net_admin,cap_net_raw=ep "$(command -v iouyap)"
if [[ -z $(which iouyap) ]]; then
printf %b\\n "${On_Red}
Unable to find IOUYAP after install....
Aborting the script${Color_Off}"
exit
fi
}
install_iol_dependencies() {
# Install IOL Dependencies
printf %b\\n "
$my_separator
${BCyan}Installing IOL Dependencies${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S lib32-openssl lib32-gcc-libs --noconfirm --needed
sudo ln -s /usr/lib32/libcrypto.so.1.0.0 /usr/lib32/libcrypto.so.4
sudo sysctl net.unix.max_dgram_qlen=10000
sudo tee -a /etc/sysctl.d/99-sysctl.conf >/dev/null <<EOL
# Prevent EXCESSCOLL error for IOL
net.unix.max_dgram_qlen=10000
EOL
check_excesscoll_1=$(sysctl net.unix.max_dgram_qlen | grep -c 10000)
check_excesscoll_2=$(tail -2 /etc/sysctl.d/99-sysctl.conf | grep -c 10000)
if [[ $check_excesscoll_1 -lt 1 ]] || [[ $check_excesscoll_2 -lt 1 ]]; then
printf %b\\n "${On_Red}EXCESSCOLL error prevention did not work....
Something is not working correctly..
Aborting the script${Color_Off}"
exit
fi
}
install_ubridge() {
# Install uBridge
sleep 2
printf %b\\n "
$my_separator
${BCyan}Installing uBridge${Color_Off}
$my_separator
"
yay -S ubridge --answerclean "A" --noconfirm --needed
cd "$HOME" || exit
if [[ -z $(which ubridge) ]]; then
printf %b\\n "${On_Red}
uBridge was not found after installation.
Something did not work correctly.
Aborting the script....${Color_Off}"
exit
fi
}
install_qemu() {
# Install QEMU
printf %b\\n "
$my_separator
${BCyan}Installing QEMU${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S qemu qemu-arch-extra --noconfirm --needed
}
install_docker() {
# Install docker
printf %b\\n "
$my_separator
${BCyan}Installing Docker${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S docker --noconfirm --needed
sudo systemctl enable docker.service
sudo systemctl start docker.service
sudo gpasswd -a "$USER" docker
}
install_wireshark() {
# Install Wireshark
printf %b\\n "
$my_separator
${BCyan}Installing Wireshark${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S wireshark-qt --noconfirm --needed
sudo gpasswd -a "$USER" wireshark
}
install_pip2pkgbuild() {
# Install pip2pkgbuild
printf %b\\n "
$my_separator
${BCyan}Installing pip2pkgbuild${Color_Off}
$my_separator
"
sleep 2
yay -S pip2pkgbuild --answerclean "A" --noconfirm --needed
sudo pacman -S python-wheel --noconfirm --needed
yay -S python-zipstream --answerclean "A" --noconfirm --needed
}
install_gns_dependencies() {
# Install GNS3 Dependencies
printf %b\\n "
$my_separator
${BCyan}Installing GNS3 dependencies${Color_Off}
$my_separator
"
sleep 2
sudo pacman -S qt5-svg qt5-websockets python-pip python-pyqt5 python-sip python-async_generator python-jinja python-distro python-jsonschema python-aiohttp-cors --noconfirm --needed
sudo pacman -S git --noconfirm --needed
sudo pacman -S python-{aiohttp,yarl,aiofiles,psutil,async-timeout,py-cpuinfo} --noconfirm --needed
}
install_gns3_server() {
# Prepare to install GNS3-server
printf %b\\n "
$my_separator
${BCyan}Preparing to install GNS3-server${Color_Off}
$my_separator
"
sleep 2
mkdir -p "$HOME"/GNS3-Dev/gns3-server && cd "$HOME"/GNS3-Dev/gns3-server || exit
pip2pkgbuild gns3-server -v "$latest_GNS3_release" -n python-pip2pkg-gns3-server
printf %b\\n "
$my_separator
${BCyan}Installing GNS3-server${Color_Off}
$my_separator
"
sleep 2
makepkg -sCfi
sleep 2
}
install_gns3_gui() {
# Install GNS3 GUI
printf %b\\n "
$my_separator
${BCyan}Installing GNS3-GUI${Color_Off}
$my_separator
"
mkdir -p "$HOME"/GNS3-Dev/gns3-gui && cd "$HOME"/GNS3-Dev/gns3-gui || exit
pip2pkgbuild gns3-gui -v "$latest_GNS3_release" -n python-pip2pkg-gns3-gui
sleep 2
makepkg -sCfi
}
verify_gns3_installation() {
# Verify GNS3 installation
printf %b\\n "
$my_separator
${BCyan}Verifying the installation${Color_Off}
$my_separator
"
sleep 3
check_for_gns3=$(pacman -Qq | grep -c 'python-pip2pkg-gns3')
if [[ $check_for_gns3 -lt 2 ]]; then
printf %b\\n "${On_Red}
It appears the installation was either completed partially or has not been completed at all....
Checking further${Color_Off}"
sleep 1
if [[ -z $(pacman -Qq python-pip2pkg-gns3-gui) ]]; then
printf %b\\n "${On_Red}
GNS3-GUI was not installed...
attempting to re-install${Color_Off}"
pip2pkgbuild gns3-gui -v "$latest_GNS3_release" -n python-pip2pkg-gns3-gui
sleep 1
makepkg -sCfi
fi
if [[ -z $(pacman -Qq python-pip2pkg-gns3-server) ]]; then
printf %b\\n "${On_Red}
GNS3-server was not installed...
attempting to re-install${Color_Off}"
pip2pkgbuild gns3-gui -v "$latest_GNS3_release" -n python-pip2pkg-gns3-server
sleep 1
makepkg -sCfi
fi
else
printf %b\\n "${IGreen}
Installation has been completed!
Please reboot your PC or logout and in again for the changes to take effect.${Color_Off}"
fi
}
create_gns3_launcher() {
printf %b\\n "${IGreen}If you are using Gnome or Budgie, the script can make a launcher icon for you.
1 = yes, 2 = no${Color_Off}"
read -r make_launcher
if [[ $make_launcher == 1 ]]; then
sudo tee -a /usr/share/applications/gns3.desktop >/dev/null <<EOL
[Desktop Entry]
Type=Application
Encoding=UTF-8
Name=GNS3
GenericName=Graphical Network Simulator 3
Comment=Graphical Network Simulator 3
Exec=/usr/bin/gns3
Icon=gns3
Terminal=false
Categories=Application;Network;Qt;
EOL
fi
printf %b\\n "${IGreen}
Done! Please remember to reboot your PC.${Color_Off}"
}
main() {
yay_status_check
intro
install_dynamips
install_vpcs
install_iouyap
install_iol_dependencies
install_ubridge
install_qemu
install_docker
install_wireshark
install_pip2pkgbuild
install_gns_dependencies
install_gns3_server
install_gns3_gui
verify_gns3_installation
create_gns3_launcher
}
main