Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
Simple bash-script installer to install Gitea on Ubuntu server. It's an alternative for server who can't run docker
properly (e.x. LXC)

# Gitea-updater
Simple bash-script updater. Can be put to cron to regularly check gitea updates.

## Tutorials

[![Mainhoster (ehemals Go2Prepaid) Gitea Video (Installation)][gitea-tutorial-go2prepaid-thumbnail]][gitea-tutorial-go2prepaid-video]
Expand Down
7 changes: 7 additions & 0 deletions gitea-download-url.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash

# Share the download gitea last github available version
gitea_latest_version=${1:-$(curl --silent "https://api.github.com/repos/go-gitea/gitea/releases/latest" | jq -r '.tag_name' 2>&1 | sed -e 's|.*-||' -e 's|^v||')}
gitea_download_url_default="https://github.com/go-gitea/gitea/releases/download/v${gitea_latest_version}/gitea-${gitea_latest_version}-linux-amd64"

export gitea_latest_version gitea_download_url_default
38 changes: 38 additions & 0 deletions gitea-updater-en.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/bin/bash

# Installed version
installed_version=$(/usr/local/bin/gitea --version | cut -f 3 -d " ")
installed_version_ma=$(echo $installed_version | cut -d'.' -f1)
installed_version_mi=$(echo $installed_version | cut -d'.' -f2)
installed_version_re=$(echo $installed_version | cut -d'.' -f3)

# Last released version
source ./gitea-download-url.sh
latest_version_ma=$(echo $gitea_latest_version | cut -d'.' -f1)
latest_version_mi=$(echo $gitea_latest_version | cut -d'.' -f2)
latest_version_re=$(echo $gitea_latest_version | cut -d'.' -f3)

# Verify if the released version is greatest than installed version
if [ $latest_version_ma -gt $installed_version_ma ] ||
([ $latest_version_ma -eq $installed_version_ma ] && [ $latest_version_mi -gt $installed_version_mi ]) ||
([ $latest_version_ma -eq $installed_version_ma ] && [ $latest_version_mi -eq $installed_version_mi ] && [ $latest_version_re -gt $installed_version_re ])
then
echo "Current version: $installed_version, latest version: $gitea_latest_version. Upgrading..."
# Stop gitea service
systemctl stop gitea
# Backup current version
gitea_bin="/usr/local/bin/gitea"
gitea_backup="$gitea_bin-$(date +%Y%m%d%H%M%S)"
mv $gitea_bin $gitea_backup
# Get lastest version
tmpfile=$(mktemp)
wget -q $gitea_download_url_default -O $tmpfile
chmod +x $tmpfile
mv $tmpfile $gitea_bin
# Start gitea version
systemctl start gitea
# Show the backup location
echo "Old version was placed in $gitea_backup"
else
echo "The current version $installed_version is updated"
fi