From 9d07d121ad516bf0d3db1c5eb700cb6575630802 Mon Sep 17 00:00:00 2001 From: anmol Date: Wed, 7 Nov 2018 09:42:21 +0530 Subject: [PATCH] Upgrade error fix and cron job --- conf/cron | 2 ++ manifest.json | 2 +- scripts/backup | 6 ++++++ scripts/install | 13 +++++++++---- scripts/remove | 2 ++ scripts/restore | 6 ++++++ scripts/upgrade | 10 +++++++++- 7 files changed, 35 insertions(+), 6 deletions(-) create mode 100644 conf/cron diff --git a/conf/cron b/conf/cron new file mode 100644 index 0000000..2b80d85 --- /dev/null +++ b/conf/cron @@ -0,0 +1,2 @@ +RAILS_ENV=production +@daily cd __FINAL__PATH__/live && __FINAL__PATH__/.rbenv/shims/bundle exec rake __USER__:media:remove_remote diff --git a/manifest.json b/manifest.json index 6ab1f85..5bc3c05 100644 --- a/manifest.json +++ b/manifest.json @@ -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.6.2", + "version": "2.6.1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { diff --git a/scripts/backup b/scripts/backup index bc1822a..eeee720 100644 --- a/scripts/backup +++ b/scripts/backup @@ -73,6 +73,12 @@ ynh_backup "/etc/systemd/system/$app-web.service" ynh_backup "/etc/systemd/system/$app-sidekiq.service" ynh_backup "/etc/systemd/system/$app-streaming.service" +#================================================= +# BACKUP THE CRON FILE +#================================================= + +ynh_backup "/etc/cron.d/$app" + #================================================= # BACKUP THE sources.list FILES #================================================= diff --git a/scripts/install b/scripts/install index e82774b..d457b8b 100644 --- a/scripts/install +++ b/scripts/install @@ -161,14 +161,14 @@ eval \"\$(rbenv init -)\"" > $final_path/.profile # Install ruby-build ( - exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.1 - exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.1 - exec_as "$app" $final_path/.rbenv/versions/2.5.1/bin/ruby -v + exec_as "$app" $final_path/.rbenv/bin/rbenv install 2.5.3 + exec_as "$app" $final_path/.rbenv/bin/rbenv global 2.5.3 + 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 # Yarn install on root pushd $final_path/live @@ -260,6 +260,11 @@ yunohost service add "$app-web" yunohost service add "$app-sidekiq" yunohost service add "$app-streaming" +# 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 + #================================================= # SETUP SSOWAT #================================================= diff --git a/scripts/remove b/scripts/remove index b92d3b9..c6c6b05 100644 --- a/scripts/remove +++ b/scripts/remove @@ -85,6 +85,8 @@ ynh_remove_nginx_config # SPECIFIC REMOVE #================================================= +# Remove a cron file +ynh_secure_remove "/etc/cron.d/$app" #================================================= # REMOVE source.list diff --git a/scripts/restore b/scripts/restore index a25bb6f..822f8fc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -146,6 +146,12 @@ yunohost service add $app-web yunohost service add $app-sidekiq yunohost service add $app-streaming +#================================================= +# RESTORE THE CRON FILE +#================================================= + +ynh_restore_file "/etc/cron.d/$app" + #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 6b03973..f837c9c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -107,7 +107,11 @@ 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" +rsync -a "$final_path/live_back/public/system" "$final_path/live_back/public/." +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 @@ -154,7 +158,6 @@ MCOMMANDS # Install package with yarn and restart postgresql pushd $final_path/live yarn install --pure-lockfile -npm install -D babel-loader @babel/core @babel/preset-env webpack systemctl restart postgresql popd @@ -197,6 +200,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 #=================================================