-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_json_file.sh
32 lines (30 loc) · 1.02 KB
/
update_json_file.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
#to update the prod_list.json
#cd omnibus-software/config/software
set -x
prod_file="/tmp/prod_list_1.json"
echo "{" >>$prod_file
for FILE in *.rb; do
echo "File name is :$FILE"
prod=$(echo "$FILE" |cut -d "." -f1);
dv=$( grep "default_version" $FILE| cut -d " " -f2)
if echo $dv | grep -qE '[0-9]\.[0-9]+' ;then
url=$(grep "https" $FILE | grep tar | tail -1 | cut -d ":" -f2 -f3 | cut -d "-" -f1)
if [ ! -z "$url" ];then
echo "\"$prod\": {" >> $prod_file;
echo "\"default_version\": $dv ,">> $prod_file;
url1=$(dirname $url)
echo "\"url\": $url1\"," >> $prod_file ;
if [ $prod == "cmake" ] || [ $prod == "nodejs" ] || [ $prod == "openssl-fips" ] || [ $prod == "postgresql" ] ;then
expr1="^v\\\\\d[\\\\\.\\\\\d]*\\\\\d"
echo $expr1
else
expr1="^($prod-)\\\\\d[\\\\\.\\\\\d]*\\\\\d(\\\\\.tar\\\\\.gz)$"
echo "EXPR=$expr1"
fi
echo "\"expr1\": \"$expr1\"">>$prod_file
echo "},">>$prod_file
fi
fi
done;
`printf '%s\n' '$' 's/.$//' wq | ex $prod_file`
echo "}" >>$prod_file