From 7463f5a977b3c965957358a242ab35435e394649 Mon Sep 17 00:00:00 2001 From: root Date: Mon, 11 Mar 2024 19:06:54 +0300 Subject: [PATCH] Add exists --- .editorconfig | 6 +++++ .gitignore | 23 ++++++++++++++++ README.MD | 4 +++ get-gitea-latest.sh | 66 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 99 insertions(+) create mode 100644 .editorconfig create mode 100644 .gitignore create mode 100644 README.MD create mode 100755 get-gitea-latest.sh diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..c651587 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,6 @@ + + + [*] + end_of_line = lf + indent_style = tab + tab_width = 4 diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..3716c41 --- /dev/null +++ b/.gitignore @@ -0,0 +1,23 @@ + +**/*_ +**/.#* +**/0* +**/1* +**/2* +**/3* +**/4* +**/5* +**/6* +**/7* +**/8* +**/9* + +**/*.log* +**/*log +**/LOG* + +cache/** +data/** +old/** +outer/** +secret/** diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..b964c4b --- /dev/null +++ b/README.MD @@ -0,0 +1,4 @@ + +# Gitea loader + +From [https://dl.gitea.com/gitea/](https://dl.gitea.com/gitea/)/[version.json](https://dl.gitea.com/gitea/version.json) diff --git a/get-gitea-latest.sh b/get-gitea-latest.sh new file mode 100755 index 0000000..194d20f --- /dev/null +++ b/get-gitea-latest.sh @@ -0,0 +1,66 @@ +#!/bin/bash + +GITEALATESTVERSION="$(curl https://dl.gitea.com/gitea/version.json 2>/dev/null | jq -r .latest.version)" + +#GITEALATESTVERSION="1.20" + +GITEALATESTFILE="gitea-${GITEALATESTVERSION}-linux-amd64" +GITEALATESTURLXZ="https://dl.gitea.com/gitea/${GITEALATESTVERSION}/${GITEALATESTFILE}.xz" +GITEALATESTURLXZASC="https://dl.gitea.com/gitea/${GITEALATESTVERSION}/${GITEALATESTFILE}.xz.asc" + +GITEALOCALAPPBIN="/opt/gitea/app/bin" + +#echo $GITEALATESTURLXZASC +#exit + + jq --version > /dev/null 2>&1 || { + echo "Command jq not found" + exit 1 + } + + if [ ! -d "${GITEALOCALAPPBIN}" ]; then + echo "Directory ${GITEALOCALAPPBIN} not found" + exit 1 + fi + + + while true; do + if [ -f "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz" ]; then + echo "Gitea version ${GITEALATESTVERSION} exists" + exit 0 + fi + + # gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2 + + # gpg --verify gitea-1.20-linux-amd64.xz.asc gitea-1.20-linux-amd64.xz && { + # echo ok + # } || { + # echo no + # } + + break + done + + echo "Download gitea version ${GITEALATESTVERSION}" + + curl "${GITEALATESTURLXZ}" 2>/dev/null > "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" && { + echo "Success" + mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz" + } || { + echo "Failed" + rm "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" + exit 1 + } + + echo "Extract gitea version ${GITEALATESTVERSION}" + + xz -cd "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz" > "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.part" && { + echo "Success" + mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}" + } || { + echo "Failed" + rm "${GITEALOCALAPPBIN}/${GITEALATESTFILE}" + exit 1 + } + + chmod +x "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"