post_upgrade() {
        echo "###########################################################"
        echo "### Mastodon from 4.7.0 and hight  Upgrade Instructions ###"
        echo "###########################################################"
        echo
        echo "### If you are already running Mastodon 4.7.0, only the following steps are required: ###"
        echo
        echo "### 1. Fix ownership, but do not touch uploaded media in ./public/system ###"
        echo "cd /var/lib/mastodon; find -path ./public/system -prune -o -exec chown -h mastodon:mastodon {} +"
        echo
        echo "### 2. Precompile the assets ###"
        echo "cd /var/lib/mastodon"
        echo "sudo -u mastodon RAILS_ENV=production bundle exec rails assets:precompile"
        echo
        echo "### 3. Reload systemd and restart Mastodon ###"
        echo "systemctl daemon-reload; systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming"
        echo
        echo
        echo "########################################################################"
        echo "### Upgrading from a Mastodon version earlier than 4.7.0             ###"
        echo "########################################################################"
        echo
        echo "### If upgrading from an earlier version, read the skipped Mastodon release notes first. ###"
        echo
        echo "### IMPORTANT: Mastodon 4.7.0 contains substantial database migrations. ###"
        echo "### Keep the PRE and POST deployment migrations as separate steps. ###"
        echo "### When upgrading from Mastodon 4.6, the PRE migration does not require stopping Mastodon. ###"
        echo
        echo "### 1. Backup the PostgreSQL database before continuing ###"
        echo "sudo -u postgres pg_dump -Fc mastodon_production > /root/mastodon_production_before_4.7.dump"
        echo
        echo "### 2. Go into the Mastodon directory ###"
        echo "cd /var/lib/mastodon"
        echo
        echo "### 3. Fix ownership first, but do not touch uploaded media in ./public/system ###"
        echo "find -path ./public/system -prune -o -exec chown -h mastodon:mastodon {} +"
        echo
        echo "### 4. If rbenv is used, make sure ruby-build is up to date, then install the Ruby version requested by .ruby-version ###"
        echo "sudo -iu mastodon bash -lc 'cd /var/lib/mastodon && RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install -s'"
        echo "sudo -iu mastodon bash -lc 'cd /var/lib/mastodon && rbenv rehash'"
        echo
        echo "### 5. Install Ruby dependencies ###"
        echo "sudo -iu mastodon bash -lc 'cd /var/lib/mastodon && bundle install'"
        echo
        echo "### If charlock_holmes fails to build with a recent gcc, retry bundle install with: ###"
        echo "sudo -iu mastodon bash -lc 'cd /var/lib/mastodon && BUNDLE_BUILD__CHARLOCK_HOLMES=\"--with-cxxflags=-std=c++17\" bundle install'"
        echo
        echo "### 6. Install JavaScript dependencies ###"
        echo "sudo -iu mastodon bash -lc 'cd /var/lib/mastodon && ./yarn install --immutable'"
        echo
        echo "### 7. Precompile the assets ###"
        echo "cd /var/lib/mastodon"
        echo "sudo -u mastodon RAILS_ENV=production bundle exec rails assets:precompile"
        echo
        echo "### 8. Run PRE-deployment database migrations BEFORE restarting Mastodon ###"
        echo "sudo -u mastodon SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate"
        echo
        echo "### Do not continue to the restart if the PRE-deployment migration fails. ###"
        echo
        echo "### 9. Reload systemd and restart all Mastodon processes ###"
        echo "systemctl daemon-reload; systemctl restart mastodon-web mastodon-sidekiq mastodon-streaming"
        echo
        echo "### 10. Check that all Mastodon services are active ###"
        echo "systemctl is-active mastodon-web mastodon-sidekiq mastodon-streaming"
        echo
        echo "### 11. Run POST-deployment database migrations AFTER the services are running ###"
        echo "cd /var/lib/mastodon"
        echo "sudo -u mastodon RAILS_ENV=production bundle exec rails db:migrate"
}



