From b93733d7266f54d97eda4ccab3f28b4d799c095b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 11 Dec 2020 10:48:57 +0100 Subject: [PATCH 1/5] LOAD_NODE -> NODE_LOAD --- conf/mastodon-streaming.service | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index 94309c1..dd9a605 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -9,7 +9,7 @@ Environment="NODE_ENV=production" Environment="PORT=__PORT_STREAM__" Environment="STREAMING_CLUSTER_NUM=1" - Environment=__YNH_LOAD_NODE_PATH__ + Environment="__YNH_NODE_LOAD_PATH__" ExecStart=__YNH_NODE__ ./streaming TimeoutSec=15 Restart=always From a7b1f9a27caf415c3fca5715cc2fe3dd2f82ac62 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 11 Dec 2020 14:39:35 +0100 Subject: [PATCH 2/5] do not run bundle as root --- scripts/install | 18 +++++++++--------- scripts/upgrade | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/scripts/install b/scripts/install index 01a2efc..84e8553 100644 --- a/scripts/install +++ b/scripts/install @@ -189,16 +189,16 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - bundle config deployment 'true' - bundle config without 'development test' - bundle install -j$(getconf _NPROCESSORS_ONLN) - yarn install --pure-lockfile + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config deployment 'true' + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config without 'development test' + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app PATH=$PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - RAILS_ENV=production bundle exec rails db:setup --quiet - RAILS_ENV=production bundle exec rails assets:precompile --quiet - RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null - RAILS_ENV=production bin/tootctl accounts modify "$admin" --approve + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl accounts modify "$admin" --approve popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") diff --git a/scripts/upgrade b/scripts/upgrade index 2914550..895049b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -284,14 +284,14 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - bundle config deployment 'true' - bundle config without 'development test' - bundle install -j$(getconf _NPROCESSORS_ONLN) - yarn install --pure-lockfile - RAILS_ENV=production bundle exec rails assets:clean - RAILS_ENV=production bundle exec rails assets:precompile - RAILS_ENV=production bundle exec rails db:migrate - RAILS_ENV=production bin/tootctl cache clear + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config deployment 'true' + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle config without 'development test' + sudo -u $app PATH=$PATH $RBENV_ROOT/shims/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app PATH=$PATH yarn install --pure-lockfile + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production PATH=$PATH bin/bundle exec rails db:migrate + sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear popd # Recalculate and store the checksum of the file for the next upgrade. From 061b4f9b9133d475728bf0485054cc64afd68757 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 11 Dec 2020 14:40:13 +0100 Subject: [PATCH 3/5] update starting message of sidekiq --- conf/mastodon-sidekiq.service | 26 +++++++++++++------------- conf/mastodon-streaming.service | 28 ++++++++++++++-------------- conf/mastodon-web.service | 26 +++++++++++++------------- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 6 files changed, 43 insertions(+), 43 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index a4fc0da..7031e63 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -1,18 +1,18 @@ [Unit] - Description=__APP__-sidekiq - After=network.target +Description=__APP__-sidekiq +After=network.target [Service] - Type=simple - User=__APP__ - WorkingDirectory=__FINALPATH__/live - Environment="RAILS_ENV=production" - Environment="DB_POOL=25" - Environment="MALLOC_ARENA_MAX=2" - ExecStart=__RBENV_ROOT__/shims/bundle exec sidekiq -c 25 - TimeoutSec=15 - Restart=always - StandardError=syslog +Type=simple +User=__APP__ +WorkingDirectory=__FINALPATH__/live +Environment="RAILS_ENV=production" +Environment="DB_POOL=25" +Environment="MALLOC_ARENA_MAX=2" +ExecStart=__RBENV_ROOT__/shims/bundle exec sidekiq -c 25 +TimeoutSec=15 +Restart=always +StandardError=syslog [Install] - WantedBy=multi-user.target +WantedBy=multi-user.target diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index dd9a605..673b7ae 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -1,19 +1,19 @@ [Unit] - Description=__APP__-streaming - After=network.target +Description=__APP__-streaming +After=network.target [Service] - Type=simple - User=__APP__ - WorkingDirectory=__FINALPATH__/live - Environment="NODE_ENV=production" - Environment="PORT=__PORT_STREAM__" - Environment="STREAMING_CLUSTER_NUM=1" - Environment="__YNH_NODE_LOAD_PATH__" - ExecStart=__YNH_NODE__ ./streaming - TimeoutSec=15 - Restart=always - StandardError=syslog +Type=simple +User=__APP__ +WorkingDirectory=__FINALPATH__/live +Environment="NODE_ENV=production" +Environment="PORT=__PORT_STREAM__" +Environment="STREAMING_CLUSTER_NUM=1" +Environment="__YNH_NODE_LOAD_PATH__" +ExecStart=__YNH_NODE__ ./streaming +TimeoutSec=15 +Restart=always +StandardError=syslog [Install] - WantedBy=multi-user.target +WantedBy=multi-user.target diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index bb07cf4..1f5b6be 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -1,18 +1,18 @@ [Unit] - Description=__APP__-web - After=network.target +Description=__APP__-web +After=network.target [Service] - Type=simple - User=__APP__ - WorkingDirectory=__FINALPATH__/live - Environment="RAILS_ENV=production" - Environment="PORT=__PORT_WEB__" - ExecStart=__RBENV_ROOT__/shims/bundle exec puma -C config/puma.rb - ExecReload=/bin/kill -SIGUSR1 $MAINPID - TimeoutSec=15 - Restart=always - StandardError=syslog +Type=simple +User=__APP__ +WorkingDirectory=__FINALPATH__/live +Environment="RAILS_ENV=production" +Environment="PORT=__PORT_WEB__" +ExecStart=__RBENV_ROOT__/shims/bundle exec puma -C config/puma.rb +ExecReload=/bin/kill -SIGUSR1 $MAINPID +TimeoutSec=15 +Restart=always +StandardError=syslog [Install] - WantedBy=multi-user.target +WantedBy=multi-user.target diff --git a/scripts/install b/scripts/install index 84e8553..6111ae9 100644 --- a/scripts/install +++ b/scripts/install @@ -263,7 +263,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" -ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" +ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" #================================================= diff --git a/scripts/restore b/scripts/restore index 513d924..84610eb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -152,7 +152,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" -ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" +ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 895049b..03408b1 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -352,7 +352,7 @@ fi ynh_script_progression --message="Starting a systemd service..." ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd --line_match="Listening on tcp" -ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Starting processing" +ynh_systemd_action --service_name=${app}-sidekiq --action="start" --log_path=systemd --line_match="Schedules Loaded" ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=systemd --line_match="Worker 1 now listening" #================================================= From b88b24c2d1b878fe04d6495052c5e0ef266f9061 Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 11 Dec 2020 14:40:24 +0100 Subject: [PATCH 4/5] use ynh_string_random --- scripts/install | 6 +++--- scripts/upgrade | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index 6111ae9..d4d51d9 100644 --- a/scripts/install +++ b/scripts/install @@ -165,15 +165,15 @@ ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$adm language="$(echo $language | head -c 2)" ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" -paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +paperclip_secret=$(ynh_string_random --length=128) ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="$config" ynh_app_setting_set --app="$app" --key=paperclip_secret --value="$paperclip_secret" -secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +secret_key_base=$(ynh_string_random --length=128) ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$config" ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base" -otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) +otp_secret=$(ynh_string_random --length=128) ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$config" ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" diff --git a/scripts/upgrade b/scripts/upgrade index 03408b1..a045f46 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -94,7 +94,7 @@ fi if [[ -z "$paperclip_secret" ]]; then paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" $config) if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + paperclip_secret=$(ynh_string_random --length=128) fi ynh_app_setting_set --app=$app --key=paperclip_secret --value="$paperclip_secret" fi @@ -103,7 +103,7 @@ fi if [[ -z "$secret_key_base" ]]; then secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" $config) if [[ -z "$secret_key_base" ]]; then - secret_key_base=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + secret_key_base=$(ynh_string_random --length=128) fi ynh_app_setting_set --app=$app --key=secret_key_base --value="$secret_key_base" fi @@ -112,7 +112,7 @@ fi if [[ -z "$otp_secret" ]]; then otp_secret=$(grep -oP "OTP_SECRET=\K\w+" $config) if [[ -z "$otp_secret" ]]; then - otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) + otp_secret=$(ynh_string_random --length=128) fi ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret" fi From 4338edbd1de311fc0cf2d17ca0a500d1790fab1a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 21 Dec 2020 21:16:27 +0100 Subject: [PATCH 5/5] Test upgarde from 3.2.1~ynh1 --- check_process | 4 ++++ manifest.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 7c95e64..843ff98 100644 --- a/check_process +++ b/check_process @@ -21,6 +21,8 @@ upgrade=1 from_commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef # 3.2.0~ynh1 upgrade=1 from_commit=bde14cc4496445fdfed4616ac44fc9527c8369fd + # 3.2.1~ynh1 + upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697 backup_restore=1 multi_instance=1 # This test is no longer necessary since the version 2.7 (PR: https://github.com/YunoHost/yunohost/pull/304), you can still do it if your app could be installed with this version. @@ -42,3 +44,5 @@ Notification=all name=3.1.2~ynh4 ; commit=bde14cc4496445fdfed4616ac44fc9527c8369fd name=3.2.0~ynh1 + ; commit=248b717f373f3c82bdb19c33cf20980494608697 + name=3.2.1~ynh1 diff --git a/manifest.json b/manifest.json index 84dbe56..9c2a68d 100644 --- a/manifest.json +++ b/manifest.json @@ -6,7 +6,7 @@ "en": "A libre and federated social network.", "fr": "Un réseau social libre et fédéré." }, - "version": "3.2.1~ynh1", + "version": "3.2.1~ynh2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [