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.

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’m developing the script on a private gitea instance - but i don’t wan’t to publish the repository there because i forked from a other private repositiory.

Because of that i have published the actual version to github: https://github.com/CMiksche/gitea-auto-update

The script was made for a Debian System - i haven’t tested it on other systems but you will definitely encounter errors if you wan’t 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):

  • Clone my script on the system:

    git clone https://github.com/CMiksche/gitea-auto-update.git

  • Install requests:

    sudo pip install requests

  • Change the variables in the settings.py file
  • Enter the command python updater.py in your commandline to test the first upgrade
  • If you want to schedule your updates, edit your /etc/crontab file and add a call the 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 ;-)