forked from TheHive-Project/Cortex-Analyzers
-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_catalogs.sh
executable file
·34 lines (28 loc) · 1.13 KB
/
update_catalogs.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
#!/usr/bin/env bash
build_catalog() {
DIR=$1
echo '[' > ${DIR}/catalog.json
echo '[' > ${DIR}/catalog-devel.json
echo '[' > ${DIR}/catalog-stable.json
first=1
for JSON in ${DIR}/*/*.json
do
if test -z "${first}"
then
echo ',' >> ${DIR}/catalog.json
echo ',' >> ${DIR}/catalog-devel.json
echo ',' >> ${DIR}/catalog-stable.json
else
first=
fi
jq 'del(.command) + { dockerImage: ("cortexneurons/" + (.name | ascii_downcase) + ":devel") }' ${JSON} >> ${DIR}/catalog-devel.json
jq 'del(.command) + { dockerImage: ("cortexneurons/" + (.name | ascii_downcase) + ":" + .version) }' ${JSON} >> ${DIR}/catalog-stable.json
jq 'del(.command) + { dockerImage: ("cortexneurons/" + (.name | ascii_downcase) + ":" + (.version | split("."))[0]) }' ${JSON} >> ${DIR}/catalog.json
done
echo ']' >> ${DIR}/catalog.json
echo ']' >> ${DIR}/catalog-devel.json
echo ']' >> ${DIR}/catalog-stable.json
}
BASE_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
build_catalog ${BASE_DIR}/analyzers
build_catalog ${BASE_DIR}/responders