mastodon インストール後〜アップデートまで

mastodonのインストールが終わったら、とにもかくにもsshの設定。

ローカルで
$ cd ~
$ mkdir .ssh
$ cd ~/.ssh
$ ssh-keygen -f rsa -t rsa

サーバ上のマストドン(hogegoge)ユーザで
$cd /home/hogehoge
$ mkdir .ssh
$ chmod 700 .ssh

ローカルで
$ scp ~/.ssh/rsa.pub hogehoge@「ipアドレス」:~/

hogehogeユーザで
$ cat rsa.pub > .ssh/authorized_keys
$ chmod 600 .ssh/authorized_keys
$ rm -f rsa.pub

$ sudo vi /etc/ssh/sshd_configを編集
PermitRootLogin no
PasswordAuthentication no
Port 「任意の番号」
#PubkeyAuthentication yes
$ sudo systemctl restart sshd
$ sudo vi /usr/lib/firewalld/services/ssh.xml
〜〜 port=”上記の番号”〜
$ sudo firewall-cmd –reload

ローカルで鍵を使ってログインできるか確認
$ssh -p 上記の番号 -i ~/.ssh/rsa hogehoge@hogehogeのIP

ローカルでこれをつくっておく
ローカル
(~/.ssh/config)
Host foobar
HostName hogehogeのIP
Port ポート番号
User hogehoge
IdentityFile ~/.ssh/rsa

としておくと次回から「ssh foobar」と打てばログインできる

ユーザーに管理者権限を付与
/home/mastodon/liveのディレクトリで行う

echo “export RAILS_ENV=production” >> ~/.bashrc
cd /home/mastodon/live
RAILS_ENV=production bin/tootctl accounts modify alice –role admin

アプデ手順
無難な対応としては、最初にmastodonを一度停止した方が良いので停止する。

systemctl stop mastodon-{web,sidekiq,stream}

Mastodonのインストールパスに移動
cd /home/mastodon/live

git で最新の状態を取得してくる
git fetch origin

新しいリリース版が出ているにもかかわらず上記コマンドでも当該バージョンのタグが取得されない( * [new tag] が表示されない)場合は下記のコマンドで取得してみる
git fetch –tags origin

または、既に取得済みである可能性もあるので、その場合は
git tag -l

で現在取得済みのタグ一覧を表示し、当該バージョンのリリースタグがあるか確認する

取得したら目的のタグに切り換える。ここでは v1.4.1 にアップデートする。
git checkout v1.4.1

bundler を使用して gem やらの更新
bundle install

フロントエンド関連のライブラリも yarn で更新
yarn install

DBの構成変更がある場合は db:migrate を実行する(何も無い場合も実行しても何も起こらない)
RAILS_ENV=production bundle exec rake db:migrate

フロントエンドのCSSやJSの更新とパッケージング(これがチョット長い)
RAILS_ENV=production bundle exec rake assets:precompile

※ここで「Using /mastodon/config/webpacker.yml file for setting up webpack paths Compiling… Compilation failed:」となったらほぼメモリ不足らしいので、スケールアップするなどする

最後にエラーのような文言が出るが、500.htmlに関するレンダリングエラーじゃなくって、500のエラーを吐き出すページ?をレンダリングしましたよ、ってことなので無問題

アプデできたらmastodon起動
sudo systemctl start mastodon*

もしくはsudo systemctl start mastodon-{web,sidekiq,streaming}

うまくいかない場合は個別に立ち上げる
sudo systemctl start mastodon-web
以下同

参考、アプデ手順
https://gist.github.com/anon5r/bd96ee4127d6b66ad4150287f5a4ed99

参考、その他保守
https://qiita.com/kumasun/items/bf4997f181f893130041