A bash script to update element-web

I got tired of manually updating Element Web to the newest version so I made a simple script to do most of the work for me.

All you have to provide is the new version of element-web and confirm that the signature is correct. Everything else is handled by the script.

The script should be called from the directory where element-web is currently installed so that the files are downloaded to the correct location. The script assumes www-data owns the directory and that the files are located in /var/www/element.site (change to your own custom directory). The script also copies config.json and welcome.html to the new version directory as I have made changes to them that I’d like to keep. My setup of nginx uses /var/www/element for Element Web which is why the link is created.

Not a work of art, but it works : )

1. git clone https://github.com/drakfrid/matrix-update-element.git
2. Edit the script to your liking
3. sh ./update-element.sh
#!/bin/bash
# Script for semi-automatically updating Element Web
# Run from the directory where Element Web is located (e.g. /var/www/element/)
# Edit this script before running the first time

set -x # for debugging / more info

read -p "Version? (e.g. 1.11.30) " _version

echo "downloading from gh"
wget https://github.com/vector-im/element-web/releases/download/v"$_version"/element-v"$_version".tar.gz.asc https://github.com/vector-im/element-web/releases/download/v"$_version"/element-v"$_version".tar.gz

if [ "$?" -ne 0 ]; then exit; fi

echo "verifying"
# You need to have imported the element release key to do this (https://github.com/vector-im/element-web#getting-started)
gpg --verify element-v"$_version".tar.gz.asc element-v"$_version".tar.gz
read -p "Is the signature good? (y/n) " _good
case "$_good" in 
  y|Y ) echo "yes";;
  n|N ) echo "no" && exit;;
  * ) echo "invalid" && exit;;
esac

echo "untar"
tar -xzf element-v"$_version".tar.gz

# Copy old files
echo "copying modified files from old version"
cp element/{config.json,welcome.html} element-v"$_version"/

echo "changing owner"
chown -R www-data:www-data element-v"$_version"

echo "create new link"
rm element && ln -s /var/www/element.site/element-v"$_version" /var/www/element.site/element

echo "delete downloaded files"
rm element-v"$_version".tar.gz.asc element-v"$_version".tar.gz

Lämna en kommentar

Din e-postadress kommer inte publiceras. Obligatoriska fält är märkta *