Last active
May 4, 2019 17:07
-
-
Save necessary129/c20559881a3f8a0f295e41ea12c47775 to your computer and use it in GitHub Desktop.
Upgrades Synapse
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -eu | |
RED='\e[0;31m' | |
BOLD='\e[1m' | |
GREEN='\e[32m' | |
NC='\e[0m' | |
problem=0 | |
function er_msg { | |
echo -e "\n${RED}${BOLD}Something bad happened. Please check!${NC}\n" | |
exit 1 | |
} | |
trap er_msg ERR | |
declare -a services=(".service" "@synchrotron.service" "@federation_reader.service" "@event_creator.service" | |
"@federation_sender.service" "@pusher.service" "@user_dir.service" | |
"@media_repository.service" "@frontend_proxy.service" "@client_reader.service") | |
echo -e "${BOLD}Downloading Update...${NC}" | |
sudo -Hu matrix-synapse bash <<EOD | |
cd ~ | |
source synapse/bin/activate | |
pip install --upgrade matrix-synapse[all] | |
EOD | |
echo -e "${BOLD}Restarting Synapse...${NC}" | |
service matrix-synapse stop && service matrix-synapse start | |
sleep 3 | |
echo -e "\nChecking if all services are running..." | |
for i in "${services[@]}" | |
do | |
service="matrix-synapse$i" | |
out=$(systemctl is-active "$service" || true) | |
echo -e "$service: ${BOLD}$out${NC}" | |
if ! [[ $out == "active" ]]; then | |
problem=1 | |
fi | |
done | |
if [[ $problem -eq 1 ]]; then | |
er_msg | |
else | |
echo -e "\n${GREEN}${BOLD}All good! Upgrade done!${NC}\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment