From c1aebe391328a35e37c99f66848d362ef51cdb2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Iwan=20Cl=C3=A9ment?= Date: Sun, 6 May 2018 23:32:22 +0200 Subject: [PATCH] Avancement dans les scripts d'installation de Mastodon --- files/Install-Mastodon-CreatePSQL-User.sh | 4 ++- files/Install-Mastodon-Phase1.sh | 1 + files/Install-Mastodon-Phase2.sh | 34 ++++++++++++------- files/Install-Mastodon-Phase3.sh | 8 +++-- files/Install-Mastodon-Phase4.sh | 40 +++++++++++++++++++++++ 5 files changed, 72 insertions(+), 15 deletions(-) create mode 100644 files/Install-Mastodon-Phase4.sh diff --git a/files/Install-Mastodon-CreatePSQL-User.sh b/files/Install-Mastodon-CreatePSQL-User.sh index 2133cb3..77b1182 100644 --- a/files/Install-Mastodon-CreatePSQL-User.sh +++ b/files/Install-Mastodon-CreatePSQL-User.sh @@ -1,2 +1,4 @@ +# https://anystack.xyz/how-to-install-mastodon-ubuntu/ #psql -c "CREATE USER admin WITH PASSWORD 'test101';" -psql -c "CREATE USER mastodon CREATEDB;" +psql -c "CREATE USER mastodon CREATEDB;" && exit 0 +exit 200 diff --git a/files/Install-Mastodon-Phase1.sh b/files/Install-Mastodon-Phase1.sh index b055ec3..2fc2d80 100644 --- a/files/Install-Mastodon-Phase1.sh +++ b/files/Install-Mastodon-Phase1.sh @@ -1,3 +1,4 @@ +# https://anystack.xyz/how-to-install-mastodon-ubuntu/ #!/bin/bash #set -x diff --git a/files/Install-Mastodon-Phase2.sh b/files/Install-Mastodon-Phase2.sh index cbf532f..8b72a78 100644 --- a/files/Install-Mastodon-Phase2.sh +++ b/files/Install-Mastodon-Phase2.sh @@ -1,4 +1,5 @@ #!/bin/bash +# https://anystack.xyz/how-to-install-mastodon-ubuntu/ set -x # Check if it is a Ubuntu host @@ -16,26 +17,35 @@ fi if true; then adduser --disabled-password --disabled-login --gecos "" mastodon || exit 3 + chmod +r Install*.sh;chmod +x Install*.sh cp Install-Mastodon-Phase3.sh Install-Mastodon-Phase4.sh /home/mastodon || exit 4 chown -R mastodon /home/mastodon || exit 5 chmod +x /home/mastodon/Install*.sh if [ -e ./Install-Mastodon-CreatePSQL-User.sh ] then # Creation de l'utilisateur Postgresql postgres - su - postgres -C ./Install-Mastodon-CreatePSQL-User.sh || exit 6 + cp -f Install-Mastodon-CreatePSQL-User.sh /tmp || exit 6 + chmod 644 /tmp/Install*.sh + chmod +x /tmp/Install*.sh || exit 7 + su - postgres -c /tmp/Install-Mastodon-CreatePSQL-User.sh || exit 8 + rm -f /tmp/Install*.sh else - exit 7 + exit 9 fi fi -sed -i '/^local.*postgres.*peer$/a host all all 127.0.0.1/32 ident' /etc/postgresql/9.?/main/pg_hba.conf || exit 3 -apt-get -y install pidentd && sudo systemctl enable pidentd && sudo systemctl start pidentd || exit 4 -systemctl restart postgresql || exit 5 -apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev || exit 6 -apt-get install -y libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev || exit 7 -apt-get install -y libgdbm3 libgdbm-dev || exit 8 +if true; then + sed -i '/^local.*postgres.*peer$/a host all all 127.0.0.1/32 ident' /etc/postgresql/9.?/main/pg_hba.conf || exit 10 + apt-get -y install pidentd || exit 11 + systemctl enable pidentd || exit 12 + systemctl start pidentd || exit 13 + systemctl restart postgresql || exit 14 + apt-get install -y autoconf bison build-essential libssl-dev libyaml-dev || exit 15 + apt-get install -y libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev || exit 16 + apt-get install -y libgdbm3 libgdbm-dev || exit 17 +fi -cp Install-Mastodon-Phase3.sh Install-Mastodon-Phase4.sh /home/mastodon || exit 10 -chown -R mastodon:mastodon /home/mastodon || exit 11 -su - mastodon -C Install-Mastodon-Phase3.sh || exit 12 -su - mastodon -C Install-Mastodon-Phase4.sh || exit 13 +if true; then + su - mastodon -c ./Install-Mastodon-Phase3.sh || exit 18 + su - mastodon -c ./Install-Mastodon-Phase4.sh || exit 19 +fi diff --git a/files/Install-Mastodon-Phase3.sh b/files/Install-Mastodon-Phase3.sh index d1a0ce6..b9fc83f 100644 --- a/files/Install-Mastodon-Phase3.sh +++ b/files/Install-Mastodon-Phase3.sh @@ -1,5 +1,9 @@ -git clone https://github.com/rbenv/rbenv.git ~/.rbenv +#!/bin/bash +# https://anystack.xyz/how-to-install-mastodon-ubuntu/ +echo Phase 3: Preparation de l'environnement + +git clone https://github.com/rbenv/rbenv.git ~/.rbenv || exit 101 echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bashrc echo 'eval "$(rbenv init -)"' >> ~/.bashrc source ~/.bashrc -exit +exit 0 diff --git a/files/Install-Mastodon-Phase4.sh b/files/Install-Mastodon-Phase4.sh new file mode 100644 index 0000000..38d2bed --- /dev/null +++ b/files/Install-Mastodon-Phase4.sh @@ -0,0 +1,40 @@ +#!/bin/bash + +# Let's install ruby 2.5.0 +echo Phase 4: Installation de Ruby +git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build || exit 301 +rbenv install 2.5.0 || exit 302 +rbenv global 2.5.0 || exit 303 +ruby -v + +cd ~ +git clone https://github.com/tootsuite/mastodon.git live || exit 304 +cd live || exit 305 +git checkout $(git tag | tail -n 1) || exit 306 + +echo "gem: --no-document" > ~/.gemrc || exit 307 +gem install bundler --no-ri || exit 308 + +echo Launch the installation +bundle install --deployment --without development test || exit 309 +yarn install || exit 310 + +cp .env.production.sample .env.production || exit 311 + +echo "# Service dependencies" >>.env.production +echo REDIS_HOST=localhost >>.env.production +echo REDIS_PORT=6379 >>.env.production +echo DB_HOST=/var/run/postgresql >>.env.production +echo DB_USER=mastodon >>.env.production +echo DB_NAME=mastodon_production >>.env.production +echo DB_PASS= >>.env.production +echo DB_PORT=5432 >>.env.production + +echo "# E-mail configuration" >>.env.production +echo SMTP_SERVER=mail.yourdomain.com >>.env.production +echo SMTP_PORT=587 >>.env.production +echo SMTP_LOGIN=noreply@yourdomain.com >>.env.production +echo SMTP_PASSWORD=YourPassword >>.env.production +echo SMTP_FROM_ADDRESS=noreply@yourdomain.com >>.env.production + +exit 0