Last active
April 20, 2024 14:47
-
-
Save Mixaill/a27db7a943b2b173a51788a1c32e4688 to your computer and use it in GitHub Desktop.
This file contains 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
#!/usr/bin/env bash | |
# | |
# Mastodon update script | |
# v3 (2024.02.18) | |
# | |
# Changelog | |
# * v1 - initial version | |
# * v2 - added mastodon-bird-ui | |
# * v3 - added import of temporary email domains | |
cd /home/mastodon/live/ | |
# revert changes | |
git restore ./config/themes.yml | |
# git | |
git pull | |
# extract version | |
mastodon_prerelease="nightly.$(git show -s --date=format:"%Y-%m-%d" --format="%cd" HEAD)" | |
mastodon_prerelease_exists=$(cat ./.env.production | grep MASTODON_VERSION_PRERELEASE= | wc -l) | |
if [ "$mastodon_prerelease_exists" -ne "0" ]; then | |
sed -i~ "/^MASTODON_VERSION_PRERELEASE=/s/=.*/=$mastodon_prerelease/" ./.env.production | |
else | |
echo "MASTODON_VERSION_PRERELEASE=$mastodon_prerelease" >> ./.env.production | |
fi | |
# install mastodon-bird-ui | |
rm -rf ./app/javascript/styles/mastodon-bird-ui/ | |
mkdir -p ./app/javascript/styles/mastodon-bird-ui/ | |
wget --no-cache https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/main/layout-single-column.css -O app/javascript/styles/mastodon-bird-ui/layout-single-column.scss | |
wget --no-cache https://raw.githubusercontent.com/ronilaukkarinen/mastodon-bird-ui/main/layout-multiple-columns.css -O app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss | |
sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' app/javascript/styles/mastodon-bird-ui/layout-single-column.scss | |
sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' app/javascript/styles/mastodon-bird-ui/layout-single-column.scss | |
sed -i 's/theme-contrast/theme-mastodon-bird-ui-contrast/g' app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss | |
sed -i 's/theme-mastodon-light/theme-mastodon-bird-ui-light/g' app/javascript/styles/mastodon-bird-ui/layout-multiple-columns.scss | |
echo -e "@import 'contrast/variables';\n@import 'application';\n@import 'contrast/diff';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" > app/javascript/styles/mastodon-bird-ui-contrast.scss | |
echo -e "@import 'mastodon-light/variables';\n@import 'application';\n@import 'mastodon-light/diff';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" > app/javascript/styles/mastodon-bird-ui-light.scss | |
echo -e "@import 'application';\n@import 'mastodon-bird-ui/layout-single-column.scss';\n@import 'mastodon-bird-ui/layout-multiple-columns.scss';" > app/javascript/styles/mastodon-bird-ui-dark.scss | |
echo "mastodon-bird-ui-dark: styles/mastodon-bird-ui-dark.scss" >> config/themes.yml | |
echo "mastodon-bird-ui-light: styles/mastodon-bird-ui-light.scss" >> config/themes.yml | |
echo "mastodon-bird-ui-contrast: styles/mastodon-bird-ui-contrast.scss" >> config/themes.yml | |
# gems and node packages | |
bundle install | |
yarn install | |
# DB/pre | |
SKIP_POST_DEPLOYMENT_MIGRATIONS=true RAILS_ENV=production bundle exec rails db:migrate | |
# Assets | |
RAILS_ENV=production bundle exec rails assets:clean | |
RAILS_ENV=production bundle exec rails assets:clobber | |
RAILS_ENV=production bundle exec rails assets:precompile | |
# Services reboot 1 | |
sudo service mastodon-sidekiq restart | |
sudo service mastodon-streaming restart | |
sudo service mastodon-web restart | |
# DB/post | |
RAILS_ENV=production bundle exec rails db:migrate | |
# Search | |
RAILS_ENV=production bin/tootctl search deploy --reset-chewy | |
# Ban temporary emails | |
mkdir -p ./~temp | |
wget --no-cache https://raw.githubusercontent.com/disposable-email-domains/disposable-email-domains/master/disposable_email_blocklist.conf -O ./~temp/email.list | |
domains="$(cat ./~temp/email.list)" | |
domains="${domains//$'\n'/ }" | |
RAILS_ENV=production bin/tootctl email-domain-blocks add $domains | |
rm -r ./~temp | |
# Services reboot 2 | |
sudo service mastodon-sidekiq restart | |
sudo service mastodon-streaming restart | |
sudo service mastodon-web restart |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@p37307 probably your repository in a detached HEAD state. you can try to execute
git checkout main
in your repo root before script