From 498702b394573187461461a67b91f43225ffac32 Mon Sep 17 00:00:00 2001 From: thorstenspille Date: Sat, 11 Feb 2023 14:47:59 +0100 Subject: [PATCH] gitea: add updater called by apt-hook --- src/gitea/install-service.sh | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/gitea/install-service.sh b/src/gitea/install-service.sh index 5532922..c49eba5 100644 --- a/src/gitea/install-service.sh +++ b/src/gitea/install-service.sh @@ -17,7 +17,7 @@ echo "deb http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" apt update -DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install -y -qq postgresql nginx git ssl-cert unzip zip +DEBIAN_FRONTEND=noninteractive DEBIAN_PRIORITY=critical apt install --no-install-recommends -y -qq postgresql nginx git ssl-cert unzip zip systemctl enable --now postgresql @@ -36,6 +36,32 @@ mkdir -p /${LXC_SHAREFS_MOUNTPOINT}/ chown -R git:git /${LXC_SHAREFS_MOUNTPOINT}/ chmod -R 750 /${LXC_SHAREFS_MOUNTPOINT}/ +cat << EOF > /usr/local/bin/update-gitea +PATH="/bin:/usr/bin:/usr/local/bin" +echo "Checking github for new gitea version" +current_version=\$(curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep "tag_name" | cut -d '"' -f4) +installed_version=\$(echo v\$(gitea --version | cut -d ' ' -f3)) +echo "Installed gitea version is \$installed_version" +if [ \$installed_version != \$current_version ]; then + echo "New gitea version \$current_version available. Stopping gitea.service" + systemctl stop gitea.service + echo "Downloading gitea version \$current_version..." + curl -s https://api.github.com/repos/go-gitea/gitea/releases/latest | grep browser_download_url | cut -d '"' -f 4 | grep '\linux-amd64$' | wget -q -O /usr/local/bin/gitea -i - + chmod +x /usr/local/bin/gitea + echo "Starting gitea.service..." + systemctl start gitea.service + echo "gitea update finished!" +else + echo "gitea version is up-to-date!" +fi +EOF +chmod +x /usr/local/bin/update-gitea + +cat << EOF > /etc/apt/apt.conf.d/80-gitea-apt-hook +DPkg::Post-Invoke {"/usr/local/bin/update-gitea";}; +EOF +chmod +x /etc/apt/apt.conf.d/80-gitea-apt-hook + cat << EOF > /etc/systemd/system/gitea.service [Unit] Description=Gitea