diff --git a/utils/scripts/update-riot-web.sh b/utils/scripts/update-riot-web.sh new file mode 100644 index 0000000..49aa1de --- /dev/null +++ b/utils/scripts/update-riot-web.sh @@ -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"