Update setup scripts

This commit is contained in:
KMY 2023-09-17 08:52:30 +09:00
parent f042cd85a3
commit 5ecab9d924
4 changed files with 97 additions and 58 deletions

View file

@ -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 <<EOF
git clone https://github.com/kmycode/mastodon.git live && cd live
git checkout $(git tag -l | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
git clone https://github.com/kmycode/mastodon.git live
cp /home/mastodon/live/install/setup2.sh /home/mastodon/setup2.sh
chmod +x /home/mastodon/setup2.sh
EOF
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
# ---------------------------------------------------
cat << EOF
@ -47,8 +47,6 @@ cat << EOF
Input this command to continue setup:
sudo su - mastodon
cd live
chmod +x install/setup2.sh
install/setup2.sh
./setup2.sh
EOF

View file

@ -1,4 +1,26 @@
# gitで最新リリースを取得
cd ~/live
git checkout $(git tag -l | grep -E '^kb[0-9]' | grep -v 'rc[0-9]*$' | sort -V | tail -n 1)
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.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

View file

@ -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

53
install/setup4.sh Normal file
View file

@ -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