1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/glitchsoc_ynh.git synced 2024-09-03 19:15:59 +02:00

Update install

This commit is contained in:
magikcypress 2017-04-09 03:26:55 +02:00
parent dab2e3571a
commit dbd92b090a
3 changed files with 55 additions and 56 deletions

View file

@ -1,6 +1,7 @@
# Mastodon for YunoHost # Mastodon for YunoHost
:warning: Testing version (don't work) :warning: [![Status](https://img.shields.io/badge/status-in_progress-yellow.svg?style=flat)](https://github.com/Snipees/couchpotato_ynh/milestones)
[![Yunohost version](https://img.shields.io/badge/yunohost-2.4.2_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost)
## Mastodon c'est quoi ? ## Mastodon c'est quoi ?

View file

@ -82,56 +82,49 @@ git clone https://github.com/tootsuite/mastodon.git $final_path/live
sudo chown -R $app: "${final_path}" sudo chown -R $app: "${final_path}"
# Install de rbenv # Install de rbenv
# Install ruby-build
# Install Mastodon
sudo su - $app <<COMMANDS sudo su - $app <<COMMANDS
pushd ~/.rbenv pushd ~/.rbenv
src/configure && make -C src src/configure && make -C src
echo 'export PATH="/opt/mastodon/.rbenv/bin:$PATH"' >> ~/.bash_profile echo 'export PATH="/opt/mastodon/.rbenv/bin:/opt/mastodon/live/bin:$PATH"' >> ~/.bashrc
echo 'export PATH="/opt/mastodon/.rbenv/bin:$PATH" echo 'eval "\$(rbenv init -)"' >> ~/.bashrc
eval "$(/opt/mastodon/.rbenv/bin/rbenv init -)"' >> ~/.bashrc echo "alias su='env PATH=\$PATH'" >> ~/.bashrc
type /opt/mastodon/.rbenv/bin/rbenv COMMANDS
/opt/mastodon/.rbenv/bin/rbenv init
# Install ruby-build
sudo su - $app <<RCOMMANDS
/opt/mastodon/.rbenv/bin/rbenv install 2.3.1 /opt/mastodon/.rbenv/bin/rbenv install 2.3.1
/opt/mastodon/.rbenv/versions/2.3.1/bin/ruby -v /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/.rbenv/versions/2.3.1/bin/gem install bundler
/opt/mastodon/live/bin/bundle install --deployment --without development test /opt/mastodon/live/bin/bundle install --deployment --without development test
yarn install yarn install
COMMANDS MCOMMANDS
## Generate a new environnement
# Generate secret key
# Adjust Mastodon config # Adjust Mastodon config
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"
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"
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 # Create database
# Preconfig CSS & JS # Preconfig CSS & JS
sudo su - $app <<ENDCOMMANDS sudo su - $app <<ENDCOMMANDS
type /opt/mastodon/.rbenv/bin/rbenv pushd ~
/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 ~/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"
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"
RAILS_ENV=production bundle exec rails db:setup RAILS_ENV=production bundle exec rails db:setup
RAILS_ENV=production bundle exec rails assets:precompile RAILS_ENV=production bundle exec rails assets:precompile
ENDCOMMANDS ENDCOMMANDS
@ -150,6 +143,11 @@ sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-stre
# debug # debug
sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service 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 # Copy nginx config
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf 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 sudo sed -i "s@__PATH__@$path@g" /etc/nginx/conf.d/$domain.d/$app.conf

View file

@ -13,6 +13,27 @@ app=$YNH_APP_INSTANCE_NAME
# Retrieve app settings # Retrieve app settings
domain=$(ynh_app_setting_get "$app" domain) 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 # Stop mastodon-web
if [ -e "/etc/systemd/system/mastodon-web.service" ]; then if [ -e "/etc/systemd/system/mastodon-web.service" ]; then
echo "Delete systemd script" echo "Delete systemd script"
@ -37,27 +58,6 @@ if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then
sudo systemctl disable mastodon-streaming.service sudo systemctl disable mastodon-streaming.service
fi 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 # delete postgresql database & user
ynh_psql_drop_db $app ynh_psql_drop_db $app
ynh_psql_drop_user $app ynh_psql_drop_user $app