Skip to content

Commit 1a8cd2a

Browse files
committed
rework
1 parent 7b2d749 commit 1a8cd2a

File tree

1 file changed

+10
-19
lines changed

1 file changed

+10
-19
lines changed

scripts/packages/package-check.sh

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -25,20 +25,6 @@ fi
2525
PKG_DIR="${PKG_REPO}/${PKG_NAME}"
2626
PKG_REPO_URL="https://${PKG_DIR}"
2727

28-
# parsing xml in bash
29-
#read_dom () {
30-
# local IFS=\>
31-
# read -d \< ENTITY CONTENT
32-
# local ret=$?
33-
# TAG_NAME=${ENTITY%% *}
34-
# ATTRIBUTES=${ENTITY#* }
35-
# return $ret
36-
#}
37-
#
38-
#while read_dom; do
39-
# if
40-
#done < ${PKG_REPO}/index.xml
41-
4228
APK=(
4329
alpine/v3.21/main/aarch64/nginx-agent-$VERSION.apk
4430
alpine/v3.21/main/x86_64/nginx-agent-$VERSION.apk
@@ -81,7 +67,7 @@ CENTOS=(
8167
centos/8/x86_64/RPMS/nginx-agent-$VERSION.el8.ngx.x86_64.rpm
8268
)
8369

84-
resources=(
70+
uris=(
8571
${DEBIAN[@]}
8672
${UBUNTU[@]}
8773
${CENTOS[@]}
@@ -92,7 +78,7 @@ resources=(
9278

9379
## Check if nginx-agent packages are present and report missing or outdated files
9480
check_pkgs () {
95-
for pkg in ${resources[@]}; do
81+
for pkg in ${uris[@]}; do
9682
echo -n "CHECK: ${PKG_REPO_URL}/${pkg} -> "
9783
local ret=$(curl -I -s -E "${CERT}" --key "${KEY}" "https://${PKG_DIR}/${pkg}" | head -n1 | awk '{ print $2 }')
9884
if [[ ${ret} != 200 ]]; then
@@ -110,9 +96,14 @@ check_pkgs () {
11096

11197
dl_pkg () {
11298
local url=${1}
113-
echo -n "GET: ${url}"
99+
echo -n "GET: ${url}... "
114100
mkdir -p "${PKG_DIR}/$(dirname ${pkg})"
115-
curl -s -E "${CERT}" --key "${KEY}" "https://${PKG_DIR}/${pkg}" --output "${PKG_DIR}/${pkg}" && echo -e " ${GREEN}Done${NC}" || echo -e " ${RED}Download failed!${NC}"
101+
local ret=$(curl -s --fail -E "${CERT}" --key "${KEY}" "${url}" --output "${PKG_DIR}/${pkg}")
102+
if [[ $? != 0 ]]; then
103+
echo -e "${RED}Download failed!${NC}"
104+
return
105+
fi
106+
echo -e "${GREEN}Done${NC}"
116107
}
117108

118109
check_repo() {
@@ -131,7 +122,7 @@ check_repo() {
131122
echo -n "Checking for nginx-agent version ${VERSION}... "
132123
grep -qnF "ver=\"${VERSION}\"" "${PKG_DIR}/index.xml"
133124
if [[ $? != 0 ]]; then
134-
echo -e "${RED}*** Error: ${PKG_NAME} v${VERSION} not found in ${PKG_REPO} ***${NC}"
125+
echo -e "${RED}not found${NC}"
135126
exit 1
136127
else
137128
echo -e "${GREEN}Found!${NC}"

0 commit comments

Comments
 (0)