-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathupdate_binfile.sh
40 lines (39 loc) · 1.29 KB
/
update_binfile.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
col=$((`cat COL.txt`))
eips $col 3 "Updating..."
repo="https://github.com/filebrowser/filebrowser"
artifact="linux-armv7-filebrowser.tar.gz"
LATEST_RELEASE=$(curl -L -s -H 'Accept: application/json' "$repo/releases/latest")
# echo $LATEST_RELEASE
# The releases are returned in the format {"id":3622206,"tag_name":"hello-1.0.0.11",...}, we have to extract the tag_name.
LATEST_VERSION=$(echo $LATEST_RELEASE | sed -e 's/.*"tag_name":"\([^"]*\)".*/\1/')
# echo $LATEST_VERSION
[ -e "BINFILE_VERSION" ] && LOCAL_VERSION=`cat BINFILE_VERSION`
if [ -z "${LATEST_VERSION}" ]
then
echo "connection failed"
exit 1
fi
if [ "${LATEST_VERSION}" != "${LOCAL_VERSION}" ]
then
echo "latest \"$LATEST_VERSION\", local \"$LOCAL_VERSION\""
ARTIFACT_URL="$repo/releases/download/$LATEST_VERSION/$artifact"
[ -e "$artifact" ] || wget $ARTIFACT_URL
if [ -e "$artifact" ]
then
tar -xf "$artifact"
ret=$?
if [ $ret -ne 0 ]; then
echo "broken file: $artifact"
rm "$artifact"
exit 2
fi
echo "$LATEST_VERSION" >BINFILE_VERSION
rm "$artifact"
echo "successfully update to $LATEST_VERSION"
else
echo "download faled"
exit 3
fi
else
echo "local version $LOCAL_VERSION is already up to date"
fi