env/utils/scripts/update-riot-web.sh

35 lines
678 B
Bash

#!/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"