Add old version remover
This commit is contained in:
@@ -1,17 +1,11 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
GITEALATESTVERSION="$(curl https://dl.gitea.com/gitea/version.json 2>/dev/null | jq -r .latest.version)"
|
for GITEALOCALAPPBIN in "/opt/gitea/app/bin" "./app/bin" "../../app/bin"; do
|
||||||
|
# echo ${GITEALOCALAPPBIN}
|
||||||
#GITEALATESTVERSION="1.20"
|
if [ -d "${GITEALOCALAPPBIN}" ]; then
|
||||||
|
break
|
||||||
GITEALATESTFILE="gitea-${GITEALATESTVERSION}-linux-amd64"
|
fi
|
||||||
GITEALATESTURLXZ="https://dl.gitea.com/gitea/${GITEALATESTVERSION}/${GITEALATESTFILE}.xz"
|
done
|
||||||
GITEALATESTURLXZASC="https://dl.gitea.com/gitea/${GITEALATESTVERSION}/${GITEALATESTFILE}.xz.asc"
|
|
||||||
|
|
||||||
GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|
||||||
|
|
||||||
#echo $GITEALATESTURLXZASC
|
|
||||||
#exit
|
|
||||||
|
|
||||||
if [ ! -d "${GITEALOCALAPPBIN}" ]; then
|
if [ ! -d "${GITEALOCALAPPBIN}" ]; then
|
||||||
echo "Directory ${GITEALOCALAPPBIN} not found"
|
echo "Directory ${GITEALOCALAPPBIN} not found"
|
||||||
@@ -19,7 +13,7 @@ GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ x"$1" == x"--self-install" ]; then
|
if [ x"$1" == x"--self-install" ]; then
|
||||||
ln -s "../../../gitea-loader.git/gitea-loader.sh" "${GITEALOCALAPPBIN}/gitea-loader.sh" && {
|
ln -s "../../gitea-loader/gitea-loader.sh" "${GITEALOCALAPPBIN}/gitea-loader.sh" && {
|
||||||
echo "Success installed ${GITEALOCALAPPBIN}/gitea-loader.sh"
|
echo "Success installed ${GITEALOCALAPPBIN}/gitea-loader.sh"
|
||||||
exit 0
|
exit 0
|
||||||
} || {
|
} || {
|
||||||
@@ -33,6 +27,14 @@ GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
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"
|
||||||
|
|
||||||
while true; do
|
while true; do
|
||||||
if [ -f "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz" ]; then
|
if [ -f "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz" ]; then
|
||||||
echo "Gitea version ${GITEALATESTVERSION} exists"
|
echo "Gitea version ${GITEALATESTVERSION} exists"
|
||||||
@@ -50,6 +52,11 @@ GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|||||||
break
|
break
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if [ x"${GITEALATESTVERSION}" = x"" ]; then
|
||||||
|
echo "Empty GITEALATESTVERSION"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Download gitea version ${GITEALATESTVERSION}"
|
echo "Download gitea version ${GITEALATESTVERSION}"
|
||||||
|
|
||||||
curl "${GITEALATESTURLXZ}" 2>/dev/null > "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" && {
|
curl "${GITEALATESTURLXZ}" 2>/dev/null > "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" && {
|
||||||
@@ -57,7 +64,7 @@ GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|||||||
mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz"
|
mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz"
|
||||||
} || {
|
} || {
|
||||||
echo "Failed"
|
echo "Failed"
|
||||||
rm "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part"
|
rm -vf "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.xz.part"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -68,8 +75,41 @@ GITEALOCALAPPBIN="/opt/gitea/app/bin"
|
|||||||
mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
mv "${GITEALOCALAPPBIN}/${GITEALATESTFILE}.part" "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
||||||
} || {
|
} || {
|
||||||
echo "Failed"
|
echo "Failed"
|
||||||
rm "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
rm -vf "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
chmod +x "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
chmod +x "${GITEALOCALAPPBIN}/${GITEALATESTFILE}"
|
||||||
|
|
||||||
|
|
||||||
|
curl \
|
||||||
|
-L -H "Accept: application/vnd.github+json" -H "X-GitHub-Api-Version: 2022-11-28" \
|
||||||
|
"https://api.github.com/repos/go-gitea/gitea/releases?per_page=15" > "gitea-releases.json"
|
||||||
|
|
||||||
|
for x in {3..15}; do
|
||||||
|
GITEAVERSION="$(cat gitea-releases.json | jq -r ".[$x].tag_name" | grep -aoE '[0-9]+\.[0-9]+\.[0-9]+')"
|
||||||
|
|
||||||
|
GITEABIN="--"
|
||||||
|
GITEARCH="--"
|
||||||
|
|
||||||
|
GITEABINFILE="${GITEALOCALAPPBIN}/gitea-${GITEAVERSION}-linux-amd64"
|
||||||
|
GITEARCHFILE="${GITEALOCALAPPBIN}/gitea-${GITEAVERSION}-linux-amd64.xz"
|
||||||
|
|
||||||
|
if [ -f "${GITEABINFILE}" ]; then
|
||||||
|
GITEABIN="OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -f "${GITEARCHFILE}" ]; then
|
||||||
|
GITEARCH="OK"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# echo ${GITEAVERSION} ${GITEABIN} ${GITEAARCH}
|
||||||
|
|
||||||
|
if [ x"${GITEABIN}" = x"OK" ]; then
|
||||||
|
echo rm "${GITEABINFILE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $x -gt 7 -a x"${GITEARCH}" = x"OK" ]; then
|
||||||
|
echo rm "${GITEARCHFILE}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
Reference in New Issue
Block a user