Skip to content

Instantly share code, notes, and snippets.

@thomasmerz
Created July 11, 2023 11:37
Show Gist options
  • Save thomasmerz/00efa1f741a89ebb4b72d3fcc593d423 to your computer and use it in GitHub Desktop.
Save thomasmerz/00efa1f741a89ebb4b72d3fcc593d423 to your computer and use it in GitHub Desktop.
bash-script for updating mastodon instance running in docker container(s)
#!/bin/bash
need_restart=no
# ---
function restart_mastodon () {
cd /opt/mastodon && {
git stash
git pull
git stash pop -q
docker-compose --no-ansi pull 2>&1
docker --no-ansi pull tootsuite/mastodon 2>&1
#docker --no-ansi pull ghcr.io/mastodon/mastodon:latest 2>&1
docker-compose --no-ansi stop && docker-compose --no-ansi up -d
# prepare for:
# 🔨 fix deprecation warning:
# --no-ansi option is deprecated and will be removed in future versions.
# Use `--ansi never` instead.
# docker-compose --ansi never pull 2>&1
# docker --ansi nevr pull tootsuite/mastodon 2>&1
# docker-compose --ansi never stop && docker-compose --ansi never up -d
}
}
# ---
# ---
function check_for_image() {
cd /opt/mastodon &&
docker-compose --no-ansi pull 2>&1 | grep "is up to date" || need_restart=yes
docker --no-ansi pull tootsuite/mastodon 2>&1 | grep "is up to date" || need_restart=yes
#docker --no-ansi pull ghcr.io/mastodon/mastodon:latest 2>&1 | grep "is up to date" || need_restart=yes
}
# ---
# ---
# MAIN
# ---
check_for_image
[ "$need_restart" == "yes" ] && restart_mastodon
# ---
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment