On Thu, Nov 05, 2020 at 10:13:19AM +0800, Lu Weitao wrote:
On Thu, Nov 05, 2020 at 09:57:30AM +0800, Zhang Yuhang wrote:
[why] We need a script to create "repo" mapping in es.
Signed-off-by: Zhang Yuhang zhangyuhang25@huawei.com
sbin/es-repo-mapping.sh | 78 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100755 sbin/es-repo-mapping.sh
diff --git a/sbin/es-repo-mapping.sh b/sbin/es-repo-mapping.sh new file mode 100755 index 0000000..ce0ad74 --- /dev/null +++ b/sbin/es-repo-mapping.sh @@ -0,0 +1,78 @@ +#!/bin/sh +# SPDX-License-Identifier: MulanPSL-2.0+ +# Copyright (c) 2020 Huawei Technologies Co., Ltd. All rights reserved.
+# Determine whether curl is installed. If not, install curl. +if ! [ -x "$(command -v curl)" ] +then
- echo "curl not exists, try to install."
- if [ -x "$(command -v apk)" ]
- then
apk add install -y curl
- elif [ -x "$(command -v yum)" ]
- then
yum install -y curl
- elif [ -x "$(command -v apt-get)" ]
- then
apt-get install -y curl
- fi
+else
- echo "curl has install."
+fi
+# Determine whether curl is installed successfully +if [ $? -ne 0 ] +then
- echo "curl install failed, exit."
- exit
+fi
+# Determine whether repo index has created +status_code=$(curl -sIL -w "%{http_code}\n" -o /dev/null http://localhost:9200/repo)
how about "repo" => "repos"
Thanks, Weitao
Thanks, I think "repo" better.
This an example of tutorial to index document.
PUT /customer/_doc/1 { "name": "John Doe" }
https://www.elastic.co/guide/en/elasticsearch/reference/current/getting-star...
Thanks, Zhang Yuhang
+if [ $status_code -eq 200 ] +then
- echo "repo index has create, exit."
+else
- echo "repo index not exists, begin create index."
- curl -H 'Content-Type: Application/json' -XPUT 'http://localhost:9200/repo' -d '
- {
"mappings": {
"_doc": {
"properties": {
"git_repo": {
"type": "keyword"
},
"pkgbuild_repo": {
"type": "keyword"
},
"url": {
"type": "keyword"
},
"fetch_time": {
"type": "keyword"
},
"new_refs_time": {
"type": "keyword"
},
"offset_fetch": {
"type": "long"
},
"offset_new_refs": {
"type": "long"
},
"priority": {
"type": "long"
},
"queued": {
"type": "boolean"
}
}
}
}
- }'
- if [ $? -ne 0 ]
- then
echo "create repo index failed."
- fi
+fi
2.23.0