-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_assistant
75 lines (66 loc) · 1.46 KB
/
run_assistant
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
#!/bin/bash
trap 'func_stop; exit' 1 2 3 6 15
set -xe
exec 2>&1
if [ -z "$HARBOR_VERSION" ]; then
echo "HARBOR_VERSION is undefined"
exit 1
fi
if [ -z "$HARBOR_VIP" ]; then
echo "HARBOR_VIP is undefined"
exit 1
fi
if [ -z "$CEPH_POOL_NAME" ]; then
echo "CEPH_POOL_NAME is undefined"
exit 1
fi
if [ -z "$CEPH_IMAGE_NAME" ]; then
echo "CEPH_IMAGE_NAME is undefined"
exit 1
fi
if [ -z "$CEPH_MON_HOST" ]; then
echo "CEPH_MON_HOST is undefined"
exit 1
fi
if [ -z "$CEPH_USER" ]; then
echo "CEPH_USER is undefined"
exit 1
fi
if [ -z "$CEPH_USER_KEY" ]; then
echo "CEPH_USER_KEY is undefined"
exit 1
fi
if [ -z "$KEEPALIVED_ROLE" ]; then
echo "KEEPALIVED_ROLE is undefined"
exit 1
fi
if [ -z "$INTERFACE" ]; then
echo "INTERFACE is undefined"
exit 1
fi
script_dir=$(
cd "$(dirname "${BASH_SOURCE[0]}")"
pwd
)
chown -R root:root "$script_dir"
chmod +x "$script_dir"/keepalivedctl "$script_dir"/harborctl
"$script_dir"/harborctl init
func_stop() {
"$script_dir"/keepalivedctl stop
"$script_dir"/harborctl stop
}
while true; do
if ! "$script_dir"/keepalivedctl status; then
"$script_dir"/keepalivedctl start
fi
if ip addr | grep -q "$HARBOR_VIP"; then
echo "vip is here"
if ! "$script_dir"/harborctl status; then
"$script_dir"/harborctl start
fi
else
echo "vip is not here"
"$script_dir"/harborctl stop
fi
sleep 2
done