-
Notifications
You must be signed in to change notification settings - Fork 0
/
launch.sh
executable file
·114 lines (94 loc) · 3.1 KB
/
launch.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
#! /bin/bash
# File: launch.sh
# Author: Gael Marcadet <gael.marcadet@limos.fr>
# Description: Launch the Samba Demo.
set -e
# ------------------------------------
# Parsing arguments
# ------------------------------------
# In case where all arguments are not provided, display the usage
if [ $# -ne 3 ]; then
echo "Usage: $0 (download|no-download) (data|no-data) (build|no-build)"
echo " (download|no-download): Specify if datasets must be downloaded (DISCLAIMER: Could take a few minutes)."
echo " (data|no-data): Generate data."
echo " (build|no-build): Build the Docker containers."
echo ""
echo "Examples:"
echo " First time: $0 download data build"
echo " After being away: $0 no-download data build"
echo " In case you are confident: $0 no-download data no-build"
exit 0
fi
downloadDataset=0
if [ $1 == "download" ]; then
downloadDataset=1
fi
generatingDataset=1
if [ $2 == 'no-data' ]; then
generatingDataset=0
fi
buildImages=0
if [ $3 == "build" ]; then
buildImages=1
fi
# -------------------------------------
# Dependancies installation
# -------------------------------------
# ensure that Docker is installed
if [ -z $(which docker) ]; then
echo "[*] Installing Docker..."
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg \
lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo "[+] Docker installed"
echo \
"deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
else
echo "[+] Docker installed, skipping installation"
fi
# ensures that docker-compose is installed
if [ -z $(which docker-compose) ]; then
echo "[*] Docker-Compose not installed yet, procedding to the installation..."
sudo curl -L "https://github.com/docker/compose/releases/download/1.29.2/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
sudo chmod +x /usr/local/bin/docker-compose
sudo ln -s /usr/local/bin/docker-compose /usr/bin/docker-compose
echo "[+] Docker-Compose successfully installed"
else
echo "[+] Docker-Compose already intalled, skipping installation"
fi
# First generate the data
if [ $generatingDataset -eq 1 ]; then
echo "[+] Calling data generation script"
cd data
chmod +x generate-data.sh
if [ $downloadDataset -eq 1 ]; then
args='download'
else
args='no-download'
fi
./generate-data.sh $args
echo "[+] Data have been generated successfully"
cd ..
else
echo "[+] Skipping data generation"
fi
# Building Docker containers
if [ $buildImages -eq 1 ]; then
echo "[*] Building Docker containers"
sudo docker-compose build
echo "[+] Docker containers built"
else
echo "[+] Docker containers building not required: skipping"
fi
# Running the Docker containers
echo "[*] Running docker containers"
sudo docker-compose up