Skip to content

Instantly share code, notes, and snippets.

@babolivier
Created July 11, 2018 13:32
Show Gist options
  • Save babolivier/9ac94a5e08d7877aee7277698cd561e0 to your computer and use it in GitHub Desktop.
Save babolivier/9ac94a5e08d7877aee7277698cd561e0 to your computer and use it in GitHub Desktop.
Script to quickly install the desired version of Riot.im
#!/bin/bash -e
# VARIABLES
HTTP_USER="http"
RIOT_REPO="https://github.com/vector-im/riot-web"
WEB_ROOT="/srv/http"
# PERMISSIONS CHECK
sudo -u $HTTP_USER whoami 2>&1 > /dev/null
if [ $? != 0 ]; then
echo "You are not authorised to run as $HTTP_USER, please run this script as an user that has enough permissions to do so"
exit 1
fi
# ARGUMENT NUMBER AND VALIDITY CHECK
if [ $# != 1 ]; then
echo "Please provide the Riot version as the only argument"
exit 1
fi
status_code=`curl --silent --head $RIOT_REPO/releases/download/$1/riot-$1.tar.gz | grep -E "^Status" | cut -d' ' -f2`
if [ "$status_code" -ge "400" ]; then
echo "The Riot version you provided doesn't exist"
exit 1
fi
# INIT
cd $WEB_ROOT
# HIGHEST INSTALLED VERSION
highest=$(ls | sort -r | grep -Ev "gz$" | head -n1)
# INSTALL DESIRED VERSION
sudo -u $HTTP_USER curl -LO $RIOT_REPO/releases/download/$1/riot-$1.tar.gz
sudo -u $HTTP_USER tar xf riot-$1.tar.gz
sudo -u $HTTP_USER cp $highest/config.json riot-$1/config.json
echo -e "\n\nDifferences between the current configuration file and the new sample:\n\n"
diff -u riot-$1/config.json riot-$1/config.sample.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment