Skip to content

Instantly share code, notes, and snippets.

@MurzNN MurzNN/riot-web-update.sh
Last active Jan 20, 2020

Embed
What would you like to do?
riot-web-update.sh - bash script for auto-update Riot.im to latest version from GitHub vector-im/riot-web project releases
#!/bin/bash
# Directory where Riot files must be placed
DIRECTORY_INSTALL=~/public_html
# Directory for temp files - must be different that install directory!
DIRECTORY_TMP=/tmp
command -v curl >/dev/null 2>&1 || { echo "You need to install "curl" package for this script: sudo apt install curl"; exit 1; }
command -v tar >/dev/null 2>&1 || { echo "You need to install "tar" package for this script: sudo apt install tar"; exit 1; }
command -v jq >/dev/null 2>&1 || { echo "You need to install "jq" package for this script: sudo apt install jq"; exit 1; }
VERSION_INSTALLED=`cat $DIRECTORY_INSTALL/version`
VERSION_LATEST=`curl -s https://api.github.com/repos/vector-im/riot-web/releases/latest | jq -r '.name' | sed s/v//` || { echo "Error checkinv last Riot version!"; exit 1; }
if [ "$VERSION_INSTALLED" != "$VERSION_LATEST" ]; then
echo "Riot installed version is $VERSION_INSTALLED, in GitHub releases found fresher version: $VERSION_LATEST - updating..."
DL_URL=`curl -s https://api.github.com/repos/vector-im/riot-web/releases/latest | jq -r '.assets[0].browser_download_url'`
curl -L -o $DIRECTORY_TMP/riot-latest.tar.gz $DL_URL || { echo "Error downloading riot-latest.tar.gz"; exit 1; }
tar -xf $DIRECTORY_TMP/riot-latest.tar.gz -C $DIRECTORY_TMP/
find $DIRECTORY_INSTALL/* -not -name 'config*.json' -delete
rm -f $DIRECTORY_INSTALL/config.sample.json
mv $DIRECTORY_TMP/riot-v$VERSION_LATEST/* $DIRECTORY_INSTALL/
rm -rf $DIRECTORY_TMP/riot-v$VERSION_LATEST
rm $DIRECTORY_TMP/riot-latest.tar.gz
echo "Riot succesfully updated from $VERSION_INSTALLED to $VERSION_LATEST";
else
echo "Current Riot version $VERSION_INSTALLED is last, no update found, exiting.";
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.