mirror of
https://github.com/YunoHost-Apps/glitchsoc_ynh.git
synced 2024-09-03 19:15:59 +02:00
Yunohost 3.0 Stretch app upgrade (#85)
* Ready to Debian Stretch * rb 2.5.1 on install * Yarn install on root * Ready to mastodon 2.4.1
This commit is contained in:
parent
7a3313b7cf
commit
64d3147a7b
7 changed files with 85 additions and 56 deletions
|
@ -1,10 +1,10 @@
|
|||
# Mastodon for YunoHost
|
||||
|
||||
[![Latest Version](https://img.shields.io/badge/version-2.4.0-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases)
|
||||
[![Latest Version](https://img.shields.io/badge/version-2.4.1-green.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/releases)
|
||||
[![Status](https://img.shields.io/badge/status-testing-yellow.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/milestones)
|
||||
[![Dependencies](https://img.shields.io/badge/dependencies-includes-lightgrey.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh#dependencies)
|
||||
[![GitHub license](https://img.shields.io/badge/license-GPLv3-blue.svg?style=flat)](https://raw.githubusercontent.com/YunoHost-Apps/mastodon_ynh/master/LICENSE)
|
||||
[![Yunohost version](https://img.shields.io/badge/yunohost-2.7.7_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost)
|
||||
[![Yunohost version](https://img.shields.io/badge/yunohost-2.7.12_tested-orange.svg?style=flat)](https://github.com/YunoHost/yunohost)
|
||||
[![GitHub issues](https://img.shields.io/github/issues/YunoHost-Apps/mastodon_ynh.svg?style=flat)](https://github.com/YunoHost-Apps/mastodon_ynh/issues)
|
||||
|
||||
[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon)
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
"en": "Mastodon is a free, open-source social network.",
|
||||
"fr": "Mastodon est un réseau social gratuit et open source."
|
||||
},
|
||||
"version": "2.4.0",
|
||||
"version": "2.4.1",
|
||||
"url": "https://github.com/tootsuite/mastodon",
|
||||
"license": "AGPL v3.0",
|
||||
"maintainer": {
|
||||
|
|
|
@ -32,7 +32,10 @@ ynh_backup "/etc/cron.d/${app}" "cron.conf"
|
|||
ynh_backup "/etc/systemd/system/mastodon-web.service" "systemd_web.service"
|
||||
ynh_backup "/etc/systemd/system/mastodon-sidekiq.service" "systemd_sidekiq.service"
|
||||
ynh_backup "/etc/systemd/system/mastodon-streaming.service" "systemd_streaming.service"
|
||||
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
||||
debian_version=$(lsb_release -c -s)
|
||||
if [[ $debian_version = jessie ]]; then
|
||||
ynh_backup "/etc/apt/sources.list.d/backports.list" "apt_backports.list"
|
||||
fi
|
||||
ynh_backup "/etc/apt/sources.list.d/yarn.list" "apt_yarn.list"
|
||||
|
||||
# final_path on nginx
|
||||
|
@ -43,5 +46,3 @@ sudo su - postgres <<COMMANDS
|
|||
pg_dump --role=mastodon -U postgres --no-password mastodon_production > mastodon_db.sql
|
||||
COMMANDS
|
||||
ynh_backup "/var/lib/postgresql/${app}_db.sql" "${app}_db.sql"
|
||||
# Fix backup fail on yunohost 2.6
|
||||
#ynh_secure_remove /var/lib/postgresql/mastodon_db.sql
|
||||
|
|
|
@ -47,7 +47,7 @@ ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt
|
|||
ynh_package_install redis-server redis-tools
|
||||
|
||||
# Install postgresql
|
||||
ynh_package_install postgresql postgresql-contrib postgresql-server-dev-9.4
|
||||
ynh_package_install postgresql postgresql-contrib postgresql-server-dev-all
|
||||
|
||||
# Install Ruby
|
||||
ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
||||
|
@ -59,14 +59,23 @@ if [[ $arch = arm* ]]; then
|
|||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
|
||||
fi
|
||||
|
||||
# Install source.list debian package backports & yarn
|
||||
sudo cp ../conf/backports.list /etc/apt/sources.list.d/
|
||||
# Install source.list debian yarn package
|
||||
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||
sudo cp ../conf/yarn.list /etc/apt/sources.list.d/
|
||||
ynh_package_update
|
||||
|
||||
# Install debian package backports
|
||||
# Install source.list debian jessie package backports
|
||||
debian_version=$(lsb_release -c -s)
|
||||
if [[ $debian_version = jessie ]]; then
|
||||
sudo cp ../conf/backports.list /etc/apt/sources.list.d/
|
||||
ynh_package_update
|
||||
sudo apt-get -t jessie-backports -y install ffmpeg
|
||||
else
|
||||
ynh_package_update
|
||||
ynh_package_install ffmpeg
|
||||
fi
|
||||
|
||||
# Install Yarn
|
||||
ynh_package_install yarn
|
||||
|
||||
# Creates the destination directory and stores its location.
|
||||
ynh_app_setting_set $app final_path $final_path
|
||||
|
@ -76,9 +85,6 @@ pushd /opt
|
|||
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
|
||||
sudo apt-get -y install nodejs
|
||||
|
||||
# Install Yarn
|
||||
ynh_package_install yarn
|
||||
|
||||
# Set UTF8 encoding by default
|
||||
sudo su -c "psql" postgres <<< \
|
||||
"update pg_database set datistemplate='false' where datname='template1';"
|
||||
|
@ -122,22 +128,26 @@ COMMANDS
|
|||
|
||||
# Install ruby-build
|
||||
sudo su - $app <<RCOMMANDS
|
||||
/opt/mastodon/.rbenv/bin/rbenv install 2.5.0
|
||||
/opt/mastodon/.rbenv/versions/2.5.0/bin/ruby -v
|
||||
/opt/mastodon/.rbenv/bin/rbenv install 2.5.1
|
||||
/opt/mastodon/.rbenv/versions/2.5.1/bin/ruby -v
|
||||
RCOMMANDS
|
||||
|
||||
# Create symlink for ruby
|
||||
sudo rm /usr/bin/ruby || true
|
||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.5.0/bin/ruby /usr/bin/ruby || true
|
||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
|
||||
|
||||
# Install Mastodon
|
||||
sudo su - $app <<MCOMMANDS
|
||||
pushd ~/live
|
||||
/opt/mastodon/.rbenv/versions/2.5.0/bin/gem install bundler
|
||||
/opt/mastodon/.rbenv/versions/2.5.1/bin/gem install bundler
|
||||
bin/bundle install --deployment --without development test
|
||||
yarn install --production
|
||||
MCOMMANDS
|
||||
|
||||
# Yarn install on root
|
||||
pushd $final_path/live
|
||||
yarn install --pure-lockfile
|
||||
popd
|
||||
|
||||
# Adjust Mastodon config
|
||||
pushd $final_path/live/
|
||||
sudo cp -a .env.production.sample .env.production
|
||||
|
@ -171,9 +181,13 @@ sudo su - $app <<CCOMMANDS
|
|||
pushd ~/live
|
||||
echo "SAFETY_ASSURED=1">> .env.production
|
||||
RAILS_ENV=production bin/bundle exec rails db:setup
|
||||
RAILS_ENV=production bin/bundle exec rails --trace assets:precompile
|
||||
CCOMMANDS
|
||||
|
||||
# Rails precompile on root
|
||||
pushd $final_path/live
|
||||
RAILS_ENV=production bin/bundle exec rails --trace assets:precompile
|
||||
popd
|
||||
|
||||
# init rbenv & create bundle
|
||||
sudo su - $app <<BCOMMANDS
|
||||
. ~/.profile
|
||||
|
@ -191,7 +205,7 @@ sudo cp ../conf/mastodon-streaming.service /etc/systemd/system/mastodon-streamin
|
|||
sudo chown root: /etc/systemd/system/mastodon-streaming.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable /etc/systemd/system/mastodon-*.service
|
||||
sudo systemctl enable mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
# debug
|
||||
sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
|
|
|
@ -23,24 +23,24 @@ domain=$(ynh_app_setting_get "$app" domain)
|
|||
if [ -e "/etc/systemd/system/mastodon-web.service" ]; then
|
||||
echo "Delete systemd script"
|
||||
sudo systemctl stop mastodon-web.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-web.service"
|
||||
sudo systemctl disable mastodon-web.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-web.service"
|
||||
fi
|
||||
|
||||
# Stop mastodon-sidekiq
|
||||
if [ -e "/etc/systemd/system/mastodon-sidekiq.service" ]; then
|
||||
echo "Delete systemd script"
|
||||
sudo systemctl stop mastodon-sidekiq.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-sidekiq.service"
|
||||
sudo systemctl disable mastodon-sidekiq.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-sidekiq.service"
|
||||
fi
|
||||
|
||||
# Stop mastodon-sidekiq
|
||||
if [ -e "/etc/systemd/system/mastodon-streaming.service" ]; then
|
||||
echo "Delete systemd script"
|
||||
sudo systemctl stop mastodon-streaming.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-streaming.service"
|
||||
sudo systemctl disable mastodon-streaming.service
|
||||
ynh_secure_remove "/etc/systemd/system/mastodon-streaming.service"
|
||||
fi
|
||||
|
||||
# Delete service on Yunohost monitoring
|
||||
|
@ -69,13 +69,10 @@ ynh_psql_drop_db "${app}_production"
|
|||
ynh_psql_drop_role "${app}"
|
||||
|
||||
# Remove Debian package
|
||||
sudo apt-get remove --purge -y yarn
|
||||
#sudo apt-get remove --purge -y yarn
|
||||
#sudo apt-get remove --purge -y imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file curl git
|
||||
# Delete redis package
|
||||
#sudo apt-get remove --purge -y redis-server redis-tools
|
||||
# Delete postgresql package
|
||||
#sudo apt-get remove --purge -y postgresql postgresql-contrib
|
||||
# Delete Ruby package
|
||||
#sudo apt-get remove --purge -y autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
||||
|
||||
# Delete app directory and configurations
|
||||
|
@ -89,10 +86,10 @@ REMOVE_NGINX_CONF
|
|||
ynh_secure_remove /etc/cron.d/$app
|
||||
# Delete source.list
|
||||
ynh_secure_remove /etc/apt/sources.list.d/backports.list
|
||||
ynh_secure_remove /etc/apt/sources.list.d/yarn.list
|
||||
#ynh_secure_remove /etc/apt/sources.list.d/yarn.list
|
||||
|
||||
# Delete ruby exec
|
||||
ynh_secure_remove /usr/bin/ruby
|
||||
#ynh_secure_remove /usr/bin/ruby
|
||||
|
||||
# Remove user
|
||||
sudo userdel -f $app
|
||||
|
|
|
@ -67,35 +67,46 @@ sudo adduser $app --home /opt/$app --gecos "First Last,RoomNumber,WorkPhone,Home
|
|||
|
||||
# Reinstall dependencies
|
||||
# Install debian package
|
||||
ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler
|
||||
ynh_package_install imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev
|
||||
|
||||
# Install redis package
|
||||
ynh_package_install redis-server redis-tools
|
||||
|
||||
# Install postgresql
|
||||
ynh_package_install postgresql postgresql-contrib
|
||||
ynh_package_install postgresql postgresql-contrib postgresql-server-dev-all
|
||||
|
||||
# Install Ruby
|
||||
ynh_package_install autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev
|
||||
|
||||
# Install source.list debian package backports & yarn
|
||||
sudo cp ./apt_backports.list /etc/apt/sources.list.d/backports.list
|
||||
# Import debian archive pubkey, need on ARM arch
|
||||
arch=$(uname -m)
|
||||
if [[ $arch = arm* ]]; then
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 8B48AD6246925553
|
||||
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 7638D0442B90D010
|
||||
fi
|
||||
|
||||
# Install source.list debian yarn package
|
||||
sudo curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
|
||||
sudo cp ./apt_yarn.list /etc/apt/sources.list.d/yarn.list
|
||||
ynh_package_update
|
||||
|
||||
# Install debian package backports
|
||||
# Install source.list debian jessie package backports
|
||||
debian_version=$(lsb_release -c -s)
|
||||
if [[ $debian_version = jessie ]]; then
|
||||
sudo cp ./apt_backports.list /etc/apt/sources.list.d/backports.list
|
||||
ynh_package_update
|
||||
sudo apt-get -t jessie-backports -y install ffmpeg
|
||||
else
|
||||
ynh_package_update
|
||||
ynh_package_install ffmpeg
|
||||
fi
|
||||
|
||||
# Install Yarn
|
||||
ynh_package_install yarn
|
||||
|
||||
# Install de Node.js
|
||||
pushd /opt
|
||||
curl -sL https://deb.nodesource.com/setup_6.x | sudo bash -
|
||||
sudo apt-get -y install nodejs
|
||||
|
||||
# Install Yarn
|
||||
ynh_package_install yarn
|
||||
|
||||
# Return to home
|
||||
popd
|
||||
|
||||
# Restore sources & data
|
||||
|
@ -107,6 +118,9 @@ sudo chown -R $app: "$final_path"
|
|||
# Debug
|
||||
sudo ls -alh "$final_path"
|
||||
|
||||
# Restart postgresql
|
||||
sudo systemctl restart postgresql
|
||||
|
||||
# Set UTF8 encoding by default
|
||||
sudo su -c "psql" postgres <<< \
|
||||
"update pg_database set datistemplate='false' where datname='template1';"
|
||||
|
@ -149,18 +163,21 @@ RECOMMANDS
|
|||
# Remove dump
|
||||
ynh_secure_remove $final_path/mastodon_db.sql
|
||||
|
||||
# Create symlink for ruby
|
||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.4.1/bin/ruby /usr/bin/ruby || true
|
||||
# Create symlink for ruby 2.5.1
|
||||
sudo rm /usr/bin/ruby || true
|
||||
sudo ln -s /opt/mastodon/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
|
||||
|
||||
# Upgrade Mastodon
|
||||
sudo su - $app <<RCOMMANDS
|
||||
cd ~/live
|
||||
bin/bundle install
|
||||
# Install Mastodon
|
||||
sudo su - $app <<MCOMMANDS
|
||||
pushd ~/live
|
||||
$final_path/.rbenv/versions/2.5.1/bin/gem install bundler
|
||||
$final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
|
||||
MCOMMANDS
|
||||
|
||||
pushd $final_path/live
|
||||
yarn install --pure-lockfile
|
||||
#RAILS_ENV=production bin/bundle exec rails db:migrate
|
||||
#RAILS_ENV=production bundle exec rails assets:clean
|
||||
#RAILS_ENV=production bin/bundle exec rails assets:precompile
|
||||
RCOMMANDS
|
||||
systemctl restart postgresql
|
||||
popd
|
||||
|
||||
# Modify Nginx configuration file and copy it to Nginx conf directory
|
||||
sudo sed -i "s@__PATH__@$app@g" ./nginx.conf
|
||||
|
@ -177,7 +194,7 @@ sudo cp ./systemd_streaming.service /etc/systemd/system/mastodon-streaming.servi
|
|||
sudo chown root: /etc/systemd/system/mastodon-streaming.service
|
||||
|
||||
sudo systemctl daemon-reload
|
||||
sudo systemctl enable /etc/systemd/system/mastodon-*.service
|
||||
sudo systemctl enable mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
# debug
|
||||
sudo systemctl status mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
|
|
|
@ -35,7 +35,7 @@ sudo sed -i "s@__FINALPATH__@$final_path@g" ../conf/nginx.conf*
|
|||
sudo cp ../conf/nginx.conf /etc/nginx/conf.d/$domain.d/$app.conf
|
||||
|
||||
# Stop Mastodon Services
|
||||
sudo systemctl stop mastodon-*.service
|
||||
sudo systemctl stop mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
|
||||
# Change owner of live folder
|
||||
sudo chown -R $app: $final_path/live
|
||||
|
@ -65,7 +65,7 @@ if [[ $node_version =~ ^v4.*$ ]]; then
|
|||
fi
|
||||
|
||||
# add additional package for upgrade
|
||||
ynh_package_install yarn pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-9.4
|
||||
ynh_package_install yarn pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all
|
||||
|
||||
# Install ruby 2.5.1 for release 2.4.0
|
||||
sudo su - $app <<RCOMMANDS
|
||||
|
@ -84,7 +84,6 @@ sudo su - $app <<MCOMMANDS
|
|||
pushd ~/live
|
||||
$final_path/.rbenv/versions/2.5.1/bin/gem install bundler
|
||||
$final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
|
||||
#yarn install --pure-lockfile
|
||||
MCOMMANDS
|
||||
|
||||
# Install package with yarn and restart postgresql
|
||||
|
@ -97,6 +96,7 @@ popd
|
|||
pushd $final_path/live
|
||||
RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails assets:clean
|
||||
RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails assets:precompile --trace
|
||||
popd
|
||||
|
||||
sudo su - $app <<UCOMMANDS
|
||||
pushd ~/live
|
||||
|
@ -106,7 +106,7 @@ RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails mas
|
|||
UCOMMANDS
|
||||
|
||||
# Restart Mastodon
|
||||
sudo systemctl start mastodon-*.service
|
||||
sudo systemctl start mastodon-web.service mastodon-sidekiq.service mastodon-streaming.service
|
||||
|
||||
# Waiting start all services
|
||||
sleep 30
|
||||
|
|
Loading…
Reference in a new issue