forked from TencentBlueKing/bk-repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbk-repo-consul-kv-set.sh
executable file
·44 lines (35 loc) · 1.17 KB
/
bk-repo-consul-kv-set.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
#!/bin/bash
# shellcheck disable=SC2128
set -eu
trap "on_ERR;" ERR
on_ERR (){
local fn=$0 ret=$? lineno=${BASH_LINENO:-$LINENO}
echo >&2 "ERROR $fn exit with $ret at line $lineno: $(sed -n ${lineno}p $0)."
}
set -a
CTRL_DIR="${CTRL_DIR}"
source ${CTRL_DIR:-/data/install}/load_env.sh
set +a
BK_PKG_SRC_PATH=${BK_REPO_SRC_DIR:-/data/src}
BK_REPO_HOME="${BK_REPO_HOME:-/data/bkce/repo}"
echo "Put kv value to Consul"
if [[ -f $BK_HOME/etc/repo/application.yaml ]] ; then
consul kv put bkrepo-config/application/data @$BK_HOME/etc/repo/application.yaml || return $?
else
echo "$BK_HOME/etc/repo/application.yaml not exist"
fi
for x in auth generic repository ; do
if [[ -f $BK_HOME/etc/repo/${x}.yaml ]] ; then
consul kv put bkrepo-config/repo-${x}/data @$BK_HOME/etc/repo/${x}.yaml || return $?
else
echo "$BK_HOME/etc/repo/${x}.yaml not exist"
fi
done
echo "get application data"
consul kv get bkrepo-config/application/data
echo "get repo-auth data"
consul kv get bkrepo-config/repo-auth/data
echo "get repo-generic data"
consul kv get bkrepo-config/repo-generic/data
echo "get repo-repository data"
consul kv get bkrepo-config/repo-repository/data