Last active
February 28, 2023 14:05
-
-
Save isosphere/1e3783328c52e213812c5e0dc11b99a9 to your computer and use it in GitHub Desktop.
Mastodon Server Upgrade Script
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/bash | |
RELEASE_TAG=${1:?"missing arg 1 for RELEASE_TAG"} | |
echo Backing up database | |
/home/mastodon/backup_database.sh | |
cd /home/mastodon/live | |
git fetch | |
# The stash commands are only required if you mess around with the source code | |
git stash | |
git checkout $RELEASE_TAG | |
git stash pop | |
read -p "Please verify that the stash was correctly popped and press [Enter] to proceed." | |
echo New code fetched, updating packages | |
bundle install | |
yarn install | |
echo Running migrations and precompiling assets | |
DB_PORT=5432 SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate | |
RAILS_ENV=production bundle exec rails assets:precompile | |
echo Restarting services | |
sudo systemctl restart mastodon-web | |
sudo systemctl restart mastodon-sidekiq | |
echo Running second migration | |
DB_PORT=5432 RAILS_ENV=production bundle exec rails db:migrate | |
echo Final restart | |
sudo systemctl restart mastodon-web | |
sudo systemctl restart mastodon-sidekiq | |
echo Completed upgrade to $RELEASE_TAG |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment