Skip to content

Commit

Permalink
add update_binfile.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
guo-yong-zhi committed Jul 17, 2022
1 parent 1af4ea5 commit bfa3fbb
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions update_binfile.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
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

0 comments on commit bfa3fbb

Please sign in to comment.