forked from FRINXio/FRINX-machine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
startup.sh
executable file
·112 lines (88 loc) · 2.06 KB
/
startup.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
#!/bin/bash
DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
cd ${DIR}
# Common functions
script="startup.sh"
function example {
echo -e "example: $script"
}
function usage {
echo -e "usage: $script [OPTION] \n"
}
function help {
usage
echo -e "OPTION:"
echo -e " -s | --skip Skips health check."
echo -e "\n"
example
}
function check_success {
if [[ $? -ne 0 ]]
then
RED='\033[0;31m'
NC='\033[0m' # No Color
printf "${RED}System is not healthy. Shutting down.\n${NC}"
echo "Removing containers."
./teardown.sh
exit
fi
}
function start_container {
sudo docker-compose up -d "$1"
}
function start_containers {
local containers_to_start=("dynomite" "elasticsearch" "logstash" "conductor-server" "odl" "sample-topology" "uniconfig-ui" "kibana" "micros")
for i in "${containers_to_start[@]}"; do
start_container $i
if [ "$skip" = false ]; then
./health_check.sh $i
check_success $?
fi
echo "################"
done
}
function import_workflows {
sudo docker exec micros bash -c "cd /home/app && newman run netinfra_utils/postman.json --folder 'TASKS' -e netinfra_utils/postman_environment.json"
if [ "$skip" = false ]; then
check_success $?
fi
sudo docker exec micros bash -c "cd /home/app && newman run netinfra_utils/postman.json --folder 'SETUP' -e netinfra_utils/postman_environment.json"
if [ "$skip" = false ]; then
check_success $?
fi
}
function import_devices {
sudo docker exec micros bash -c "cd /home/app && newman run netinfra_utils/devices/device_import.postman_collection.json -d netinfra_utils/devices/device_data.csv"
if [ "$skip" = false ]; then
check_success $?
fi
}
# Loop arguments
skip=false
import=false
while [ "$1" != "" ];
do
case $1 in
-s | --skip)
skip=true
shift
;;
-h | --help )
help
exit
;;
*) # unknown option
echo "$script: illegal option $1"
exit 1 #error
;;
esac
done
# Clean up docker
sudo docker system prune -f
# Starts containers
start_containers
# Imports workflows
import_workflows
# Import devices
import_devices
echo 'Startup finished!'