-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfc-clust
executable file
·84 lines (74 loc) · 1.47 KB
/
fc-clust
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
#!/bin/bash
FC=/home/mm/bin/fc
BASE=""
KERNEL=~/code/linux/vmlinux
AMT=3
MEM=4
CPU=2
usage() {
echo -e "fc-clust [options]"
echo -e "\t-r|--root: root partition to be used (eg root.ext4)"
echo -e "\t-k|--kernel: Kernel to be used (default $KERNEL)"
echo -e "\t-n|--count: number of virtual machines to be run (default $AMT)"
echo -e "\t-m|--memory: amount of memory for each virtual machine"
echo -e "\t-j|--cores: amount of cores for each virtual machine"
echo -e "\t-c|--clean: clean up any running cluster"
}
while [[ ! -z $1 ]]; do
case $1 in
-r|--root)
BASE=$2
shift
;;
-k|--kernel)
KERNEL=$2
shift
;;
-n|--count)
AMT=$2
shift
;;
-c|--clean)
CLEAN="yes"
;;
-h|--help)
usage
exit
;;
-m|--memory)
MEM=$2
shift
;;
-j|--cores)
CPU=$2
shift
;;
*)
echo "Unknown Command"
exit
esac
shift
done
pkill firecracker
sleep 1
rm /tmp/firecracker*.socket 2> /dev/null
sudo umount fireclust/o* 2> /dev/null
rm -rf fireclust
if [[ $CLEAN != "yes" && $BASE != "" ]]; then
for (( i=0; i<$AMT; i++)); do
$FC --server &
sleep 1
done
mkdir -p fireclust/base
cp $BASE fireclust/base/OS.ext4
for (( i=0; i<$AMT; i++)); do
mkdir -p fireclust/{w$i,u$i,o$i}
sudo mount -t overlay -o \
lowerdir=fireclust/base,upperdir=fireclust/u$i,workdir=fireclust/w$i \
none fireclust/o$i
done
for (( i=0; i<$AMT; i++)); do
$FC -c -r fireclust/o$i/OS.ext4 -k $KERNEL -m $MEM -j $CPU -n --socket $i &
sleep 1
done
fi