#!/bin/bash set -e; function error() { echo $@ >&2; } function as() { sudo -u git $@; } checksumType="sha256"; checksumApp="${checksumType}sum"; installed=$(cd ~git && as ./gitea --version | grep -Po "(?<=version )\d+(\.\d+)*(?= )") version=$(curl -s https://blog.gitea.io/index.xml | grep -Po '.*' | grep -Po '\d+(\.\d+)+' | sort -rn | head -n 1); address="https://dl.gitea.io/gitea/$version"; binary="gitea-$version-linux-amd64"; signature="$binary.asc"; checksum="$binary.$checksumType"; if [[ -z "$installed" ]]; then error "Missing version installed"; exit 2; fi if [[ -z "$version" ]]; then error "Missing version available"; exit 2; fi echo "Installed $installed, available $version"; if [[ "$installed" = "$version" ]]; then echo "No update required"; exit 0; fi echo "Update to $version"; cd /home/git; for a in "$binary" "$signature" "$checksum"; do if ! wget --quiet -O "$a" "$address/$a"; then error "Failed to download $a"; exit 1; fi done if ! "$checksumApp" --quiet --check "$checksum"; then error "Checksum not correct!"; exit 1; fi if ! (gpg --status-fd 1 --verify $signature $binary 2>/dev/null | grep -P 'VALIDSIG .* 7C9E68152594688862D62AF62D9AE806EC1592E2' > /dev/null); then error "Signature not valid!"; exit 1; fi rm "$checksum"; rm "$signature"; as ./gitea dump #-c custom/conf/app.ini; mv "$binary" gitea; chmod o+rx gitea; supervisorctl restart git.banananet.work;