-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcheck-updates.sh
executable file
·80 lines (64 loc) · 1.86 KB
/
check-updates.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/bin/bash
# Uncomment for debugging use
# set -o xtrace
set -o errexit
set -o pipefail
set -o nounset
# Dependencies:
# - curl
# - dpkg-deb
PREV_ETAG="b9efff6abb9dd27169247ab4ec13b229-16"
PREV_RELEASE="1.0.9284034~release"
DEB_URL="https://www.guilded.gg/downloads/Guilded-Linux.deb"
DEB_FILE=$(basename ${DEB_URL})
function check_deb() {
LATEST_ETAG=$(curl --head --silent ${DEB_URL} | \
sed --quiet --regexp-extended 's/etag: \"(.*)\"/\1/p' | \
tr -d '\r')
if [[ "${LATEST_ETAG}" != "${PREV_ETAG}" ]]; then
echo "Etag has changed."
echo "${LATEST_ETAG} > ${PREV_ETAG}."
curl --silent --remote-name ${DEB_URL}
LATEST_RELEASE=$(dpkg-deb --field "${DEB_FILE}" Version | sed 's/-master//')
if [[ "${LATEST_RELEASE}" != "${PREV_RELEASE}" ]]; then
echo "Deb version has changed."
echo "${LATEST_RELEASE} > ${PREV_RELEASE}."
else
echo "Deb version has not changed."
echo "${LATEST_RELEASE} == ${PREV_RELEASE}."
fi
else
echo "Etag has not changed."
echo "${LATEST_ETAG} == ${PREV_ETAG}."
fi
rm -f Guilded-Linux.deb
}
function check_appimage() {
# Example download URL:
# https://s3-us-west-2.amazonaws.com/www.guilded.gg/AppBuilds/linux/Guilded-1.0.9105465-master.AppImage
APP_UPDATE="https://s3-us-west-2.amazonaws.com/www.guilded.gg/AppBuilds/linux/master-linux.yml"
yaml() {
python3 -c "import yaml;print(yaml.safe_load(open('$1'))$2)"
}
curl --silent --remote-name ${APP_UPDATE}
LATEST_RELEASE=$(yaml master-linux.yml "['version']" | sed 's/-master//')
if [[ "${LATEST_RELEASE}" != "${PREV_RELEASE}" ]]; then
echo "AppImage version has changed."
echo "${LATEST_RELEASE} > ${PREV_RELEASE}."
else
echo "AppImage version has not changed."
echo "${LATEST_RELEASE} == ${PREV_RELEASE}."
fi
rm -f master-linux.yml
}
case "$@" in
deb)
check_deb
;;
appimage)
check_appimage
;;
*)
echo "Usage: $0 {deb|appimage}"
;;
esac