forked from alexlacerda/Castalia-3.2_OMNeT-IDE_Windows_Linux
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdateCastalia.sh
116 lines (106 loc) · 3.24 KB
/
updateCastalia.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
#!/bin/bash
# *****************************************************************
# * CASTALIA-3.2 PORT TO OMNeT++ v.4 ON WINDOWS AND LINUX *
# * Automatic Installation Shell Script *
# * Author(s): Alex Lacerda, Marcella Pinheiro *
# * Contact: [email protected] *
# * *
# *****************************************************************
# This script automatically checks whether Castalia-3.2 and OMNeT++ v.4 are installed.
# Then applies the patch and copies the files necessary to adapt/port Castalia.
# Showing OMNeT++ and Castalia-3.2 installation reminder
echo
echo "Make sure OMNeT++ v.4 is correctly installed"
echo "and Castalia-3.2/bin folder is on the PATH"
echo
# Showing confirmation prompt
read -r -p "Proceed with this installation? [Y/n] " response
if ! [[ $response =~ ^[Yy]$ ]] && ! [ -z $response ]; then
echo
echo "Abort."
exit 1
fi
# Checking OMNeT++ installation and version
echo
printf "Checking whether omnetpp is on the PATH..."
omnetppPath=`which omnetpp`
if [[ $omnetppPath ]]; then
echo "OK!"
omnetppDir=${omnetppPath%/*/*}
echo "OMNeT++ folder: $omnetppDir"
printf "Checking OMNeT++ version..."
versionResult=$(head -n 1 "$omnetppDir/Version" | grep "omnetpp-4")
if [[ $versionResult ]] ; then
echo "OK!"
echo "Version: $versionResult"
else
omnetppErrorMessage="OMNeT++ v.4 was not found. Do not forget to install it so that you can run Castalia!"
fi
else
omnetppErrorMessage="omnetpp was not found in the PATH. Do not forget to install it so that you can run Castalia!"
fi
echo
# Checking Castalia installation and version
printf "Checking whether Castalia is on the PATH..."
castaliaPath=`which Castalia`
if [[ $castaliaPath ]]; then
echo "OK!"
castaliaDir=${castaliaPath%/*/*}
echo "Castalia folder: $castaliaDir"
printf "Checking Castalia version..."
versionResult=$(head -n 1 "$castaliaDir/VERSION" | grep "Castalia 3.0")
if [[ $versionResult ]] ; then
echo "OK!"
echo "Version: $versionResult"
else
echo
echo "ERROR: Castalia-3.2 not found!"
echo "Abort."
echo
exit 1
fi
else
echo
echo "ERROR: Castalia not found in the PATH!"
echo "Abort."
echo
exit 1
fi
# Applying patch
echo
echo "Applying adaptation patch to Castalia folder..."
patch -d $castaliaDir -p1 < "$(dirname ${BASH_SOURCE[0]})"/castalia_adaptation.patch
if [[ $? != 0 ]]; then
echo
echo "ERROR: Unable to apply patch!"
echo "Maybe it has already been applied before or you do not have a fresh Castalia installation!"
echo "Abort."
echo
exit 1
fi
echo
echo "Patch successfully applied!"
# Copying zlib1.dll (Windows only)
if [[ "$OSTYPE" == "msys" ]]; then
echo
echo "Copying zlib1.dll to Castalia folder..."
cp "$(dirname ${BASH_SOURCE[0]})"/zlib1.dll $castaliaDir
if [[ $? != 0 ]]; then
echo
echo "WARNING: Could not copy zlib1.dll!"
echo "Try to copy it manually to Castalia-3.2 folder!"
echo
fi
fi
# Showing warning message about OMNet++ installation, if any
if [[ $omnetppErrorMessage ]]; then
echo
echo "WARNING: $omnetppErrorMessage"
fi
echo
echo "Installation successfully finished!"
echo
echo "Now you can import Castalia.3.2 to OMNeT++ IDE or run a simulation from the command line!"
echo
echo "done."
echo