-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathauto_up_elk_service.sh
executable file
·56 lines (49 loc) · 1.43 KB
/
auto_up_elk_service.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
#!/bin/bash
# platform and elk_version is required, is platform is mac, es_host is required, or'll no need es_host param
platform=$1
elk_version=$2
es_host=$3
docker_compose_file=./$elk_version/docker-compose.yml
#platform_list
version_list=(5.3.1 5.6.3 6.0.1 6.1.2)
# Show usage if required param is missing.
usage() {
echo 'usage: ./up_service.sh <linux|mac> ' '<'${version_list[@]}'>' '<your_hostname>'
exit 0
}
# Check required param
check_param(){
if [ "$(echo $platform | tr [A-Z] [a-z] )" = "linux" ]; then
echo $platform
elif [ "$(echo $platform | tr [A-Z] [a-z])" = "mac" ]; then
echo $platform
if [ -n "$es_host" ]; then
echo $es_host
else
usage
fi
else
usage
fi
if echo "${version_list[@]}" | grep -w "$elk_version" &>/dev/null ; then
echo $elk_version
else
usage
fi
}
# replace param and generate docker-compose file
replace_param_if_need() {
if [ "$(echo $platform | tr [A-Z] [a-z])" = "mac" ]; then
cat ./$elk_version/docker-compose.yml.docker_for_mac > $docker_compose_file
sed -i -e "s/<your_es_host>/$es_host/g" $docker_compose_file
elif [ "$(echo $platform | tr [A-Z] [a-z] )" = "linux" ]; then
cat ./$elk_version/docker-compose.yml.linux > $docker_compose_file
fi
}
# Start service user docker-compose file.
up_service(){
docker-compose -f ./$elk_version/docker-compose.yml up -d
}
check_param
replace_param_if_need
up_service