2020-03-14 16:37:25 +01:00
|
|
|
#!/bin/sh
|
2020-05-03 16:47:27 +02:00
|
|
|
# env
|
|
|
|
# Written in 2020 by Lucas
|
|
|
|
# CC0 1.0 Universal/Public domain - No rights reserved
|
|
|
|
#
|
|
|
|
# To the extent possible under law, the author(s) have dedicated all
|
|
|
|
# copyright and related and neighboring rights to this software to the
|
|
|
|
# public domain worldwide. This software is distributed without any
|
|
|
|
# warranty. You should have received a copy of the CC0 Public Domain
|
|
|
|
# Dedication along with this software. If not, see
|
|
|
|
# <http://creativecommons.org/publicdomain/zero/1.0/>.
|
|
|
|
|
2020-03-14 16:37:25 +01:00
|
|
|
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]+$"
|
|
|
|
}
|
|
|
|
|
2020-10-03 18:05:14 +02:00
|
|
|
[ -n "${ELEMENT_WEB_UI_DIR:-}" ] ||
|
|
|
|
err "environment var ELEMENT_WEB_UI_DIR unset"
|
2020-05-03 16:47:27 +02:00
|
|
|
[ $# -eq 1 ] && isversion "$1" || usage
|
2020-03-14 16:37:25 +01:00
|
|
|
ver=$1
|
|
|
|
|
2020-10-03 18:05:14 +02:00
|
|
|
GH_BASE_URL=https://github.com/vector-im/element-web/releases/download
|
2020-03-14 16:37:25 +01:00
|
|
|
|
2020-10-03 18:05:14 +02:00
|
|
|
cd "$ELEMENT_WEB_UI_DIR" || err "can't cd to web UI directory"
|
2020-12-21 13:18:38 +01:00
|
|
|
ftp -o - "$GH_BASE_URL/$ver/element-$ver.tar.gz" | pax -rz ||
|
2020-05-03 16:47:27 +02:00
|
|
|
err "can't fetch and extract release"
|
2020-12-21 13:18:38 +01:00
|
|
|
rm -f element && ln -s "element-$ver" element ||
|
2020-05-03 16:47:27 +02:00
|
|
|
err "can't point web UI directory to new release"
|