Make the Docker Utility Script check for updates to itself.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-05-22 20:28:52 -05:00
parent ee997eff91
commit 954b4d7b6f
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
1 changed files with 34 additions and 9 deletions

View File

@ -325,14 +325,31 @@ install() {
# Usage: ./docker.sh update
#
update() {
# Check for a new Docker Utility Script.
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/master/docker.sh -o docker.new.sh
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/master/docker-compose.sample.yml -o docker-compose.new.yml
FILES_MATCH="$(
cmp --silent docker-compose.yml docker-compose.new.yml
UTILITY_FILES_MATCH="$(
cmp --silent docker.sh docker.new.sh
echo $?
)"
UPDATE_NEW=0
UPDATE_UTILITY=0
if [[ ${UTILITY_FILES_MATCH} -ne 0 ]]; then
if ask "The Docker Utility Script has changed since your version. Update to latest version?" Y; then
UPDATE_UTILITY=1
fi
fi
if [[ ${UPDATE_UTILITY} -ne 0 ]]; then
mv docker.new.sh docker.sh
chmod a+x docker.sh
echo "A new Docker Utility Script has been downloaded."
echo "Please re-run the update process to continue."
exit
else
rm docker.new.sh
fi
if [[ ! -f azuracast.env ]]; then
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/master/azuracast.sample.env -o azuracast.env
@ -343,20 +360,28 @@ update() {
.env --file azuracast.env get PREFER_RELEASE_BUILDS
PREFER_RELEASE_BUILDS="${REPLY:-false}"
if [[ $PREFER_RELEASE_BUILDS = "true" ]]; then
if [[ $PREFER_RELEASE_BUILDS == "true" ]]; then
.env --file .env set AZURACAST_VERSION=stable
fi
.env --file azuracast.env set PREFER_RELEASE_BUILDS
# Check for updated Docker Compose config.
if [[ ${FILES_MATCH} -ne 0 ]]; then
curl -fsSL https://raw.githubusercontent.com/AzuraCast/AzuraCast/master/docker-compose.sample.yml -o docker-compose.new.yml
COMPOSE_FILES_MATCH="$(
cmp --silent docker-compose.yml docker-compose.new.yml
echo $?
)"
UPDATE_COMPOSE=0
if [[ ${COMPOSE_FILES_MATCH} -ne 0 ]]; then
if ask "The docker-compose.yml file has changed since your version. Overwrite? This will overwrite any customizations you made to this file?" Y; then
UPDATE_NEW=1
UPDATE_COMPOSE=1
fi
fi
if [[ ${UPDATE_NEW} -ne 0 ]]; then
if [[ ${UPDATE_COMPOSE} -ne 0 ]]; then
docker-compose -f docker-compose.new.yml pull
docker-compose down