#!/bin/bash # Custom location work="$HOME/apps" # Location of your Gitea installation gitea="$work/gitea" # Location of your Gitea executable # If run as root, yell at me and exit [[ $EUID -eq 0 ]] && echo "Don't use root to manage Gitea... It sucks..." && exit 1 # Check Gitea versions version=$1 [[ -z $version ]] && version=$(curl -s https://github.com/go-gitea/gitea/releases/latest | awk -F 'https://github.com/go-gitea/gitea/releases/tag/v' '{ print $2 }' | awk -F '"' '{ print $1 }') [[ -z $version ]] && echo -e "${c_red}Sélectionne une version\nExemple: 1.12.6$c_" && exit 1 actual=$($gitea --version | awk '{ print $3 }') [[ "$actual" == "$version" ]] && echo -e "${c_green}Votre version de Gitea est à jours (v$actual).$c_" && exit 0 # Start installation echo -e "${c_yellow}Téléchargement de la version $version de Gitea (actuelle $actual) ...$c_" rm -f /tmp/gitea wget -q https://github.com/go-gitea/gitea/releases/download/v$version/gitea-${version}-linux-amd64 -O /tmp/gitea || { echo -e "${c_red}Impossible de télécharger Gitea v$version.$c_\nURL: https://github.com/go-gitea/gitea/releases/download/v$version/gitea-${version}-linux-amd64" && exit 1; } echo -e "${c_yellow}Arrêt de Gitea ... $c_" sudo service gitea stop || { echo -e "${c_red}Impossible d'arrêter gitea$c_" && exit 1; } echo -e "${c_yellow}Renommage de gitea en sa version actuelle $actual...$c_" cd $work rm -f gitea-* mv $gitea ${gitea}-$actual || { echo -e "${c_red}Impossible de renommer Gitea$c_" && exit 1; } mv /tmp/gitea . chmod u+x $gitea echo -e "${c_yellow}Redémarrage de Gitea ...$c_" sudo service gitea start || { echo -e "${c_red}Impossible de démarer Gitea ...$c_" && exit 1; } echo -e "${c_green}Mise à jours terminée,$c_" exit 0