aboutsummaryrefslogtreecommitdiff
path: root/scripts/upgrade
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/upgrade')
-rw-r--r--scripts/upgrade58
1 files changed, 43 insertions, 15 deletions
diff --git a/scripts/upgrade b/scripts/upgrade
index 0429013..d337e6d 100644
--- a/scripts/upgrade
+++ b/scripts/upgrade
@@ -90,15 +90,25 @@ echo "deb https://dl.yarnpkg.com/debian/ stable main" | tee /etc/apt/sources.lis
ynh_install_nodejs 8
-# add additional package for upgrade
-ynh_package_install pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev postgresql-server-dev-all
+# TODO: use the same mecanism with other files
+ynh_install_app_dependencies \
+ `# debian packages ` \
+ imagemagick libpq-dev libxml2-dev libxslt1-dev file curl apt-transport-https pkg-config libprotobuf-dev protobuf-compiler libicu-dev libidn11-dev \
+ `# redis ` \
+ redis-server redis-tools \
+ `# postgresql ` \
+ postgresql postgresql-contrib \
+ `# Ruby ` \
+ autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3 libgdbm-dev \
+ `# ffmpeg from backports ` \
+ ffmpeg \
+ `# Yarn ` \
+ yarn
#=================================================
# STANDARD UPGRADE STEPS
#=================================================
-# Change owner of live folder
-chown -R $app: $final_path/live
# Stop Mastodon Services
# Restart Mastodon
@@ -107,7 +117,13 @@ yunohost service stop "$app-sidekiq"
yunohost service stop "$app-streaming"
# Download Mastodon
+mv "$final_path/live" "$final_path/live_back"
ynh_setup_source "$final_path/live" "app-mastodon"
+if [ -z $final_path/live_back/public/system ]; then
+ rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/."
+fi
+rsync -a "$final_path/live_back/.env.production" "$final_path/live/."
+rm -Rf "$final_path/live_back"
# Clean files which are not needed anymore
ynh_secure_remove $final_path/live/config/initializers/timeout.rb
@@ -115,7 +131,6 @@ ynh_secure_remove $final_path/live/config/initializers/timeout.rb
#=================================================
# NGINX CONFIGURATION
#=================================================
-
ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/nginx.conf"
ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/nginx.conf"
ynh_add_nginx_config
@@ -125,27 +140,29 @@ ynh_add_nginx_config
ynh_setup_source "$final_path/.rbenv" "app-rbenv"
ynh_setup_source "$final_path/.rbenv/plugins/ruby-build" "app-ruby-build"
+chown -R "$app": "$final_path"
+
# Install ruby 2.5.1
(
- exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.1 || true
- exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1 || true
- exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v
+ exec_as "$app" $final_path/.rbenv/bin/rbenv install -s 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 || true
+ exec_as "$app" $final_path/.rbenv/versions/2.5.3/bin/ruby -v
)
# Create symlink for ruby
rm /usr/bin/ruby || true
-ln -s $final_path/.rbenv/versions/2.5.1/bin/ruby /usr/bin/ruby || true
+ln -s $final_path/.rbenv/versions/2.5.3/bin/ruby /usr/bin/ruby || true
# Preconfig CSS & JS
# 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.3/bin/gem install bundler
if [ "$(lsb_release --codename --short)" == "jessie" ]; then
- $final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --without development test
+ $final_path/.rbenv/versions/2.5.3/bin/bundle install --deployment --without development test
else
- $final_path/.rbenv/versions/2.5.1/bin/bundle install --deployment --force --without development test
+ $final_path/.rbenv/versions/2.5.3/bin/bundle install --deployment --force --without development test
fi
yarn install --pure-lockfile
MCOMMANDS
@@ -160,15 +177,19 @@ popd
# Apply Mastodon upgrade
(
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
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails assets:clean
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails assets:precompile
popd
sudo su - $app <<COMMANDS
pushd ~/live
-RAILS_ENV=production $final_path/.rbenv/versions/2.5.1/bin/bundle exec rails db:migrate
+RAILS_ENV=production $final_path/.rbenv/versions/2.5.3/bin/bundle exec rails db:migrate
COMMANDS
)
+
+# permissions to app files
+chown -R "$app": "$final_path"
+
#=================================================
# SETUP SYSTEMD
#=================================================
@@ -185,6 +206,8 @@ ynh_add_systemd_config "$app-streaming" "mastodon-streaming.service"
#=================================================
# Add service YunoHost
+ynh_replace_string "__PORT_WEB__" "$port_web" "../conf/mastodon-web.service"
+ynh_replace_string "__PORT_STREAM__" "$port_stream" "../conf/mastodon-streaming.service"
yunohost service add "$app-web"
yunohost service add "$app-sidekiq"
yunohost service add "$app-streaming"
@@ -196,6 +219,11 @@ yunohost service start "$app-streaming"
# Waiting start all services
sleep 30
+# SETUP CRON JOB FOR REMOVING CACHE
+ynh_replace_string "__FINAL_PATH__" "$final_path" ../conf/cron
+ynh_replace_string "__USER__" "$app" ../conf/cron
+sudo cp -f ../conf/cron /etc/cron.d/$app
+
#=================================================
# RELOAD NGINX
#=================================================