File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -20,18 +20,22 @@ echo "Installing ${BINARY_NAME}..."
2020LATEST_TAG=$( curl -fsSL " https://api.github.com/repos/${REPO} /releases/latest" 2> /dev/null \
2121 | grep ' "tag_name"' | sed ' s/.*"\(.*\)".*/\1/' || true)
2222
23+ DOWNLOADED=false
24+
2325if [[ -n " $LATEST_TAG " ]]; then
2426 echo " Latest release: ${LATEST_TAG} "
25- DOWNLOAD_URL =" https://github.com/${REPO} /releases/download/${LATEST_TAG} /vps-harden.sh"
26- else
27- echo " No releases found, downloading from main branch... "
28- DOWNLOAD_URL= " https://raw.githubusercontent.com/ ${REPO} /main/vps-harden.sh "
27+ RELEASE_URL =" https://github.com/${REPO} /releases/download/${LATEST_TAG} /vps-harden.sh"
28+ if curl -fsSL " $RELEASE_URL " -o " ${INSTALL_DIR} / ${BINARY_NAME} " 2> /dev/null ; then
29+ DOWNLOADED=true
30+ fi
2931fi
3032
31- # Download
32- if ! curl -fsSL " $DOWNLOAD_URL " -o " ${INSTALL_DIR} /${BINARY_NAME} " ; then
33- echo " Error: Failed to download ${BINARY_NAME} " >&2
34- exit 1
33+ if [[ " $DOWNLOADED " != " true" ]]; then
34+ echo " Downloading from main branch..."
35+ if ! curl -fsSL " https://raw.githubusercontent.com/${REPO} /main/vps-harden.sh" -o " ${INSTALL_DIR} /${BINARY_NAME} " ; then
36+ echo " Error: Failed to download ${BINARY_NAME} " >&2
37+ exit 1
38+ fi
3539fi
3640
3741chmod +x " ${INSTALL_DIR} /${BINARY_NAME} "
You can’t perform that action at this time.
0 commit comments