-
Notifications
You must be signed in to change notification settings - Fork 0
/
uptime-kuma-update.sh
61 lines (53 loc) · 1.22 KB
/
uptime-kuma-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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
APP_NAME="Uptime Kuma"
ORG=louislam # Organisation or GitHub user
REPO=uptime-kuma
GITHUB_API_URL=https://api.github.com/repos/$ORG/$REPO/releases/latest
function get_local_version
{
LOCAL_VERSION=$(git describe --tags)
}
function get_latest_version
{
LATEST_VERSION=$(curl --silent $GITHUB_API_URL |
jq --raw-output .tag_name)
}
function do_update_procedure
{
git fetch --all
git checkout "$LATEST_VERSION" --force
npm ci --production
npm run download-dist
supervisorctl restart uptime-kuma
sleep 3
supervisorctl status
}
## version_lower_than A B
# returns whether A < B
function version_lower_than
{
test "$(echo "$@" |
tr " " "\n" |
sort --version-sort --reverse |
head --lines=1)" != "$1"
}
function main
{
cd ~/uptime-kuma || exit 1
get_local_version
get_latest_version
if [ "$LOCAL_VERSION" = "$LATEST_VERSION" ]
then
echo "Your $APP_NAME is already up to date."
echo "You are running $APP_NAME $LOCAL_VERSION"
else
if version_lower_than "$LOCAL_VERSION" "$LATEST_VERSION"
then
echo "There is a new version available."
echo "Doing update from $LOCAL_VERSION to $LATEST_VERSION"
do_update_procedure
fi
fi
}
main "${@}"
exit $?