forge/bin/upgrade

63 lines
2.0 KiB
Bash
Executable File

#!/bin/bash
# Author: Cpm
# License: GNU AGPLv3+
#set -ex
BINDIR=/srv/forgejo/bin
GITEA_HOME=/srv/forgejo
export GITEA_WORK_DIR=/srv/forgejo
cd $BINDIR
if [ -z "$1" ]; then
echo "Need version value."
else
#
VERSION="$1"
# Verify.
if ./forgejo --version | grep -q "version $VERSION " ; then
echo "Same version."
else
# Download the binary file.
wget https://codeberg.org/forgejo/forgejo/releases/download/v${VERSION}/forgejo-${VERSION}-linux-amd64
# Check the binary file.
wget https://codeberg.org/forgejo/forgejo/releases/download/v${VERSION}/forgejo-${VERSION}-linux-amd64.sha256
sha256sum -c forgejo-${VERSION}-linux-amd64.sha256
# Verify the binary file.
wget https://codeberg.org/forgejo/forgejo/releases/download/v${VERSION}/forgejo-${VERSION}-linux-amd64.asc
gpg --keyserver keys.openpgp.org --recv EB114F5E6C0DC2BCDD183550A4B61A2DC5923710
gpg --verify forgejo-${VERSION}-linux-amd64.asc forgejo-${VERSION}-linux-amd64
# Flush queues.
su - git -c "cd /srv/forgejo/bin ; $BINDIR/forgejo -c /etc/forgejo/forgejo.ini manager flush-queues"
# Stop.
systemctl stop forgejo
# Call doctor.
su - git -c "cd /srv/forgejo/bin ; $BINDIR/forgejo doctor --all --fix -c /etc/forgejo/forgejo.ini -C /srv/forgejo/custom -w /srv/forgejo/"
# Dump.
su - git -c "cd /srv/forgejo/bin ; $BINDIR/forgejo dump --tempdir $GITEA_HOME/tmp/ -c /etc/forgejo/forgejo.ini -C /srv/forgejo/custom -w /srv/forgejo/"
# Upgrade.
chmod u+x forgejo-${VERSION}-linux-amd64
chown git.git forgejo-${VERSION}-linux-amd64
ln --force forgejo-${VERSION}-linux-amd64 forgejo
# Start.
#systemctl start forgejo
echo "Please, check then start the service Forgejo."
read -e -p "Start Forgejo service? [Y/n] " choice
if [[ "$choice" =~ ^[yY]$ ]]; then
echo "Restarting…"
systemctl start forgejo
journalctl -f -u forgejo
fi
fi
fi