diff --git a/install/setup1.sh b/install/setup1.sh index 0f513d71f0..91acd3cdb8 100644 --- a/install/setup1.sh +++ b/install/setup1.sh @@ -2,15 +2,16 @@ apt update && apt upgrade -y apt install -y curl wget gnupg apt-transport-https lsb-release ca-certificates -# nodejs +# Node.js curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_20.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list sudo apt-get update && sudo apt-get install nodejs -y -# postgresql +# PostgreSQL wget -O /usr/share/keyrings/postgresql.asc https://www.postgresql.org/media/keys/ACCC4CF8.asc echo "deb [signed-by=/usr/share/keyrings/postgresql.asc] http://apt.postgresql.org/pub/repos/apt $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/postgresql.list +# 必要なパッケージをまとめてインストール apt update apt install -y \ imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core \ @@ -23,23 +24,22 @@ apt install -y \ corepack enable yarn set version classic +# mastodonユーザーを追加 adduser --disabled-login mastodon +# PostgreSQLにmastodonユーザーを追加 sudo -u postgres psql << EOF CREATE USER mastodon WITH PASSWORD 'ohagi' CREATEDB; EOF +# kmyblueソースコードをダウンロード su - mastodon <> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc + +cp /home/mastodon/live/install/setup3.sh /home/mastodon/setup3.sh +chmod +x /home/mastodon/setup3.sh +cp /home/mastodon/live/install/setup4.sh /home/mastodon/setup4.sh +chmod +x /home/mastodon/setup4.sh + +# --------------------------------------------------- + +cat << EOF + +============== [kmyblue setup script 2 completed] ================ + +Input this command to continue setup: + exec bash + exit + sudo /home/mastodon/setup3.sh + +EOF diff --git a/install/setup3.sh b/install/setup3.sh index cd54b8f5d2..8d90e2b562 100644 --- a/install/setup3.sh +++ b/install/setup3.sh @@ -1,52 +1,18 @@ -git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build +# 必要なファイルをコピー +chmod o+x /home/mastodon +cp /home/mastodon/live/dist/nginx.conf /etc/nginx/sites-available/mastodon +ln -s /etc/nginx/sites-available/mastodon /etc/nginx/sites-enabled/mastodon +cp /home/mastodon/live/dist/mastodon-*.service /etc/systemd/system/ +systemctl daemon-reload -RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.2 -rbenv global 3.2.2 - -gem install bundler --no-document - -cd ~/live - -yarn install --pure-lockfile - -bundle config deployment 'true' -bundle config without 'development test' -bundle install -j$(getconf _NPROCESSORS_ONLN) +# --------------------------------------------------- cat << EOF -============== [kmyblue setup script 2 completed] ================ +============== [kmyblue setup script 3 completed] ================ -PostgreSQL and Redis are now available on localhost. - -* PostgreSQL - host : /var/run/postgresql - user : mastodon - database : mastodon_production - password : ohagi - -* Redis - host : localhost - -[IMPORTANT] Check PostgreSQL password before setup! - -Input this command to finish setup: - cd live - RAILS_ENV=production bundle exec rake mastodon:setup - -If you update kmyblue version, use following: - /home/mastodon/update +Input this command to continue setup: + sudo su - mastodon + ./setup4.sh EOF - - -# パスワード変更 -# sudo -u postgres psql << EOF -# ALTER USER mastodon WITH PASSWORD 'ohagi'; -# EOF - -# サーバー設定変更 -# sudo vi /etc/nginx/sites-available/mastodon - -# サーバー起動・OS起動時自動起動設定 -# systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming diff --git a/install/setup4.sh b/install/setup4.sh new file mode 100644 index 0000000000..0af940e90a --- /dev/null +++ b/install/setup4.sh @@ -0,0 +1,53 @@ +git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build + +RUBY_CONFIGURE_OPTS=--with-jemalloc rbenv install 3.2.2 +rbenv global 3.2.2 + +gem install bundler --no-document + +cd ~/live + +yarn install --pure-lockfile + +bundle config deployment 'true' +bundle config without 'development test' +bundle install -j$(getconf _NPROCESSORS_ONLN) + +rm ~/setup3.sh +rm ~/setup4.sh + +# --------------------------------------------------- + +cat << EOF + +============== [kmyblue setup script 4 completed] ================ + +PostgreSQL and Redis are now available on localhost. + +* PostgreSQL + host : /var/run/postgresql + user : mastodon + database : mastodon_production + password : ohagi + +* Redis + host : localhost + +[IMPORTANT] Check PostgreSQL password before setup! + +Input this command to finish setup: + RAILS_ENV=production bundle exec rake mastodon:setup + +EOF + + +# パスワード変更 +# sudo -u postgres psql << EOF +# ALTER USER mastodon WITH PASSWORD 'ohagi'; +# EOF + +# サーバー設定変更 +# sudo vi /etc/nginx/sites-available/mastodon + +# サーバー起動・OS起動時自動起動設定 +# systemctl enable --now mastodon-web mastodon-sidekiq mastodon-streaming