diff --git a/download-act_runner.sh b/download-act_runner.sh old mode 100644 new mode 100755 index a0b992e..8eb3dfa --- a/download-act_runner.sh +++ b/download-act_runner.sh @@ -4,6 +4,18 @@ BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/"; # shellcheck source=init.sh . "${BASE_FOLDER}init.sh"; +download_file=$(curl -s https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest |\ + jq ".assets[].browser_download_url" |\ + cut -d '"' -f 2 |\ + grep "${arch}$"); +version=$(echo "${download_file}" | cut -d "/" -f 8); +file=$(echo "${download_file}" | cut -d "/" -f 9); +if [ -f "${download_folder}/${file}" ]; then + echo "[!] File ${file} has already been downloaded"; + exit; +fi; +echo "act_runner version to download: ${version}"; + cd "${download_folder}" || exit; curl -s https://gitea.com/api/v1/repos/gitea/act_runner/releases/latest |\ jq ".assets[].browser_download_url" |\ diff --git a/download.sh b/download.sh index 61c19ab..338aff5 100755 --- a/download.sh +++ b/download.sh @@ -4,11 +4,21 @@ BASE_FOLDER=$(dirname "$(readlink -f "$0")")"/"; # shellcheck source=init.sh . "${BASE_FOLDER}init.sh"; -cd "${download_folder}" || exit; -curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest |\ +download_file=$(curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest |\ grep browser_download_url |\ cut -d '"' -f 4 |\ - grep "${arch}$" |\ + grep "${arch}$"); + +version=$(echo "${download_file}" | cut -d "/" -f 8); +file=$(echo "${download_file}" | cut -d "/" -f 9); +if [ -f "${download_folder}/${file}" ]; then + echo "[!] File ${file} has already been downloaded"; + exit; +fi; +echo "gitea version to download: ${version}"; + +cd "${download_folder}" || exit; +echo "${download_file}" |\ xargs curl -LJO --output-dir "${download_folder}" cd - || exit; diff --git a/init.sh b/init.sh index 840f74a..0efdccb 100644 --- a/init.sh +++ b/init.sh @@ -30,16 +30,18 @@ if [ ! -d "${download_folder}" ]; then exit; fi; target_file="/usr/local/bin/gitea"; +gitea_exists=1; if [ ! -f "${target_file}" ]; then - echo "There is no gitea target file at ${target_file}. Is gitea installed?"; - exit; + echo "[!] There is no gitea target file at ${target_file}. Is gitea installed?"; + gitea_exists=0; fi; target_file_act_runner="/usr/local/bin/act_runner"; +act_runner_exists=1 if [ ! -f "${target_file_act_runner}" ]; then - echo "There is no gitea action runner target file at ${target_file}. Is gitea action runner installed?"; - exit; + echo "[!] There is no gitea action runner target file at ${target_file}. Is gitea action runner installed?"; + act_runner_exists=0 fi; -export arch target_file; +export arch target_file gitea_exists act_runner_exists; # __END__ diff --git a/install-act_runner.sh b/install-act_runner.sh index c678a73..4e30091 100755 --- a/install-act_runner.sh +++ b/install-act_runner.sh @@ -17,7 +17,7 @@ echo -e "Update gitea action runner to ${1} ... "; systemctl stop act_runner; cp "${download_folder}act_runner-${1}-${arch}" "${target_file_act_runner}"; chmod +x "${target_file_act_runner}"; -systemctl start gitea; +systemctl start act_runner; echo "[DONE]"; # __END__