diff options
| author | magikcypress <cyp@rouquin.me> | 2017-04-09 03:26:55 +0200 |
|---|---|---|
| committer | magikcypress <cyp@rouquin.me> | 2017-04-09 03:26:55 +0200 |
| commit | dbd92b090ad9a7ce0b3428623667f308547eca88 (patch) | |
| tree | a30a22cb5fb40e3109121f53d50ad6cee2b5356b | |
| parent | dab2e3571a3afc33795fa54fef57f10243522f90 (diff) | |
| download | mastodon_ynh-dbd92b090ad9a7ce0b3428623667f308547eca88.tar.gz mastodon_ynh-dbd92b090ad9a7ce0b3428623667f308547eca88.tar.bz2 mastodon_ynh-dbd92b090ad9a7ce0b3428623667f308547eca88.zip | |
Update install
| -rw-r--r-- | README.md | 3 | ||||
| -rw-r--r-- | scripts/install | 66 | ||||
| -rw-r--r-- | scripts/remove | 42 |
3 files changed, 55 insertions, 56 deletions
@@ -1,6 +1,7 @@ # Mastodon for YunoHost -:warning: Testing version (don't work) :warning: +[](https://github.com/Snipees/couchpotato_ynh/milestones) +[](https://github.com/YunoHost/yunohost) ## Mastodon c'est quoi ? diff --git a/scripts/install b/scripts/install index cfee5b2..174fc42 100644 --- a/scripts/install +++ b/scripts/install @@ -82,56 +82,49 @@ git clone https://github.com/tootsuite/mastodon.git $final_path/live sudo chown -R $app: "${final_path}" # Install de rbenv -# Install ruby-build -# Install Mastodon sudo su - $app <<COMMANDS pushd ~/.rbenv src/configure && make -C src -echo 'export PATH="/opt/mastodon/.rbenv/bin:$PATH"' >> ~/.bash_profile -echo 'export PATH="/opt/mastodon/.rbenv/bin:$PATH" -eval "$(/opt/mastodon/.rbenv/bin/rbenv init -)"' >> ~/.bashrc -type /opt/mastodon/.rbenv/bin/rbenv - -/opt/mastodon/.rbenv/bin/rbenv init +echo 'export PATH="/opt/mastodon/.rbenv/bin:/opt/mastodon/live/bin:$PATH"' >> ~/.bashrc +echo 'eval "\$(rbenv init -)"' >> ~/.bashrc +echo "alias su='env PATH=\$PATH'" >> ~/.bashrc +COMMANDS +# Install ruby-build +sudo su - $app <<RCOMMANDS /opt/mastodon/.rbenv/bin/rbenv install 2.3.1 /opt/mastodon/.rbenv/versions/2.3.1/bin/ruby -v +RCOMMANDS +# Install Mastodon +sudo su - $app <<MCOMMANDS +pushd ~/live /opt/mastodon/.rbenv/versions/2.3.1/bin/gem install bundler /opt/mastodon/live/bin/bundle install --deployment --without development test yarn install -COMMANDS +MCOMMANDS -## Generate a new environnement -# Generate secret key # Adjust Mastodon config -# Create database -# Preconfig CSS & JS -sudo su - $app <<ENDCOMMANDS -type /opt/mastodon/.rbenv/bin/rbenv -/opt/mastodon/.rbenv/bin/rbenv init - -bundle_paperclip_secret=$(/opt/mastodon/live/bin/bundle exec rake secret) -bundle_secret_key_base=$(/opt/mastodon/live/bin/bundle exec rake secret) -bundle_otp_secret=$(/opt/mastodon/live/bin/bundle exec rake secret) +pushd $final_path/live/ +sudo cp -a .env.production.sample .env.production +sudo sed -i "s@REDIS_HOST=localhost@REDIS_HOST=localhost@g" "${final_path}/live/.env.production" +sudo sed -i "s@DB_HOST=db@DB_HOST=/var/run/postgresql@g" "${final_path}/live/.env.production" +sudo sed -i "s@DB_USER=mastodon@DB_USER=${dbuser}@g" "${final_path}/live/.env.production" +sudo sed -i "s@DB_NAME=mastodon@DB_NAME=${dbuser}@g" "${final_path}/live/.env.production" +sudo sed -i "s@LOCAL_DOMAIN=domainedevotreinstance.tld@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" -pushd ~/live/ -cp .env.production.sample .env.production -sed -i "s@REDIS_HOST=localhost@REDIS_HOST=localhost@g" "${final_path}/live/.env.production" -sed -i "s@DB_HOST=db@DB_HOST=/var/run/postgresql@g" "${final_path}/live/.env.production" -sed -i "s@DB_USER=mastodon@DB_USER=${dbuser}@g" "${final_path}/live/.env.production" -sed -i "s@DB_NAME=mastodon@DB_NAME=${dbuser}@g" "${final_path}/live/.env.production" -sed -i "s@LOCAL_DOMAIN=domainedevotreinstance.tld@LOCAL_DOMAIN=${domain}@g" "${final_path}/live/.env.production" +sudo sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" +sudo sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" +sudo sed -i "s@OTP_SECRET=@OTP_SECRET=$(head -n32 /dev/urandom | tr -dc -d 'A-Za-z0-9' | head -c32)@g" "${final_path}/live/.env.production" -sed -i "s@PAPERCLIP_SECRET=@PAPERCLIP_SECRET=${bundle_paperclip_secret}@g" "${final_path}/live/.env.production" -sed -i "s@SECRET_KEY_BASE=@SECRET_KEY_BASE=${bundle_secret_key_base}@g" "${final_path}/live/.env.production" -sed -i "s@OTP_SECRET=@OTP_SECRET=${bundle_otp_secret}@g" "${final_path}/live/.env.production" - -sed -i "s@SMTP_SERVER=smtp.mailgun.org@SMTP_SERVER=localhost@g" "${final_path}/live/.env.production" -sed -i "s@SMTP_FROM_ADDRESS=notifications@example.com@SMTP_FROM_ADDRESS=${user}@${domain}@g" "${final_path}/live/.env.production" +sudo sed -i "s@SMTP_SERVER=smtp.mailgun.org@SMTP_SERVER=localhost@g" "${final_path}/live/.env.production" +sudo sed -i 's,SMTP_FROM_ADDRESS=notifications@example.com,SMTP_FROM_ADDRESS='${admin_mastodon}'@'${domain}',' "${final_path}/live/.env.production" +# Create database +# Preconfig CSS & JS +sudo su - $app <<ENDCOMMANDS +pushd ~ RAILS_ENV=production bundle exec rails db:setup - RAILS_ENV=production bundle exec rails assets:precompile ENDCOMMANDS @@ -150,6 +143,11 @@ sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-stre # debug sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service +# Add service YunoHost +sudo yunohost service add mastodon-web +sudo yunohost service add mastodon-sidekiq +sudo yunohost service add mastodon-streaming + # Copy nginx config sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf diff --git a/scripts/remove b/scripts/remove index d4e896f..b8f2d6b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -13,6 +13,27 @@ app=$YNH_APP_INSTANCE_NAME # Retrieve app settings domain=$(ynh_app_setting_get "$app" domain) +# Delete service on Yunohost monitoring +if sudo yunohost service status | grep -q mastodon-web +then + echo "Remove mastodon-web service" + sudo yunohost service remove mastodon-web +fi + +# Delete service on Yunohost monitoring +if sudo yunohost service status | grep -q mastodon-sidekiq +then + echo "Remove mastodon-sidekiq service" + sudo yunohost service remove mastodon-sidekiq +fi + +# Delete service on Yunohost monitoring +if sudo yunohost service status | grep -q mastodon-streaming +then + echo "Remove mastodon-streaming service" + sudo yunohost service remove mastodon-streaming +fi + # Stop mastodon-web if [ -e "/etc/systemd/system/mastodon-web.service" ]; then echo "Delete systemd script" @@ -37,27 +58,6 @@ if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then sudo systemctl disable mastodon-streaming.service fi -# Delete service on Yunohost monitoring -if sudo yunohost service status | grep -q mastodon-web -then - echo "Remove mastodon-web service" - sudo yunohost service remove mastodon-web -fi - -# Delete service on Yunohost monitoring -if sudo yunohost service status | grep -q mastodon-sidekiq -then - echo "Remove mastodon-sidekiq service" - sudo yunohost service remove mastodon-sidekiq -fi - -# Delete service on Yunohost monitoring -if sudo yunohost service status | grep -q mastodon-streaming -then - echo "Remove mastodon-streaming service" - sudo yunohost service remove mastodon-streaming -fi - # delete postgresql database & user ynh_psql_drop_db $app ynh_psql_drop_user $app |
