@@ -5,9 +5,9 @@ RED='\033[0;31m'
55GREEN=' \033[0;32m'
66NC=' \033[0m' # No Color
77
8- if [[ -z ${CERT} ]] || [[ -z ${KEY} ]] ; then
9- echo " Missing required credential "
10- exit 1
8+ CURL_OPTS= " "
9+ if [[ ! -z ${CERT} ]] && [[ ! -z ${KEY} ]] ; then
10+ CURL_OPTS= " -E ${CERT} --key ${KEY} "
1111fi
1212
1313if [[ -z ${PKG_REPO} ]]; then
8080check_pkgs () {
8181 for pkg in ${uris[@]} ; do
8282 echo -n " CHECK: ${PKG_REPO_URL} /${pkg} -> "
83- local ret=$( curl -I -s -E " ${CERT} " --key " ${KEY} " " https://${PKG_DIR} /${pkg} " | head -n1 | awk ' { print $2 }' )
83+ local ret=$( curl -I -s ${CURL_OPTS} " https://${PKG_DIR} /${pkg} " | head -n1 | awk ' { print $2 }' )
8484 if [[ ${ret} != 200 ]]; then
8585 echo -e " ${RED}${ret}${NC} "
8686 continue
@@ -98,7 +98,7 @@ dl_pkg () {
9898 local url=${1}
9999 echo -n " GET: ${url} ... "
100100 mkdir -p " ${PKG_DIR} /$( dirname ${pkg} ) "
101- local ret=$( curl -s --fail -E " ${CERT} " --key " ${KEY} " " ${url} " --output " ${PKG_DIR} /${pkg} " )
101+ local ret=$( curl -s --fail ${CURL_OPTS} " ${url} " --output " ${PKG_DIR} /${pkg} " )
102102 if [[ $? != 0 ]]; then
103103 echo -e " ${RED} Download failed!${NC} "
104104 return
@@ -108,16 +108,16 @@ dl_pkg () {
108108
109109check_repo () {
110110 echo -n " Checking package repository ${PKG_REPO_URL} ... "
111- curl -s -I -E " ${CERT} " --key " ${KEY} " " ${PKG_REPO_URL} /index.xml" > /dev/null
111+ curl -s -I ${CURL_OPTS} " ${PKG_REPO_URL} /index.xml" > /dev/null
112112 if [[ $? != 0 ]]; then
113- echo -e " ${RED} *** Error: index.xml not found in $PKG_REPO repository *** ${NC} "
113+ echo -e " ${RED} index.xml not found in ${PKG_REPO_URL} repository${NC} "
114114 exit 1
115115 else
116116 echo -e " ${GREEN} Found!${NC} "
117117 fi
118118
119119 mkdir -p ${PKG_DIR}
120- curl -s -E " ${CERT} " --key " ${KEY} " " ${PKG_REPO_URL} /index.xml" --output " ${PKG_DIR} /index.xml" || exit 2
120+ curl -s ${CURL_OPTS} " ${PKG_REPO_URL} /index.xml" --output " ${PKG_DIR} /index.xml" || exit 2
121121
122122 echo -n " Checking for nginx-agent version ${VERSION} ... "
123123 grep -qnF " ver=\" ${VERSION} \" " " ${PKG_DIR} /index.xml"
0 commit comments