Last active
April 13, 2020 01:59
-
-
Save pjaudiomv/ed7c4e208fe338875abe87f93e116d9a to your computer and use it in GitHub Desktop.
script for upgrading a BMLT Root Server
This file contains hidden or 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/sh | |
# Script for upgrading a BMLT server. | |
# Basic Usage: < ./bmlt-upgrade.sh > this will download the new release put it in a folder called new_main_server. | |
# when you have verified everything works you can run < ./bmlt-upgrade.sh complete > | |
# this will copy main_server to old_main server and new_main_server to main_server | |
# if url provided we use that, otherwise just get latest release. | |
if [[ -z "$1" ]];then | |
RELEASE_URL=$(curl -sL "https://api.github.com/repos/bmlt-enabled/bmlt-root-server/releases/latest" | grep -o '"browser_download_url": *"[^"]*' | grep -o '[^"]*$') | |
# if jq is available curl -sL "https://api.github.com/repos/bmlt-enabled/bmlt-root-server/releases/latest" | jq -r '.assets[].browser_download_url' | |
else | |
RELEASE_URL=$1 | |
fi | |
# if parameter eq complete, we complete the process. | |
if [[ "$RELEASE_URL" == "complete" ]] | |
then | |
echo "Deleting previous archived version" | |
rm -rf old_main_server/ | |
echo "Moving previous version to be archived version." | |
mv main_server/ old_main_server/ | |
echo "Moving new version to be the current one." | |
mv new_main_server/ main_server/ | |
echo "You can now view the site under http://[bmlt-host]/main_server." | |
else | |
echo "Deleting older zip if it is there" | |
rm $(basename "$RELEASE_URL") | |
rm -rf new_main_server | |
echo "Downloading the newest version" | |
wget "$RELEASE_URL" | |
echo "Unpacking..." | |
unzip $(basename "$RELEASE_URL") -d temp/ | |
echo "Moving from temporary location to migration path" | |
mkdir new_main_server | |
mv temp/main_server/* new_main_server | |
echo "Removing temporary location" | |
rm -rf temp/ | |
# this step usually isn't needed on shared hosting | |
#echo "Fixing permissions" | |
#chown -R www-data: new_main_server/ | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment