Last active
June 22, 2019 11:16
-
-
Save jomat/a2fe027c0ef400c47d6351420f0c2ec4 to your computer and use it in GitHub Desktop.
Script to check latest riot-web release and update it
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/zsh | |
# This script assumes you have a symlinked riot installation, eg | |
# /var/www/html/riot -> /var/www/html/riot-v0.11.4 | |
# | |
# If the local version is older than the github version, it | |
# downloads the latest release, extracts it, copies | |
# config.json and home.html from old to new, removes | |
# the old symlink and sets a new one | |
ATOM="https://github.com/vector-im/riot-web/releases.atom" | |
HTDOCS="/var/www/html/" | |
WGET=`which wget` | |
XMLSTARLET=`which xmlstarlet` | |
[ ! -x "$WGET" ] && echo "wget not found" >&2 && exit 1 | |
[ ! -x "$XMLSTARLET" ] && echo "xmlstarlet not found" >&2 && exit 1 | |
VERSION_GH=$($WGET -qO- $ATOM|$XMLSTARLET sel -N atom="http://www.w3.org/2005/Atom" -t -m '/atom:feed /atom:entry[1]' -v 'atom:title' -n) | |
VERSION_LO=$(readlink ${HTDOCS}/riot|cut -d- -f2-|sed 's:/$::') | |
[ $VERSION_LO = $VERSION_GH ] && echo "already newest version $VERSION_LO" && exit 1 | |
cd $HTDOCS | |
$WGET -q https://github.com/vector-im/riot-web/releases/download/${VERSION_GH}/riot-${VERSION_GH}.tar.gz -O${VERSION_GH}.tar.gz | |
tar zxf ${VERSION_GH}.tar.gz | |
NEWDIR=`tar ztf ${VERSION_GH}.tar.gz --exclude \*/\*` | |
cp riot-${VERSION_LO}/config.json ${NEWDIR} | |
cp riot-${VERSION_LO}/home.html ${NEWDIR} | |
cp riot-${VERSION_LO}/welcome.html ${NEWDIR} | |
rm riot | |
ln -s ${NEWDIR} riot | |
echo Updated from $VERSION_LO to $VERSION_GH >&2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment