I’m a Gitea user for a long time now. Gitea is a nice application to build your own light and fast version of git hosting services like GitHub or GitLab.

Gitea has one problem thought. It doesn’t update automatically. A issue for that is open nearly 2 years: https://github.com/go-gitea/gitea/issues/518#issuecomment-441742904

If there is one thing that I really hate, it is that a security sensible web application doesn’t update automatically. Because of that I have begun to write a update script for Gitea before 4 months.

That script has updated my Gitea instance multiple times now and as I can see, that many users have the same problem (a german blog post from me is my most visited article from outside germany), I want to show you my solution.

Update#

If you want to update Gitea and other software (like Drone, Caddy, Podman, Python, Zitadel and Kanboard), you should check out Autoupdate.

This new tool of mine was built as a single binary with a config file and tested on multiple Linux systems.

Warning#

As I mentioned - I am no fan of manual upgrades - because of that I write many auto update scripts for my own systems. This scripts often haven’t been tested on other systems and may contain ugly code. I am open for the creation of issues or pull requests which optimise my code. You should definitely check the code out and make sure to review it before using it.

Some creators - e.g. the person behind Kanboard - have a strong option against auto updates. There are good reasons for that too - you may not want to crash your application because of a faulty upgrade. I recommend auto updates only if you create auto backups, too.

The Script#

I have published the actual version to GitHub: https://github.com/CMiksche/gitea-auto-update

The script was made for a Debian and Arch Linux Systems - I haven’t tested it on other systems, but you will definitely encounter errors if you want to use it on Windows, MacOS or a Linux System without systemd (I make bash calls to restart the Gitea service). You may need to modify the script to work on your system.

If the Gitea upgrade changes the template files the automatic update may will destroy your custom design because it is a really simple script and doesn’t check that.

How to use it#

The usage of my script is easy (please read the paragraphs over this first - it won’t work without modifying it if you have no gitea service or no systemd):

  • Install my script on the system:

    pip install gitea-auto-update

  • Create a settings.ini file:

[Gitea]
site=https://your-gitea-instance.com/api/v1/version
apiUrl=https://api.github.com/repos/go-gitea/gitea/releases/latest
system=linux-amd64
file=/usr/local/bin/gitea
tmpDir=/tmp/
buildFromSource=
sourceDir=
logFile=update.log
  • Change the variables in the settings.ini file
  • Enter the command gite-auto-update --settings=/path/to/settings.ini in your command line to test the first upgrade
  • If you want to schedule your updates, edit your /etc/crontab file and add a call to the script

That’s it. Please write a issue if my script doesn’t works. I am caring if people want to use my script ;-)