Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
288 lines (255 loc) Β· 7.58 KB
/
Copy pathMakefile
File metadata and controls
288 lines (255 loc) Β· 7.58 KB
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
# Makefile for assignment #3
HOSTIP:= 10.129.135.190
.PHONY: all build clean distclean \
build-task1 run-task1 \
build-task2 run-task2 \
build-task3 run-task3 \
run-task3a run-task3b \
run-task3d1 run-task3d2a \
run-task3d2b run-task3d3 \
run-task3e stop-task3 build-task4 \
run-task4 run-test4
all: build
build: build-task1 build-task2 build-task3
@echo ""
@echo "β
All builds completed."
@echo "π You can now run individual tasks with:"
@echo " make run-task1, make run-task2"
@echo " make run-task3, make run-task4"
@echo ""
build-task1: task1/namespace_prog.c
@echo "π¨ Building task1 (namespace_prog.c)..."
@gcc task1/namespace_prog.c -o task1/namespace_prog
build-task2: task2/container_prog.c task2/simple_container.sh
@echo "π¨ Building task2 (container_prog.c)..."
@gcc task2/container_prog.c -o task2/container_prog
build-task3: task3/setup.sh task3/conductor.sh
@echo "π¨ Debootstrap task3 (conductor.sh)..."
@if [ -f task3/conductor.sh ]; then \
if [ -d "task3/.cache/base/debian-bookworm" ]; then \
echo "π Base image setup already done, skipping debootstrap..."; \
else \
cd task3 && bash conductor.sh build test && cd .. ; \
fi \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
build-task4: task4/service-orchestrator.sh task4/counter-service task4/external-service task4/csfile task4/esfile
@echo "π¨ Building task4/counter-service..."
@$(MAKE) -C task4/counter-service
run-task1:
@echo "π Running task1..."
@if [ -x task1/namespace_prog ]; then \
sudo ./task1/namespace_prog; \
else \
echo "β Error: task1/namespace_prog not found. Build it first!"; \
fi
run-task2:
@echo "π Running task2..."
@if [ -x task2/container_prog ] && [ -f task2/simple_container.sh ]; then \
cd task2 && bash simple_container.sh; \
else \
echo "β Error: task2 artifacts missing. Build it first!"; \
fi
run-task3:
@if [ -f task3/conductor.sh ]; then \
echo "π£ Task3 has multiple subtasks..."; \
echo "Start with task3a..."; \
echo "Check rubric for more instructions."; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3a:
@echo "π Running task3a..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && bash conductor.sh build test1 ; \
bash conductor.sh images; \
bash conductor.sh ps ; \
bash conductor.sh run test1 eg1; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-task3b:
@echo "π Running task3b..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && bash conductor.sh ps ; \
bash conductor.sh exec eg1 /bin/bash; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-task3c:
@echo "π Running task3c..."
@if [ -f task3/conductor.sh ]; then \
cd task3; \
if [ -d ".containers/eg1" ]; then \
bash conductor.sh addnetwork eg1; \
ip a; \
sudo tcpdump -i eg1-outside icmp; \
else \
echo "β Error: eg1 container not found."; \
fi; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3da:
@echo "π Running task3d1..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && chmod +x conductor.sh; \
./conductor.sh build test1 ; \
./conductor.sh run test1 eg1 ; \
mount | grep overlay ; \
sleep 2 ; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3d2a:
@echo "π Running task3d2a..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && chmod +x conductor.sh; \
./conductor.sh build test1 Testfile1 ; \
./conductor.sh run test1 eg1 ; \
mount | grep overlay ; \
sleep 2 ; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3d2b:
@echo "π Running task3d2b..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && chmod +x conductor.sh; \
./conductor.sh build test2 Testfile1 ; \
./conductor.sh run test2 eg2 ; \
mount | grep overlay ; \
sleep 2 ; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3d3:
@echo "π Running task3d3..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && chmod +x conductor.sh; \
./conductor.sh build test1 Testfile2 ; \
./conductor.sh run test1 eg1 ; \
mount | grep overlay ; \
sleep 2 ; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-subtask3e:
@echo "π Running task3d3..."
@if [ -f task3/conductor.sh ]; then \
cd task3 && chmod +x conductor.sh; \
./conductor.sh build test1 Testfile3 ; \
./conductor.sh run test1 eg1 ; \
mount | grep overlay ; \
sleep 2 ; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
stop-task3:
@echo "π Stopping task3 containers..."
@if [ -f task3/conductor.sh ]; then \
cd task3; \
if [ -d ".containers/eg1" ]; then \
bash conductor.sh stop eg1; \
fi; \
if [ -d ".containers/eg2" ]; then \
bash conductor.sh stop eg2; \
fi; \
if [ -d ".images/test" ]; then \
bash conductor.sh rmi test; \
fi; \
if [ -d ".images/test1" ]; then \
bash conductor.sh rmi test1; \
fi; \
if [ -d ".images/test2" ]; then \
bash conductor.sh rmi test2; \
fi; \
if [ -d ".cache/layers" ]; then \
rm -rf .cache/layers; \
fi; \
else \
echo "β Error: task3/conductor.sh missing."; \
fi
run-task3a: run-subtask3a stop-task3
@echo "π Done..."
run-task3d1: run-subtask3da stop-task3
@echo "π Done..."
run-task3d2a: run-subtask3d2a stop-task3
@echo "π Done..."
run-task3d2b: run-subtask3d2b stop-task3
@echo "π Done..."
run-task3d3: run-subtask3d3 stop-task3
@echo "π Done..."
run-task3e: run-subtask3e stop-task3
@echo "π Done..."
run-task4:
@echo "π Running task4 orchestrator..."
@if [ -f task4/service-orchestrator.sh ]; then \
cd task4 && bash service-orchestrator.sh; \
else \
echo "β Error: task4/service-orchestrator.sh missing."; \
fi
stop-task4:
@echo "π Stopping task4 containers..."
@if [ -f task4/conductor.sh ]; then \
cd task4; \
if [ -d ".containers/es-cont" ]; then \
bash conductor.sh stop es-cont; \
fi; \
if [ -d ".containers/cs-cont" ]; then \
bash conductor.sh stop cs-cont; \
fi; \
if [ -d ".images/es-image" ]; then \
bash conductor.sh rmi es-image; \
fi; \
if [ -d ".images/cs-image" ]; then \
bash conductor.sh rmi cs-image; \
fi; \
if [ -d ".cache/layers" ]; then \
rm -rf .cache/layers; \
fi; \
else \
echo "β Error: task4/conductor.sh missing."; \
fi
run-subtest4:
@echo "π Running test for task4 orchestrator...(test1)"
@if [ -f task4/conductor.sh ]; then \
bash task4/conductor.sh ps; \
echo "π Running test for task4 orchestrator...(test2)" ; \
cd task4 && bash conductor.sh exec es-cont -- apt install -y curl ; \
bash conductor.sh exec es-cont curl http://localhost:8080 ; \
echo "" ; \
bash conductor.sh exec es-cont curl http://localhost:8080 ; \
echo "" ; \
echo "π Running test for task4 orchestrator...(test3)" ; \
curl http://$(HOSTIP):3000 ; \
echo "" ; \
curl http://$(HOSTIP):3000 ; \
echo "" ; \
bash conductor.sh exec es-cont curl http://localhost:8080 ; \
echo "" ; \
sleep 2 ; \
else \
echo "β Error: task4/conductor.sh missing."; \
fi
run-test4: run-subtest4 stop-task4
@echo "π Done..."
clean: stop-task3 stop-task4
@echo "π§Ή Cleaning build artifacts..."
@rm -f task1/namespace_prog task2/container_prog
@$(MAKE) -C task4/counter-service clean
@echo "β
Cleanup complete."
distclean: clean
@echo "π₯ Performing DIST CLEAN (full wipe for the submission)..."
@rm -rf \
task1/namespace_prog.c \
task2/simple_container.sh \
task2/container_root \
task3/conductor.sh \
task4/conductor.sh \
task4/setup.sh \
task4/service-orchestrator.sh \
task4/csfile \
task4/esfile
@echo "β
Project fully cleaned."