-
Notifications
You must be signed in to change notification settings - Fork 10
/
check_params.sh
executable file
·59 lines (52 loc) · 1.56 KB
/
check_params.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
#! /bin/bash
BASEDIR=$(dirname "$0")
file=$1 file_found=0
usage_shown=0
docker_folder="$BASEDIR/docker"
function show_usage() {
if [ $file_found -eq 0 ]
then
echo "Invalid configuration file specified"
echo
echo "Usage: bash start.sh <short-option|long-option>"
echo
echo "Short options: ms | mm | smms"
echo "Long options : master-to-slave | master-to-master | slave-to-master-to-slave"
echo
exit 0
fi
}
function check_shortcut() {
case $file in
"ms"|"masterslave"|"master-slave"|"master2slave"|"master-2-slave")
file="master-2-slave.yml"
file_found=1
;;
"mm"|"mastermaster"|"master-master"|"master2master"|"master-2-master")
file="master-2-master.yml"
file_found=1
;;
"smms"|"slavemastermasterslave"|"slave-master-master-slave"|"slave2master2master2slave"|"slave-2-master-2-master-2-slave")
file="slave-2-master-2-master-2-slave.yml"
file_found=1
;;
esac
}
function check_docker_config() {
check_shortcut
if [ $file_found -eq 1 ]
then
cfiles=("master-2-slave.yml" "master-2-master.yml" "slave-2-master-2-master-2-slave.yml")
for cfile in ${cfiles[@]}
do
if [ "$cfile" == "$file" ] && [ -f "$docker_folder/$cfile" ]
then
file=$docker_folder/$cfile
file_found=1
break;
fi
done
else
show_usage
fi
}