Add script for updating riot-web

This commit is contained in:
Lucas 2020-03-14 15:37:25 +00:00
parent fa6fbb9e3c
commit 17b440be69

View File

@ -0,0 +1,34 @@
#!/bin/sh
usage()
{
printf "Usage: %s version\n" "${0##*/}" >&2
exit 1
}
err()
{
printf "%s: %s\n" "${0##*/}" "$*" >&2
exit 1
}
isversion()
{
printf "%s\n" "$*" | grep -Eq "^v[0-9]+\.[0-9]+\.[0-9]+$"
}
if [ -z "${RIOT_WEB_UI_DIR:-}" ]; then
err "Environment RIOT_WEB_UI_DIR unset"
fi
if [ $# -ne 1 ] || ! isversion "$1"; then
usage
fi
ver=$1
GH_BASE_URL=https://github.com/vector-im/riot-web/releases/download
cd "$RIOT_WEB_UI_DIR" || err "Can't cd to web UI directory"
ftp -o - "$GH_BASE_URL/$ver/riot-$ver.tar.gz" | pax -rz ||
err "Can't fetch and extract release"
rm -f riot && ln -s "riot-$ver" riot ||
err "Can't point web UI directory to new release"