-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathstart
executable file
·105 lines (98 loc) · 4.38 KB
/
start
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
#!/bin/sh
. ./.env
set -e
DB_VERSION_ENV_FILE_LOCATION="./.env.ceversion"
if [ -n "${HA_NFS_DATA_DIRECTORY}" ]; then
. ${HA_NFS_DATA_DIRECTORY}/config/.env
DB_VERSION_ENV_FILE_LOCATION="${HA_NFS_DATA_DIRECTORY}/config/.env.ceversion"
fi
if [ -f "/.cloud_exchange_vm.marker" ]; then
file_path="/opt/cloudexchange/containers/ce_containers.tar"
if [ -f "$file_path" ] && [ -z $SKIP_IMPORT ]; then
echo "Importing Cloud Exchange images..."
while [ -f "$file_path" ]; do
sleep 5
done
echo "Successfully imported Cloud Exchange images..."
fi
fi
if [ -f /etc/redhat-release ] && [ `grep -c "Red Hat" /etc/redhat-release` -eq 1 ]; then
if [ `grep -c "7.9" /etc/redhat-release` -ge 1 ]; then
docker compose version &> /dev/null
if [ $? -eq 127 ]; then
echo "Could not find docker compose"
exit 1;
else
if [ -z "${HA_IP_LIST}" ]; then
docker compose --compatibility up --remove-orphans -d
alias compose_command="docker compose -f docker-compose.yml"
else
docker compose -f docker-compose-ha.yml --env-file=$HA_NFS_DATA_DIRECTORY/config/.env --compatibility up --remove-orphans -d
alias compose_command="docker compose -f docker-compose-ha.yml"
fi
fi
else
podman-compose version &> /dev/null
if [ $? -eq 127 ]; then
echo "Could not find podman-compose"
exit 1;
else
if [ -z "${HA_IP_LIST}" ]; then
podman-compose -f podman-compose.yml up -d
alias compose_command="podman-compose -f podman-compose.yml"
else
podman-compose -f podman-compose-ha.yml --env-file=$HA_NFS_DATA_DIRECTORY/config/.env up -d
alias compose_command="podman-compose -f podman-compose-ha.yml"
fi
fi
fi
else
docker compose version &> /dev/null
if [ $? -eq 127 ]; then
podman-compose version &> /dev/null
if [ $? -eq 127 ]; then
echo "Could not find docker compose or podman-compose"
exit 1;
else
if [ -z "${HA_IP_LIST}" ]; then
podman-compose -f podman-compose.yml up -d
alias compose_command="podman-compose -f podman-compose.yml"
else
podman-compose -f podman-compose-ha.yml --env-file=$HA_NFS_DATA_DIRECTORY/config/.env up -d
alias compose_command="podman-compose -f podman-compose-ha.yml"
fi
fi
else
if [ -z "${HA_IP_LIST}" ]; then
docker compose --compatibility up --remove-orphans -d
alias compose_command="docker compose -f docker-compose.yml"
else
docker compose -f docker-compose-ha.yml --env-file=$HA_NFS_DATA_DIRECTORY/config/.env --compatibility up --remove-orphans -d
alias compose_command="docker compose -f docker-compose-ha.yml"
fi
fi
fi
# Wait RabbitMQ to start
while true; do
compose_command exec -- rabbitmq-stats rabbitmqctl enable_feature_flag all > /dev/null 2>/dev/null && echo "" && echo "Enabling all feature flags" && echo "" && echo "Enabled all feature flags" && break
echo "Waiting for RabbitMQ to start..."
sleep 10;
done
CURRENT_DATABASE_VERSION=$(compose_command exec -- core cat /opt/netskope/common/api/__init__.py | grep -oP "(?<=__version__ = \")[^\"]*")
echo "CURRENT_DATABASE_VERSION=\"$CURRENT_DATABASE_VERSION\"" > "$DB_VERSION_ENV_FILE_LOCATION"
export CURRENT_DATABASE_VERSION=$CURRENT_DATABASE_VERSION
if [ -n "${HA_IP_LIST}" ]; then
if [ "$HA_PRIMARY_NODE_IP" = "$HA_CURRENT_NODE" ]; then
./replica_set --initiate
else
./replica_set --join
sleep 5
compose_command exec -- rabbitmq-stats rabbitmqctl stop_app
compose_command exec -- rabbitmq-stats rabbitmqctl reset
compose_command exec -- rabbitmq-stats rabbitmqctl join_cluster rabbit@$HA_PRIMARY_NODE_IP
compose_command exec -- rabbitmq-stats rabbitmqctl start_app
compose_command exec -- rabbitmq-stats rabbitmq-queues add_member cloudexchange_9 rabbit@$HA_CURRENT_NODE
compose_command exec -- rabbitmq-stats rabbitmq-queues add_member cloudexchange_6 rabbit@$HA_CURRENT_NODE
compose_command exec -- rabbitmq-stats rabbitmq-queues add_member cloudexchange_3 rabbit@$HA_CURRENT_NODE
fi
fi