Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contrib/upgrade.sh #18286

Merged
merged 22 commits into from
Feb 6, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions contrib/upgrade.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
noerw marked this conversation as resolved.
Show resolved Hide resolved
set -e
noerw marked this conversation as resolved.
Show resolved Hide resolved

# this is an upgrade script, for gitea deployed on linux as systemd service
# depends on: curl, xz, sha256sum, gpg
# usage: upgrade.sh [version]

# change the variables below for your local setup
giteaversion=${1:-1.15.10}
noerw marked this conversation as resolved.
Show resolved Hide resolved
giteabin=/usr/local/bin/gitea
giteahome=/var/lib/gitea
giteaconf=/etc/gitea/app.ini
giteauser="git"
noerw marked this conversation as resolved.
Show resolved Hide resolved
giteacmd="sudo -u $giteauser $giteabin -c $giteaconf -w $giteahome"
noerw marked this conversation as resolved.
Show resolved Hide resolved

# download new binary
binname=gitea-${giteaversion}-linux-amd64
binurl="https://dl.gitea.io/gitea/${giteaversion}/${binname}.xz"
echo downloading $binurl
noerw marked this conversation as resolved.
Show resolved Hide resolved
cd $giteahome # needed for gitea dump later
noerw marked this conversation as resolved.
Show resolved Hide resolved
curl -sSfL "$binurl" > ${binname}.xz
noerw marked this conversation as resolved.
Show resolved Hide resolved
curl -sSfL "${binurl}.sha256" > ${binname}.xz.sha256
curl -sSfL "${binurl}.asc" > ${binname}.xz.asc

# validate checksum & gpg signature (exit script if error)
sha256sum -c ${binname}.xz.sha256
gpg --keyserver keys.openpgp.org --recv 7C9E68152594688862D62AF62D9AE806EC1592E2
noerw marked this conversation as resolved.
Show resolved Hide resolved
gpg --verify ${binname}.xz.asc ${binname}.xz
rm ${binname}.xz.{sha256,asc}

# unpack binary + make executable
xz -d ${binname}.xz
chmod +x $binname
noerw marked this conversation as resolved.
Show resolved Hide resolved

# stop gitea, create backup, replace binary, restart gitea
$giteacmd manager flush-queues
systemctl stop gitea
noerw marked this conversation as resolved.
Show resolved Hide resolved
$giteacmd --version
noerw marked this conversation as resolved.
Show resolved Hide resolved
$giteacmd dump
noerw marked this conversation as resolved.
Show resolved Hide resolved
mv -fb $binname $giteabin
noerw marked this conversation as resolved.
Show resolved Hide resolved
systemctl start gitea
2 changes: 2 additions & 0 deletions docs/content/doc/upgrade/from-gitea.en-us.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ a snapshot for the Gitea data volume and related object storage is more convenie
* Replace the installed Gitea binary with the downloaded one.
* Start the Gitea instance.

A script automating these steps for a deployment on Linux can be found at [`contrib/upgrade.sh` in Gitea's source tree](https://github.com/go-gitea/gitea/blob/main/contrib/upgrade.sh).

## Take care about customized templates

Gitea's template structure and variables may change between releases, if you are using customized templates,
Expand Down