-
Notifications
You must be signed in to change notification settings - Fork 13
/
bootstrap.sh
executable file
·272 lines (221 loc) · 8.67 KB
/
bootstrap.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
#!/bin/bash
#
# Bootstrap script for OPS -- The Opportunistic Protocol Simulator
#
# Setup everything for the OPS simulations. Refer to README.md for detailed
# information and how to use this file.
#
# @author Jens Dede ([email protected])
# @date 28-February-2018
#
# Load the settings and convenience functions
source ./res/tools/shell-functions.sh
loadSettings
# Ensure that all paths are is absolute
if [[ "$INET_PATH" != /* ]]; then
echo "\$INET_PATH is relative. Change it to an absolute one"
INET_PATH=$(pwd)/$INET_PATH
fi
if [[ "$SWIM_PATH" != /* ]]; then
echo "\$SWIM_PATH is relative. Change it to an absolute one"
SWIM_PATH=$(pwd)/$SWIM_PATH
fi
if [[ "$EXTENDED_SWIM_PATH" != /* ]]; then
echo "\$EXTENDED_SWIM_PATH is relative. Change it to an absolute one"
EXTENDED_SWIM_PATH=$(pwd)/$EXTENDED_SWIM_PATH
fi
if [[ "$KEETCHI_API_PATH" != /* ]]; then
echo "\$KEETCHI_API_PATH is relative. Change it to an absolute one"
KEETCHI_API_PATH=$(pwd)/$KEETCHI_API_PATH
fi
echo "Using INET: $INET_PATH"
echo "Using SWIM: $SWIM_PATH"
echo "Using Extended SWIM: $EXTENDED_SWIM_PATH"
echo "Using KeetchiLib: $KEETCHI_API_PATH"
if [ ! -d "modules" ]; then
mkdir modules
fi
cd modules
echo "Pulling all dependent libraries from Github: INET and KeetchiLib"
git clone https://github.com/inet-framework/inet.git
git clone https://github.com/ComNets-Bremen/KeetchiLib.git
# Now, all directories should be there and we can finally check
if [ ! -d $INET_PATH ]; then
echo "Invalid INET path: \"$INET_PATH\". Please check your configuration. Aborting..."
exit 1
fi
if [ ! -d $KEETCHI_API_PATH ]; then
echo "Invalid KeetchiLib path: \"$KEETCHI_API_PATH\". Please check your configuration. Aborting..."
exit 1
fi
if [ "$INET_BUILD" = true ]; then
echo "Building version $INET_VERSION of the OMNeT++ INET Framework..."
cd inet
# The inet version is taken from the settings
git checkout $INET_VERSION
# build SWIM and ExtendedSWIM modules with INET
if [ "$INET_PATCH" = true ]; then
if [ -d $SWIM_PATH ]; then
echo "Checking for SWIM in INET located in $INET_PATH and patch it if necessary"
for f in $(ls $SWIM_PATH/*.{cc,h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/single/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/single/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/single/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
else
echo "SWIMMobility not found! Skipping"
fi
if [ -d $EXTENDED_SWIM_PATH ]; then
echo "Checking for ExtendedSWIM in INET located in $INET_PATH and patch it if necessary"
for f in $(ls $EXTENDED_SWIM_PATH/IReactive*.{h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/contract/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/contract/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/contract/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
for f in $(ls $EXTENDED_SWIM_PATH/ExtendedSWIM*.{cc,h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/single/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/single/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/single/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
else
echo "ExtendedSWIMMobility not found. Skipping"
fi
else
echo "INET patching disabled"
fi
# Is there an old version? -> clean up inet
if [ ! -f “Makefile” ]; then
make clean
fi
make makefiles
if [ $? -ne 0 ]; then
echo "Command \"make makefiles\" for INET failed. Aborting"
exit 1
fi
#make MODE=release -j $(nproc)
make MODE=release -j 1
if [ $? -ne 0 ]; then
echo "Command \"make MODE=release\" for INET failed. Aborting"
exit 1
fi
cd ..
else
echo "Skipping building OMNeT++ INET Framework"
fi
####
echo "Initialize the submodules"
git submodule update --init --recursive
# Now, all directories should be there and we can finally check the $INET_PATH
if [ ! -d $INET_PATH ]; then
echo "Invalid INET path: \"$INET_PATH\". Please check your configuration. Aborting..."
exit 1
fi
cd modules
if [ "$INET_BUILD" = true ]; then
echo "Building version $INET_VERSION of the OMNeT++ INET Framework..."
cd inet
# The inet version is taken from the settings
git checkout $INET_VERSION
git submodule update --init --recursive
# build SWIM and ExtendedSWIM modules with INET
if [ "$INET_PATCH" = true ]; then
if [ -d "../SWIMMobility" ]; then
echo "Checking for SWIM in INET located in $INET_PATH and patch it if necessary"
for f in $(ls ../SWIMMobility/*.{cc,h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/single/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/single/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/single/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
else
echo "SWIMMobility not found! Skipping"
fi
if [ -d "../ExtendedSWIMMobility" ]; then
echo "Checking for ExtendedSWIM in INET located in $INET_PATH and patch it if necessary"
for f in $(ls ../ExtendedSWIMMobility/IReactive*.{h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/contract/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/contract/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/contract/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
for f in $(ls ../ExtendedSWIMMobility/ExtendedSWIM*.{cc,h,ned}); do
basefile=$(basename $f)
echo "Checking for $basefile..."
if [ ! -f "$INET_PATH/inet/mobility/single/$basefile" ]; then
echo "\"$basefile\" does not exist. Copying..."
cp $f $INET_PATH/inet/mobility/single/
else
echo "Found \"$basefile\" in the INET directory \"$INET_PATH/inet/mobility/single/"
echo "The existing version is not replaced. Ensure that you update it if required!"
fi
done
else
echo "ExtendedSWIMMobility not found. Skipping"
fi
else
echo "INET patching disabled"
fi
# Is there an old version? -> clean up inet
if [ ! -f “Makefile” ]; then
make clean
fi
make makefiles
if [ $? -ne 0 ]; then
echo "Command \"make makefiles\" for INET failed. Aborting"
exit 1
fi
# make MODE=release -j $(nproc)
make MODE=release -j 1
if [ $? -ne 0 ]; then
echo "Command \"make MODE=release\" for INET failed. Aborting"
exit 1
fi
cd ..
else
echo "Skipping building OMNeT++ INET Framework"
fi
if ! [ -x "$(command -v autoreconf)" ]; then
echo "Error: autoconf automake libtool must be installed"
exit 1
fi
if [ "$KEETCHI_BUILD" = true ]; then
echo "Building KeetchiLib..."
cd KeetchiLib
./bootstrap.sh
./configure
make
cd ..
else
echo "Skipping building KeetchiLib"
fi
echo " "
echo "Done. Next step: run \"make\" to build the simulation"
echo " "