-
Notifications
You must be signed in to change notification settings - Fork 17
/
gitea-update.sh
29 lines (25 loc) · 1.19 KB
/
gitea-update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
# This script is used to auto-update Gitea when new versions come out
NEW_VERSION=$(curl -sL https://github.com/go-gitea/gitea/releases/latest | grep -Po '(?<=v)\d.\d\d.\d' | cut -d" " -f1 | head -n 1)
LOCATION=$(which gitea)
CURRENT_VERSION=$(gitea -v | grep -Po '\d.\d\d.\d')
if [ "$CURRENT_VERSION" != "$NEW_VERSION" ]; then
wget "https://dl.gitea.io/gitea/$NEW_VERSION/gitea-$NEW_VERSION-linux-arm-6" -O /tmp/gitea
if [ -f /tmp/gitea ]; then
printf "[*] Successfully downloaded Gitea v$NEW_VERSION \n"
chmod a+x /tmp/gitea
mv $LOCATION $LOCATION.$CURRENT_VERSION.old
mv /tmp/gitea $LOCATION
printf "[*] Saved Gitea v$CURRENT_VERSION as $LOCATION.$CURRENT_VERSION.old \n"
else
printf "[!] Failed to dowload Gitea. Check your internet connection and verify https://dl.gitea.io is accessible\n"
exit 1
fi
if [ ! command -v $LOCATION &> /dev/null ]; then
printf "[!] FAILED to update Gitea \n"
exit 1
fi
else
printf "[*] Using the most current version of Gitea $CURRENT_VERSION \n"
gitea -v
fi