From 0ecdb6e3c330b9594a83443ea60597f8367c55bf Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 15:23:13 +0200 Subject: [PATCH 001/101] Fix nginx.conf for multi-instance --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index 7fa7b87..d348613 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -38,7 +38,7 @@ location @proxy { proxy_set_header Proxy ""; proxy_pass_header Server; - proxy_pass http://127.0.0.1:3000; + proxy_pass http://127.0.0.1:__PORT_WEB__; proxy_buffering on; proxy_redirect off; proxy_http_version 1.1; @@ -62,7 +62,7 @@ location /api/v1/streaming { proxy_set_header X-Forwarded-Proto https; proxy_set_header Proxy ""; - proxy_pass http://127.0.0.1:4000; + proxy_pass http://127.0.0.1:__PORT_STREAM__; proxy_buffering off; proxy_redirect off; proxy_http_version 1.1; From ee08de04d42a5e9831f500242bd99d4cb63fbd19 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 19:40:55 +0200 Subject: [PATCH 002/101] Update readme --- README.md | 2 +- README_fr.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bd421eb..5ae936a 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview -Mastodon is a free, open-source social network. A decentralized alternative to commercial platforms, it avoids the risks of a single company monopolizing your communication. Pick a server that you trust — whichever you choose, you can interact with everyone else. Anyone can run their own Mastodon instance and participate in the social network seamlessly. +Mastodon is a free, open-source social network. A decentralized alternative to commercial platforms, it avoids the risks of a single company monopolizing your communication. **Shipped version:** 3.1.2 diff --git a/README_fr.md b/README_fr.md index ea8fc4f..684d762 100644 --- a/README_fr.md +++ b/README_fr.md @@ -9,7 +9,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble -Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. Choisissez un serveur sur lequel vous faites confiance - selon votre choix, vous pouvez interagir avec tous les autres. N'importe qui peut exécuter sa propre instance de Mastodon et participer au réseau social de façon transparente. +Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. **Version incluse:** 3.1.2 From 69fe6ac2e99f1247e11d797601ecd5f7f0abe04f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:09:24 +0200 Subject: [PATCH 003/101] spacing --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index f5e4602..0e62a0a 100644 --- a/check_process +++ b/check_process @@ -3,7 +3,7 @@ ; Manifest domain="domain.tld" (DOMAIN) admin="john" (USER) - language="fr_FR" + language="fr_FR" ; Checks pkg_linter=1 setup_sub_dir=0 From 123386436f2b02c779e403a750da6ef299032090 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:09:42 +0200 Subject: [PATCH 004/101] missing is_public --- check_process | 1 + 1 file changed, 1 insertion(+) diff --git a/check_process b/check_process index 0e62a0a..9d3b4bb 100644 --- a/check_process +++ b/check_process @@ -4,6 +4,7 @@ domain="domain.tld" (DOMAIN) admin="john" (USER) language="fr_FR" + is_public=1 (PUBLIC|public=1|private=0) ; Checks pkg_linter=1 setup_sub_dir=0 From d83e11d8ac71c39dc33fc37f51aabb0baf57263f Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:23:32 +0200 Subject: [PATCH 005/101] indentation --- manifest.json | 110 +++++++++++++++++++++++++------------------------- 1 file changed, 55 insertions(+), 55 deletions(-) diff --git a/manifest.json b/manifest.json index 5925f8f..76b6a5c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,54 +1,54 @@ { - "name": "Mastodon", - "id": "mastodon", - "packaging_format": 1, - "description": { - "en": "A libre and federated social network.", - "fr": "Un réseau social libre et fédéré." - }, - "version": "3.1.2~ynh3", - "url": "https://github.com/tootsuite/mastodon", - "license": "AGPL-3.0-or-later", - "maintainer": [ - { - "name": "cyp", - "email": "cyp@rouquin.me" - }, - { - "name": "nemsia", - "email": "nemsia@nemsia.org" - }, - { - "name": "yalh76" - } - ], + "name": "Mastodon", + "id": "mastodon", + "packaging_format": 1, + "description": { + "en": "A libre and federated social network.", + "fr": "Un réseau social libre et fédéré." + }, + "version": "3.1.2~ynh3", + "url": "https://github.com/tootsuite/mastodon", + "license": "AGPL-3.0-or-later", + "maintainer": [ + { + "name": "cyp", + "email": "cyp@rouquin.me" + }, + { + "name": "nemsia", + "email": "nemsia@nemsia.org" + }, + { + "name": "yalh76" + } + ], "requirements": { "yunohost": ">= 3.7" }, "multi_instance": true, - "services": [ - "nginx" - ], - "arguments": { - "install" : [ - { - "name": "domain", - "type": "domain", - "ask": { - "en": "Choose a domain for Mastodon", - "fr": "Choisissez un domaine pour Mastodon" - }, + "services": [ + "nginx" + ], + "arguments": { + "install" : [ + { + "name": "domain", + "type": "domain", + "ask": { + "en": "Choose a domain for Mastodon", + "fr": "Choisissez un domaine pour Mastodon" + }, "example": "example.com" - }, - { - "name": "admin", - "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, + }, + { + "name": "admin", + "type": "user", + "ask": { + "en": "Choose an admin user", + "fr": "Choisissez l'administrateur" + }, "example": "johndoe" - }, + }, { "name": "is_public", "type": "boolean", @@ -58,16 +58,16 @@ }, "default": true }, - { - "name": "language", + { + "name": "language", "type": "string", - "ask": { - "en": "Choose the application language", - "fr": "Choisissez la langue de l'application" - }, - "choices": ["en_EN", "fr_FR"], - "default": "fr_FR" - } - ] - } + "ask": { + "en": "Choose the application language", + "fr": "Choisissez la langue de l'application" + }, + "choices": ["en_EN", "fr_FR"], + "default": "fr_FR" + } + ] + } } From 93f2e6201a0692f0665148b5d5776217f1c06ba7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:33:02 +0200 Subject: [PATCH 006/101] correct spacing --- check_process | 2 +- scripts/install | 18 +++++++++--------- scripts/upgrade | 22 +++++++++++----------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/check_process b/check_process index 9d3b4bb..52ea6cb 100644 --- a/check_process +++ b/check_process @@ -2,7 +2,7 @@ auto_remove=1 ; Manifest domain="domain.tld" (DOMAIN) - admin="john" (USER) + admin="john" (USER) language="fr_FR" is_public=1 (PUBLIC|public=1|private=0) ; Checks diff --git a/scripts/install b/scripts/install index cb059ba..d3cc1ca 100644 --- a/scripts/install +++ b/scripts/install @@ -108,7 +108,7 @@ ynh_script_progression --message="Setting up source files..." --weight=5 ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src mkdir $final_path -ynh_setup_source --dest_dir="$final_path/live" +ynh_setup_source --dest_dir="$final_path/live" # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" @@ -167,10 +167,10 @@ ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" paperclip_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production" @@ -208,8 +208,8 @@ ynh_secure_remove --file="$final_path/live/acc.txt" vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="${final_path}/live/.env.production" -ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="${final_path}/live/.env.production" ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" @@ -222,7 +222,7 @@ ynh_secure_remove --file="$final_path/live/key.txt" ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= @@ -231,11 +231,11 @@ sudo cp -f ../conf/cron /etc/cron.d/$app ynh_script_progression --message="Configuring a systemd service..." --weight=5 # Create a dedicated systemd config -ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 153437b..88947cf 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -180,7 +180,7 @@ then mkdir $tmpdir/system if [ -d "$final_path/live/public/system" ]; then rsync -a "$final_path/live/public/system" "$tmpdir/." - fi + fi rsync -a "$final_path/live/.env.production" "$tmpdir/." ynh_secure_remove --file="$final_path/live" ynh_setup_source --dest_dir="$final_path/live" @@ -262,10 +262,10 @@ ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production" ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production" ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production" @@ -273,8 +273,8 @@ ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secre ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production" -ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "$final_path/live/.env.production" -ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "$final_path/live/.env.production" +ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file"$final_path/live/.env.production" +ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$final_path/live/.env.production" #================================================= # UPGRADE MASTODON @@ -301,8 +301,8 @@ popd # ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" # ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" # ynh_secure_remove "$final_path/live/key.txt" -# ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production" -# ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production" +# ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production" +# ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production" #fi # Recalculate and store the checksum of the file for the next upgrade. @@ -314,7 +314,7 @@ ynh_store_file_checksum --file="${final_path}/live/.env.production" ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" +ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" sudo cp -f ../conf/cron /etc/cron.d/$app #================================================= @@ -323,11 +323,11 @@ sudo cp -f ../conf/cron /etc/cron.d/$app ynh_script_progression --message="Upgrading systemd configuration..." --weight=13 # Create a dedicated systemd config -ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" #================================================= From 0e27aab64a45ecdae0ce2b4500e81f72f28f9293 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:33:31 +0200 Subject: [PATCH 007/101] remove not needed code --- scripts/upgrade | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 88947cf..1c78242 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -293,18 +293,6 @@ pushd "$final_path/live" sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear popd -# If vapid_private_key doesn't exist, retrieve it or create it -#if [[ -z "$vapid_private_key" ]]; then -# sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.0/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt -# vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") -# vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") -# ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" -# ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" -# ynh_secure_remove "$final_path/live/key.txt" -# ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "${final_path}/live/.env.production" -# ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "${final_path}/live/.env.production" -#fi - # Recalculate and store the checksum of the file for the next upgrade. ynh_store_file_checksum --file="${final_path}/live/.env.production" From 36ff48ac1d930f235217d5758f6bd33bac039cc5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 18 May 2020 22:38:55 +0200 Subject: [PATCH 008/101] config filename factorisation --- scripts/install | 29 +++++++++++++++-------------- scripts/upgrade | 44 +++++++++++++++++++++++--------------------- 2 files changed, 38 insertions(+), 35 deletions(-) diff --git a/scripts/install b/scripts/install index d3cc1ca..409911b 100644 --- a/scripts/install +++ b/scripts/install @@ -162,26 +162,27 @@ ynh_install_ruby --ruby_version=2.6.5 #================================================= ynh_script_progression --message="Modifying a config file..." --weight=2 -cp -f ../conf/.env.production.sample "$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" +config="$final_path/live/.env.production" +cp -f ../conf/.env.production.sample "$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="$config" language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" +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) -ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production" +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) -ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$final_path/live/.env.production" +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) -ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production" +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" #================================================= @@ -195,7 +196,7 @@ pushd "$final_path/live" ynh_use_nodejs sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.5/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile - sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production + sudo -u "$app" echo "SAFETY_ASSURED=1">> $config sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails db:setup --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:precompile --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt @@ -208,8 +209,8 @@ ynh_secure_remove --file="$final_path/live/acc.txt" vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="${final_path}/live/.env.production" -ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="$config" +ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$config" ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" @@ -244,7 +245,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming ynh_script_progression --message="Storing the config file checksum..." --weight=1 # Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="${final_path}/live/.env.production" +ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALIZATION diff --git a/scripts/upgrade b/scripts/upgrade index 1c78242..98d0403 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -51,6 +51,8 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +config="$final_path/live/.env.production" + # If db_name doesn't exist, create it if [ -z "$db_name" ]; then db_name="${app}_production" @@ -87,12 +89,12 @@ if [[ -z "$db_pwd" ]]; then ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd ynh_psql_test_if_first_run sudo --login --user=postgres psql -c"ALTER user $app WITH PASSWORD '$db_pwd'" postgres - ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="${final_path}/live/.env.production" + ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="$config" fi # If paperclip_secret doesn't exist, retrieve it or create it if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" ${final_path}/live/.env.production) + 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) fi @@ -101,7 +103,7 @@ fi # If secret_key_base doesn't exist, retrieve it or create it if [[ -z "$secret_key_base" ]]; then - secret_key_base=$(grep -oP "SECRET_KEY_BASE=\K\w+" ${final_path}/live/.env.production) + 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) fi @@ -110,7 +112,7 @@ fi # If otp_secret doesn't exist, retrieve it or create it if [[ -z "$otp_secret" ]]; then - otp_secret=$(grep -oP "OTP_SECRET=\K\w+" ${final_path}/live/.env.production) + 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) fi @@ -119,8 +121,8 @@ fi # If vapid_private_key doesn't exist, retrieve it or create it if [[ -z "$vapid_private_key" ]]; then - vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" ${final_path}/live/.env.production) - vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" ${final_path}/live/.env.production) + vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" $config) + vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" $config) ynh_app_setting_set "$app" vapid_private_key "$vapid_private_key" ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" fi @@ -181,7 +183,7 @@ then if [ -d "$final_path/live/public/system" ]; then rsync -a "$final_path/live/public/system" "$tmpdir/." fi - rsync -a "$final_path/live/.env.production" "$tmpdir/." + rsync -a "$config" "$tmpdir/." ynh_secure_remove --file="$final_path/live" ynh_setup_source --dest_dir="$final_path/live" @@ -256,25 +258,25 @@ ynh_install_ruby --ruby_version=2.6.5 #================================================= ynh_script_progression --message="Modifying a config file..." --weight=1 -ynh_backup_if_checksum_is_different --file="$final_path/live/.env.production" -cp -f ../conf/.env.production.sample "$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="${final_path}/live/.env.production" +ynh_backup_if_checksum_is_different --file="$config" +cp -f ../conf/.env.production.sample "$config" +ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$config" +ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" +ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" +ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" +ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="$config" language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" -ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="${final_path}/live/.env.production" +ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="$config" -ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$config" -ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$config" -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file"$final_path/live/.env.production" -ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file"$config" +ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$config" #================================================= # UPGRADE MASTODON @@ -294,7 +296,7 @@ pushd "$final_path/live" popd # Recalculate and store the checksum of the file for the next upgrade. -ynh_store_file_checksum --file="${final_path}/live/.env.production" +ynh_store_file_checksum --file="$config" #================================================= # SETUP CRON JOB FOR REMOVING CACHE From 736d7908b4f31095e7a7b92fc632b0f6fad05e83 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:20:45 +0200 Subject: [PATCH 009/101] RUBY_VERSION factorisation --- conf/cron | 2 +- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-web.service | 2 +- scripts/_common.sh | 2 ++ scripts/install | 28 +++++++++++++++++----------- scripts/restore | 8 +++++--- scripts/upgrade | 25 +++++++++++++++---------- 7 files changed, 42 insertions(+), 27 deletions(-) diff --git a/conf/cron b/conf/cron index 9a984a3..8bf7bdb 100644 --- a/conf/cron +++ b/conf/cron @@ -1,2 +1,2 @@ RAILS_ENV=production -@daily cd __FINAL__PATH__/live && /opt/rbenv/versions/2.6.5/bin/bundle exec rake __USER__:media:remove_remote +@daily cd __FINAL__PATH__/live && __RBENVROOT__/shims/bundle exec rake __USER__:media:remove_remote diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index d5fc7e1..73f29e5 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -9,7 +9,7 @@ Environment="RAILS_ENV=production" Environment="DB_POOL=25" Environment="MALLOC_ARENA_MAX=2" - ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec sidekiq -c 25 + ExecStart=__RBENVROOT__/shims/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index bb65afe..14d1260 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" - ExecStart=/opt/rbenv/versions/2.6.5/bin/bundle exec puma -C config/puma.rb + ExecStart=__RBENVROOT__/shims/bundle exec puma -C config/puma.rb ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 Restart=always diff --git a/scripts/_common.sh b/scripts/_common.sh index 015c1e9..f39b966 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,6 +7,8 @@ # dependencies used by the app pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https" +RUBY_VERSION="2.6.5" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 409911b..2e218c6 100644 --- a/scripts/install +++ b/scripts/install @@ -20,6 +20,7 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { + read -p "key" ynh_clean_check_starting } # Exit if an error occurs during the execution of the script @@ -153,9 +154,11 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Installing Ruby..." --weight=424 -ynh_install_ruby --ruby_version=2.6.5 -/opt/rbenv/versions/2.6.5/bin/gem update --system -/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document +ynh_install_ruby --ruby_version=$RUBY_VERSION +pushd "$final_path/live" + gem update --system + gem install bundler:1.17.3 --no-document +popd #================================================= # MODIFY A CONFIG FILE @@ -194,13 +197,13 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.5/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test - sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile - sudo -u "$app" echo "SAFETY_ASSURED=1">> $config - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails db:setup --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:precompile --quiet - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > acc.txt + bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + 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 > acc.txt popd admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) @@ -224,7 +227,8 @@ ynh_script_progression --message="Setuping a cron job for removing cache..." --w ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" -sudo cp -f ../conf/cron /etc/cron.d/$app +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron" +cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD @@ -233,6 +237,8 @@ ynh_script_progression --message="Configuring a systemd service..." --weight=5 # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service" ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" diff --git a/scripts/restore b/scripts/restore index c6e4bc8..bd79e95 100644 --- a/scripts/restore +++ b/scripts/restore @@ -114,9 +114,11 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= ynh_script_progression --message="Installing Ruby..." --weight=393 -ynh_install_ruby --ruby_version=2.6.5 -/opt/rbenv/versions/2.6.5/bin/gem update --system -/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document +ynh_install_ruby --ruby_version=$RUBY_VERSION +pushd "$final_path/live" + gem update --system + gem install bundler:1.17.3 --no-document +popd #================================================= # RESTORE THE POSTGRESQL DATABASE diff --git a/scripts/upgrade b/scripts/upgrade index 98d0403..f34010b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -249,9 +249,11 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Installing Ruby..." --weight=424 -ynh_install_ruby --ruby_version=2.6.5 -/opt/rbenv/versions/2.6.5/bin/gem update --system -/opt/rbenv/versions/2.6.5/bin/gem install bundler:1.17.3 --no-document +ynh_install_ruby --ruby_version=$RUBY_VERSION +pushd "$final_path/live" + gem update --system + gem install bundler:1.17.3 --no-document +popd #================================================= # MODIFY A CONFIG FILE @@ -287,12 +289,12 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.5/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test - sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:clean - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails assets:precompile - sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.5/bin/bundle exec rails db:migrate - sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear + bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + 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 popd # Recalculate and store the checksum of the file for the next upgrade. @@ -305,7 +307,8 @@ ynh_script_progression --message="Setuping a cron job for removing cache..." --w ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" -sudo cp -f ../conf/cron /etc/cron.d/$app +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron" +cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD @@ -314,6 +317,8 @@ ynh_script_progression --message="Upgrading systemd configuration..." --weight=1 # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service" +ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service" ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" From b5556ae674f1ca35da8f5e1d5a8a8ce4e69bc580 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:24:16 +0200 Subject: [PATCH 010/101] BUNDLER_VERSION factorization --- scripts/_common.sh | 2 ++ scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 3 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index f39b966..bb0fe95 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,6 +9,8 @@ pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git RUBY_VERSION="2.6.5" +BUNDLER_VERSION="1.17.3" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 2e218c6..ab3aaa9 100644 --- a/scripts/install +++ b/scripts/install @@ -157,7 +157,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=424 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= diff --git a/scripts/restore b/scripts/restore index bd79e95..724afc3 100644 --- a/scripts/restore +++ b/scripts/restore @@ -117,7 +117,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=393 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index f34010b..149c2f5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -252,7 +252,7 @@ ynh_script_progression --message="Installing Ruby..." --weight=424 ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:1.17.3 --no-document + gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= From ff8fbd3fd06a0a87272e751bf3011d730dbfffc0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:31:51 +0200 Subject: [PATCH 011/101] disable registrations and invitations --- scripts/install | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/install b/scripts/install index ab3aaa9..c5e5775 100644 --- a/scripts/install +++ b/scripts/install @@ -188,6 +188,9 @@ otp_secret=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c 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" +ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml" +ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml" + #================================================= # INSTALLING MASTODON #================================================= From 2396f84cdb7c8105037df6a45b857a0d28ed0804 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 01:39:19 +0200 Subject: [PATCH 012/101] Update install --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index c5e5775..c359dfd 100644 --- a/scripts/install +++ b/scripts/install @@ -20,7 +20,6 @@ source /usr/share/yunohost/helpers ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { - read -p "key" ynh_clean_check_starting } # Exit if an error occurs during the execution of the script From 4aafbbb86cd9110adce6506b93ba17463578c308 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 13:22:00 +0200 Subject: [PATCH 013/101] missing = :/ --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 149c2f5..7d747e0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -277,7 +277,7 @@ ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secre ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$config" -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file"$config" +ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="$config" ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$config" #================================================= From f4487bb3df27286b811579116af4decb8bd29fea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 13:25:24 +0200 Subject: [PATCH 014/101] fix bundle install --- scripts/install | 4 +++- scripts/upgrade | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index c359dfd..f6a1411 100644 --- a/scripts/install +++ b/scripts/install @@ -199,7 +199,9 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + bundle config deployment 'true' + bundle config without 'development test' + bundle install -j$(getconf _NPROCESSORS_ONLN) yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config RAILS_ENV=production bundle exec rails db:setup --quiet diff --git a/scripts/upgrade b/scripts/upgrade index 7d747e0..ee97cde 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -289,7 +289,9 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + 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 From d6ad96999ea61b292d212ebc00f0d1ef2eecff72 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 18:36:29 +0200 Subject: [PATCH 015/101] remove ynh_send_readme_to_admin__2 --- scripts/install | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/install b/scripts/install index f6a1411..510701f 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_extra_apt_repos__3 -source ynh_send_readme_to_admin__2 source ynh_add_swap source ynh_check_ram source /usr/share/yunohost/helpers From aac5dadc34f4810b852f1836576272eb52e115a1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 18:44:16 +0200 Subject: [PATCH 016/101] $NODEJS_VERSION factorisation --- scripts/_common.sh | 2 ++ scripts/install | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index bb0fe95..0c5fb0e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,6 +11,8 @@ RUBY_VERSION="2.6.5" BUNDLER_VERSION="1.17.3" +NODEJS_VERSION="10" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 510701f..8f4f223 100644 --- a/scripts/install +++ b/scripts/install @@ -80,7 +80,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= ynh_script_progression --message="Installing dependencies..." --weight=86 -ynh_install_nodejs --nodejs_version="10" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" diff --git a/scripts/upgrade b/scripts/upgrade index ee97cde..da0e7bb 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -213,7 +213,7 @@ ynh_add_nginx_config 'port_web port_stream' ynh_script_progression --message="Upgrading dependencies..." --weight=24 ynh_remove_nodejs -ynh_install_nodejs --nodejs_version="10" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" From 2eb6680a727a36ac5bcb179d20eec5c6a4c871d3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 18:58:25 +0200 Subject: [PATCH 017/101] Update restore --- scripts/restore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/restore b/scripts/restore index 724afc3..5a349d4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -105,7 +105,7 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Reinstalling dependencies..." --weight=63 -ynh_install_nodejs --nodejs_version="10" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" From c309a117e7eacc2bdaaa8057ddf4411fc6bd9bd9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 19:19:02 +0200 Subject: [PATCH 018/101] fix admin account approval --- scripts/install | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/install b/scripts/install index 8f4f223..1f1a11f 100644 --- a/scripts/install +++ b/scripts/install @@ -207,6 +207,7 @@ pushd "$final_path/live" 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 > acc.txt + RAILS_ENV=production bin/tootctl accounts modify "$admin" --approve popd admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) From 5f421f48d7fb69b8c8adafad48b93bbb621c6dce Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 19:20:06 +0200 Subject: [PATCH 019/101] Fix CRON --- conf/cron | 2 +- scripts/install | 2 -- scripts/upgrade | 2 -- 3 files changed, 1 insertion(+), 5 deletions(-) diff --git a/conf/cron b/conf/cron index 8bf7bdb..af98c3c 100644 --- a/conf/cron +++ b/conf/cron @@ -1,2 +1,2 @@ RAILS_ENV=production -@daily cd __FINAL__PATH__/live && __RBENVROOT__/shims/bundle exec rake __USER__:media:remove_remote +@daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove diff --git a/scripts/install b/scripts/install index 1f1a11f..32cb94e 100644 --- a/scripts/install +++ b/scripts/install @@ -230,8 +230,6 @@ ynh_secure_remove --file="$final_path/live/key.txt" ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index da0e7bb..0a19125 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -308,8 +308,6 @@ ynh_store_file_checksum --file="$config" ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -ynh_replace_string --match_string="__USER__" --replace_string="$app" --target_file="../conf/cron" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app #================================================= From bf0fef631f39616ed455cc9face32cacdda16172 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 19:24:47 +0200 Subject: [PATCH 020/101] remove not needed retrieving admin generated password --- scripts/install | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 32cb94e..8b36e56 100644 --- a/scripts/install +++ b/scripts/install @@ -206,13 +206,10 @@ pushd "$final_path/live" 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 > acc.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 popd -admin_pass=$( tail -1 $final_path/live/acc.txt | head -1 | cut -c 15- ) -ynh_secure_remove --file="$final_path/live/acc.txt" - vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") From 477d3adf08699435883ff2c7c7fee50123bfbdc7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 19:51:05 +0200 Subject: [PATCH 021/101] increase version number --- check_process | 2 ++ manifest.json | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 52ea6cb..12c74c8 100644 --- a/check_process +++ b/check_process @@ -15,6 +15,8 @@ upgrade=1 # 3.1.2~ynh2 upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 + # 3.1.2~ynh3 + upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 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. diff --git a/manifest.json b/manifest.json index 76b6a5c..12f7789 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.1.2~ynh3", + "version": "3.1.2~ynh4", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ From c2f6661420069146b6ca6777b4acedd827863bf1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 20:26:36 +0200 Subject: [PATCH 022/101] increase nodejs version --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 0c5fb0e..e0686b2 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,7 +11,7 @@ RUBY_VERSION="2.6.5" BUNDLER_VERSION="1.17.3" -NODEJS_VERSION="10" +NODEJS_VERSION="12" #================================================= # PERSONAL HELPERS From 1977f0fff725ff589618fffc18e861b264f46891 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 19 May 2020 23:57:16 +0200 Subject: [PATCH 023/101] Imrpove cron --- conf/cron | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/conf/cron b/conf/cron index af98c3c..1296c1b 100644 --- a/conf/cron +++ b/conf/cron @@ -1,2 +1,4 @@ -RAILS_ENV=production @daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl status remove From b4dc3908d08cb1767dbe729ea2cc8956369359c3 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 May 2020 03:12:41 +0200 Subject: [PATCH 024/101] add tootctl preview_cards remove --- conf/cron | 1 + 1 file changed, 1 insertion(+) diff --git a/conf/cron b/conf/cron index 1296c1b..f3cae63 100644 --- a/conf/cron +++ b/conf/cron @@ -2,3 +2,4 @@ @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl status remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl preview_cards remove From 29c9a33cdb9f11f14083bebaa519bf7a6f762cfc Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 22 May 2020 03:16:41 +0200 Subject: [PATCH 025/101] fix tootctl statuses remove --- conf/cron | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/cron b/conf/cron index f3cae63..776808b 100644 --- a/conf/cron +++ b/conf/cron @@ -1,5 +1,5 @@ @daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl status remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl statuses remove @monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl preview_cards remove From f7e0cfd553116619409035037643441b1da0be85 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 12:23:48 +0200 Subject: [PATCH 026/101] moving to 3.8 new helper --- manifest.json | 2 +- scripts/install | 1 - scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 1 - scripts/ynh_add_extra_apt_repos__3 | 294 ----------------------------- 6 files changed, 1 insertion(+), 299 deletions(-) delete mode 100644 scripts/ynh_add_extra_apt_repos__3 diff --git a/manifest.json b/manifest.json index 12f7789..b54d843 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.7" + "yunohost": ">= 3.8" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 8b36e56..388b2a3 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/remove b/scripts/remove index f2b2e16..d955a8a 100644 --- a/scripts/remove +++ b/scripts/remove @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source /usr/share/yunohost/helpers diff --git a/scripts/restore b/scripts/restore index 5a349d4..dbcd5cb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -9,7 +9,6 @@ #Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 -source ../settings/scripts/ynh_add_extra_apt_repos__3 source ../settings/scripts/ynh_add_swap source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/upgrade b/scripts/upgrade index 0a19125..c5be012 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_add_extra_apt_repos__3 source ynh_add_swap source ynh_check_ram source /usr/share/yunohost/helpers diff --git a/scripts/ynh_add_extra_apt_repos__3 b/scripts/ynh_add_extra_apt_repos__3 deleted file mode 100644 index 3276f00..0000000 --- a/scripts/ynh_add_extra_apt_repos__3 +++ /dev/null @@ -1,294 +0,0 @@ -#!/bin/bash - -# Pin a repository. -# -# usage: ynh_pin_repo --package=packages --pin=pin_filter [--priority=priority_value] [--name=name] [--append] -# | arg: -p, --package - Packages concerned by the pin. Or all, *. -# | arg: -i, --pin - Filter for the pin. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# See https://manpages.debian.org/stretch/apt/apt_preferences.5.en.html for information about pinning. -# -ynh_pin_repo () { - # Declare an array to define the options of this helper. - local legacy_args=pirna - declare -Ar args_array=( [p]=package= [i]=pin= [r]=priority= [n]=name= [a]=append ) - local package - local pin - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - package="${package:-*}" - priority=${priority:-50} - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/preferences.d" - echo "Package: $package -Pin: $pin -Pin-Priority: $priority" \ - | $append "/etc/apt/preferences.d/$name" -} - -# Add a repository. -# -# usage: ynh_add_repo --uri=uri --suite=suite --component=component [--name=name] [--append] -# | arg: -u, --uri - Uri of the repository. -# | arg: -s, --suite - Suite of the repository. -# | arg: -c, --component - Component of the repository. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -# -# Example for a repo like deb http://forge.yunohost.org/debian/ stretch stable -# uri suite component -# ynh_add_repo --uri=http://forge.yunohost.org/debian/ --suite=stretch --component=stable -# -ynh_add_repo () { - # Declare an array to define the options of this helper. - local legacy_args=uscna - declare -Ar args_array=( [u]=uri= [s]=suite= [c]=component= [n]=name= [a]=append ) - local uri - local suite - local component - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - - if [ $append -eq 1 ] - then - append="tee -a" - else - append="tee" - fi - - mkdir -p "/etc/apt/sources.list.d" - # Add the new repo in sources.list.d - echo "deb $uri $suite $component" \ - | $append "/etc/apt/sources.list.d/$name.list" -} - -# Add an extra repository correctly, pin it and get the key. -# -# usage: ynh_install_extra_repo --repo="repo" [--key=key_url] [--priority=priority_value] [--name=name] [--append] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -k, --key - url to get the public key. -# | arg: -p, --priority - Priority for the pin -# | arg: -n, --name - Name for the files for this repo, $app as default value. -# | arg: -a, --append - Do not overwrite existing files. -ynh_install_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=rkpna - declare -Ar args_array=( [r]=repo= [k]=key= [p]=priority= [n]=name= [a]=append ) - local repo - local key - local priority - local name - local append - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - append=${append:-0} - key=${key:-0} - priority=${priority:-} - - if [ $append -eq 1 ] - then - append="--append" - wget_append="tee -a" - else - append="" - wget_append="tee" - fi - - # Split the repository into uri, suite and components. - # Remove "deb " at the beginning of the repo. - repo="${repo#deb }" - - # Get the uri - local uri="$(echo "$repo" | awk '{ print $1 }')" - - # Get the suite - local suite="$(echo "$repo" | awk '{ print $2 }')" - - # Get the components - local component="${repo##$uri $suite }" - - # Add the repository into sources.list.d - ynh_add_repo --uri="$uri" --suite="$suite" --component="$component" --name="$name" $append - - # Pin the new repo with the default priority, so it won't be used for upgrades. - # Build $pin from the uri without http and any sub path - local pin="${uri#*://}" - pin="${pin%%/*}" - # Set a priority only if asked - if [ -n "$priority" ] - then - priority="--priority=$priority" - fi - ynh_pin_repo --package="*" --pin="origin \"$pin\"" $priority --name="$name" $append - - # Get the public key for the repo - if [ -n "$key" ] - then - mkdir -p "/etc/apt/trusted.gpg.d" - wget -q "$key" -O - | gpg --dearmor | $wget_append /etc/apt/trusted.gpg.d/$name.gpg > /dev/null - fi - - # Update the list of package with the new repo - ynh_package_update -} - -# Remove an extra repository and the assiociated configuration. -# -# usage: ynh_remove_extra_repo [--name=name] -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_remove_extra_repo () { - # Declare an array to define the options of this helper. - local legacy_args=n - declare -Ar args_array=( [n]=name= ) - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - - ynh_secure_remove "/etc/apt/sources.list.d/$name.list" - ynh_secure_remove "/etc/apt/preferences.d/$name" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.gpg" - ynh_secure_remove "/etc/apt/trusted.gpg.d/$name.asc" - - # Update the list of package to exclude the old repo - ynh_package_update -} - -# Install packages from an extra repository properly. -# -# usage: ynh_install_extra_app_dependencies --repo="repo" --package="dep1 dep2" [--key=key_url] [--name=name] -# | arg: -r, --repo - Complete url of the extra repository. -# | arg: -p, --package - The packages to install from this extra repository -# | arg: -k, --key - url to get the public key. -# | arg: -n, --name - Name for the files for this repo, $app as default value. -ynh_install_extra_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=rpkn - declare -Ar args_array=( [r]=repo= [p]=package= [k]=key= [n]=name= ) - local repo - local package - local key - local name - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - name="${name:-$app}" - key=${key:-0} - - # Set a key only if asked - if [ -n "$key" ] - then - key="--key=$key" - fi - # Add an extra repository for those packages - ynh_install_extra_repo --repo="$repo" $key --priority=995 --name=$name - - # Install requested dependencies from this extra repository. - ynh_add_app_dependencies --package="$package" - - # Remove this extra repository after packages are installed - ynh_remove_extra_repo --name=$app -} - -#================================================= - -# patched version of ynh_install_app_dependencies to be used with ynh_add_app_dependencies - -# Define and install dependencies with a equivs control file -# This helper can/should only be called once per app -# -# usage: ynh_install_app_dependencies dep [dep [...]] -# | arg: dep - the package name to install in dependence -# You can give a choice between some package with this syntax : "dep1|dep2" -# Example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" -# This mean in the dependence tree : dep1 & dep2 & (dep3 | dep4 | dep5) -# -# Requires YunoHost version 2.6.4 or higher. -ynh_install_app_dependencies () { - local dependencies=$@ - dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" - dependencies=${dependencies//|/ | } - local manifest_path="../manifest.json" - if [ ! -e "$manifest_path" ]; then - manifest_path="../settings/manifest.json" # Into the restore script, the manifest is not at the same place - fi - - local version=$(grep '\"version\": ' "$manifest_path" | cut -d '"' -f 4) # Retrieve the version number in the manifest file. - if [ ${#version} -eq 0 ]; then - version="1.0" - fi - local dep_app=${app//_/-} # Replace all '_' by '-' - - # Handle specific versions - if [[ "$dependencies" =~ [\<=\>] ]] - then - # Replace version specifications by relationships syntax - # https://www.debian.org/doc/debian-policy/ch-relationships.html - # Sed clarification - # [^(\<=\>] ignore if it begins by ( or < = >. To not apply twice. - # [\<=\>] matches < = or > - # \+ matches one or more occurence of the previous characters, for >= or >>. - # [^,]\+ matches all characters except ',' - # Ex: package>=1.0 will be replaced by package (>= 1.0) - dependencies="$(echo "$dependencies" | sed 's/\([^(\<=\>]\)\([\<=\>]\+\)\([^,]\+\)/\1 (\2 \3)/g')" - fi - - cat > /tmp/${dep_app}-ynh-deps.control << EOF # Make a control file for equivs-build -Section: misc -Priority: optional -Package: ${dep_app}-ynh-deps -Version: ${version} -Depends: ${dependencies} -Architecture: all -Description: Fake package for $app (YunoHost app) dependencies - This meta-package is only responsible of installing its dependencies. -EOF - ynh_package_install_from_equivs /tmp/${dep_app}-ynh-deps.control \ - || ynh_die --message="Unable to install dependencies" # Install the fake package and its dependencies - rm /tmp/${dep_app}-ynh-deps.control - ynh_app_setting_set --app=$app --key=apt_dependencies --value="$dependencies" -} - -ynh_add_app_dependencies () { - # Declare an array to define the options of this helper. - local legacy_args=pr - declare -Ar args_array=( [p]=package= [r]=replace) - local package - local replace - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - replace=${replace:-0} - - local current_dependencies="" - if [ $replace -eq 0 ] - then - local dep_app=${app//_/-} # Replace all '_' by '-' - if ynh_package_is_installed --package="${dep_app}-ynh-deps" - then - current_dependencies="$(dpkg-query --show --showformat='${Depends}' ${dep_app}-ynh-deps) " - fi - - current_dependencies=${current_dependencies// | /|} - fi - - ynh_install_app_dependencies "${current_dependencies}${package}" -} From 3d713af143776d074d2f37cb0689d777aa632fdf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:18:02 +0200 Subject: [PATCH 027/101] Moving from ynh_check_ram to ynh_get_ram --- manifest.json | 2 +- scripts/install | 6 ++-- scripts/restore | 4 +-- scripts/upgrade | 4 +-- scripts/ynh_check_ram | 72 ------------------------------------------- 5 files changed, 5 insertions(+), 83 deletions(-) delete mode 100644 scripts/ynh_check_ram diff --git a/manifest.json b/manifest.json index b54d843..9041ab7 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.8" + "yunohost": ">= 3.8.1" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 388b2a3..97dee20 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap -source ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -134,12 +133,11 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Adding swap is needed..." --weight=4 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then - # Need a minimum of 8Go of memory + # Need a minimum of 2.5Go of memory swap_needed=$((2560 - $total_memory)) fi diff --git a/scripts/restore b/scripts/restore index dbcd5cb..ed0b27d 100644 --- a/scripts/restore +++ b/scripts/restore @@ -10,7 +10,6 @@ source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 source ../settings/scripts/ynh_add_swap -source ../settings/scripts/ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -87,8 +86,7 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Adding swap if needed..." --weight=4 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then diff --git a/scripts/upgrade b/scripts/upgrade index c5be012..9e02c01 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap -source ynh_check_ram source /usr/share/yunohost/helpers #================================================= @@ -231,8 +230,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= ynh_script_progression --message="Adding swap if needed..." --weight=7 -total_memory=$(ynh_check_ram) -total_swap=$(ynh_check_ram --only_swap) +total_memory=$(ynh_get_ram --total) swap_needed=0 if [ $total_memory -lt 2560 ]; then diff --git a/scripts/ynh_check_ram b/scripts/ynh_check_ram deleted file mode 100644 index 11012a3..0000000 --- a/scripts/ynh_check_ram +++ /dev/null @@ -1,72 +0,0 @@ -#!/bin/bash - -# Check the amount of available RAM -# -# usage: ynh_check_ram [--required=RAM required in Mb] [--no_swap|--only_swap] [--free_ram] -# | arg: -r, --required= - Amount of RAM required in Mb. The helper will return 0 is there's enough RAM, or 1 otherwise. -# If --required isn't set, the helper will print the amount of RAM, in Mb. -# | arg: -s, --no_swap - Ignore swap -# | arg: -o, --only_swap - Ignore real RAM, consider only swap. -# | arg: -f, --free_ram - Count only free RAM, not the total amount of RAM available. -ynh_check_ram () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [r]=required= [s]=no_swap [o]=only_swap [f]=free_ram ) - local required - local no_swap - local only_swap - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - required=${required:-} - no_swap=${no_swap:-0} - only_swap=${only_swap:-0} - - local total_ram=$(vmstat --stats --unit M | grep "total memory" | awk '{print $1}') - local total_swap=$(vmstat --stats --unit M | grep "total swap" | awk '{print $1}') - local total_ram_swap=$(( total_ram + total_swap )) - - local free_ram=$(vmstat --stats --unit M | grep "free memory" | awk '{print $1}') - local free_swap=$(vmstat --stats --unit M | grep "free swap" | awk '{print $1}') - local free_ram_swap=$(( free_ram + free_swap )) - - # Use the total amount of ram - local ram=$total_ram_swap - if [ $free_ram -eq 1 ] - then - # Use the total amount of free ram - ram=$free_ram_swap - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$free_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$free_swap - fi - else - if [ $no_swap -eq 1 ] - then - # Use only the amount of free ram - ram=$total_ram - elif [ $only_swap -eq 1 ] - then - # Use only the amount of free swap - ram=$total_swap - fi - fi - - if [ -n "$required" ] - then - # Return 1 if the amount of ram isn't enough. - if [ $ram -lt $required ] - then - return 1 - else - return 0 - fi - - # If no RAM is required, return the amount of available ram. - else - echo $ram - fi -} From 9c47591da2ba69b548382ac324702217733b1ec9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:18:15 +0200 Subject: [PATCH 028/101] Adding commit name --- check_process | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/check_process b/check_process index 12c74c8..6050dcd 100644 --- a/check_process +++ b/check_process @@ -29,3 +29,8 @@ ;;; Options Email=yalh@yahoo.com Notification=all +;;; Upgrade options + ; commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 + name=3.1.2~ynh2 + ; commit=6b30109fc986d83166b1805ec3ad7e28200e3743 + name=3.1.2~ynh3 From f2051e67a3a7ee03254677434a35209beff2225b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:19:50 +0200 Subject: [PATCH 029/101] $MEMORY_NEEDED factorisation --- scripts/_common.sh | 2 ++ scripts/install | 4 ++-- scripts/restore | 4 ++-- scripts/upgrade | 4 ++-- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index e0686b2..dc466ba 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -13,6 +13,8 @@ BUNDLER_VERSION="1.17.3" NODEJS_VERSION="12" +MEMORY_NEEDED="2560" + #================================================= # PERSONAL HELPERS #================================================= diff --git a/scripts/install b/scripts/install index 97dee20..8c63cde 100644 --- a/scripts/install +++ b/scripts/install @@ -136,9 +136,9 @@ ynh_script_progression --message="Adding swap is needed..." --weight=4 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 2.5Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 diff --git a/scripts/restore b/scripts/restore index ed0b27d..ae64eaf 100644 --- a/scripts/restore +++ b/scripts/restore @@ -89,9 +89,9 @@ ynh_script_progression --message="Adding swap if needed..." --weight=4 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 8Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 diff --git a/scripts/upgrade b/scripts/upgrade index 9e02c01..fd58f16 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -233,9 +233,9 @@ ynh_script_progression --message="Adding swap if needed..." --weight=7 total_memory=$(ynh_get_ram --total) swap_needed=0 -if [ $total_memory -lt 2560 ]; then +if [ $total_memory -lt $MEMORY_NEEDED ]; then # Need a minimum of 8Go of memory - swap_needed=$((2560 - $total_memory)) + swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 From d3ea53c200fd20a61acb4bb1a5dce5aa6ab77752 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:22:20 +0200 Subject: [PATCH 030/101] removing not needed cron job description --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index 8c63cde..c78419e 100644 --- a/scripts/install +++ b/scripts/install @@ -219,9 +219,9 @@ ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_k ynh_secure_remove --file="$final_path/live/key.txt" #================================================= -# SETUP CRON JOB FOR REMOVING CACHE +# SETUP CRON JOB #================================================= -ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 +ynh_script_progression --message="Setuping a cron job..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index ae64eaf..f41b2a8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring a cron job for removing cache..." --weight=2 +ynh_script_progression --message="Restoring a cron job..." --weight=2 ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index fd58f16..eff42b3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -302,7 +302,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SETUP CRON JOB FOR REMOVING CACHE #================================================= -ynh_script_progression --message="Setuping a cron job for removing cache..." --weight=1 +ynh_script_progression --message="Setuping a cron job..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app From 0c4121ac5234e4351a431f9e6091c426a60aa533 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:40:04 +0200 Subject: [PATCH 031/101] Add service description --- scripts/install | 6 +++--- scripts/restore | 6 +++--- scripts/upgrade | 9 +++++++++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/scripts/install b/scripts/install index c78419e..5443717 100644 --- a/scripts/install +++ b/scripts/install @@ -264,9 +264,9 @@ chown -R "$app": "$final_path" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 -yunohost service add "$app-web" -yunohost service add "$app-sidekiq" -yunohost service add "$app-streaming" +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index f41b2a8..175543a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -142,9 +142,9 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 -yunohost service add $app-web -yunohost service add $app-sidekiq -yunohost service add $app-streaming +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index eff42b3..f14c08b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -322,6 +322,15 @@ ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" +#================================================= +# INTEGRATE SERVICE IN YUNOHOST +#================================================= +ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 + +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" + #================================================= # GENERIC FINALIZATION #================================================= From 117393a2f5beacc301df6271b0f62b3a0bd2c090 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:40:25 +0200 Subject: [PATCH 032/101] Apply last example_ynh on backup script --- scripts/backup | 55 +++++++++++++++++--------------------------------- 1 file changed, 18 insertions(+), 37 deletions(-) diff --git a/scripts/backup b/scripts/backup index 61ad5f4..9159b31 100644 --- a/scripts/backup +++ b/scripts/backup @@ -33,30 +33,38 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) #================================================= -# STANDARD BACKUP STEPS +# DECLARE DATA AND CONF FILES TO BACKUP #================================================= -# STOP SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=27 - -ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" -ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" -ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped" +ynh_print_info --message="Declaring files to be backed up..." #================================================= # BACKUP THE APP MAIN DIR #================================================= -ynh_script_progression --message="Backing up the main app directory..." --weight=2 ynh_backup --src_path="$final_path" #================================================= # BACKUP THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Backing up nginx web server configuration..." --weight=2 ynh_backup --src_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# SPECIFIC BACKUP +#================================================= +# BACKUP SYSTEMD +#================================================= + +ynh_backup --src_path="/etc/systemd/system/$app-web.service" +ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service" +ynh_backup --src_path="/etc/systemd/system/$app-streaming.service" + +#================================================= +# BACKUP A CRON FILE +#================================================= + +ynh_backup --src_path="/etc/cron.d/$app" + #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= @@ -64,33 +72,6 @@ ynh_script_progression --message="Backing up the PostgreSQL database..." --weigh ynh_psql_dump_db --database="$db_name" > db.sql -#================================================= -# SPECIFIC BACKUP -#================================================= -# BACKUP SYSTEMD -#================================================= -ynh_script_progression --message="Backing up systemd configuration..." --weight=2 - -ynh_backup --src_path="/etc/systemd/system/$app-web.service" -ynh_backup --src_path="/etc/systemd/system/$app-sidekiq.service" -ynh_backup --src_path="/etc/systemd/system/$app-streaming.service" - -#================================================= -# BACKUP A CRON FILE -#================================================= -ynh_script_progression --message="Backing up a cron file..." --weight=1 - -ynh_backup --src_path="/etc/cron.d/$app" - -#================================================= -# START SYSTEMD SERVICE -#================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=1 - -ynh_systemd_action --action=start --service_name=${app}-web --line_match="Listening on tcp" --log_path=systemd -ynh_systemd_action --action=start --service_name=${app}-sidekiq --line_match="Starting processing" --log_path=systemd -ynh_systemd_action --action=start --service_name=${app}-streaming --line_match="Worker 1 now listening" --log_path=systemd - #================================================= # END OF SCRIPT #================================================= From 5108846acb8628d01aec2f8444e2256be2f13fae Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:44:21 +0200 Subject: [PATCH 033/101] cron job to cron file --- scripts/install | 4 ++-- scripts/restore | 2 +- scripts/upgrade | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 5443717..77c3cca 100644 --- a/scripts/install +++ b/scripts/install @@ -219,9 +219,9 @@ ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_k ynh_secure_remove --file="$final_path/live/key.txt" #================================================= -# SETUP CRON JOB +# SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping a cron job..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app diff --git a/scripts/restore b/scripts/restore index 175543a..694b649 100644 --- a/scripts/restore +++ b/scripts/restore @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring a cron job..." --weight=2 +ynh_script_progression --message="Restoring the cron file..." --weight=2 ynh_restore_file --origin_path="/etc/cron.d/$app" diff --git a/scripts/upgrade b/scripts/upgrade index f14c08b..d578415 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -300,9 +300,9 @@ popd ynh_store_file_checksum --file="$config" #================================================= -# SETUP CRON JOB FOR REMOVING CACHE +# SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping a cron job..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." --weight=1 ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app From d9cac4a31a4007b4b0223480deb74806f7a3458d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:50:52 +0200 Subject: [PATCH 034/101] spacing --- scripts/upgrade | 68 ++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 34 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index d578415..bf81be9 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -65,8 +65,8 @@ fi # Check if admin is not null if [[ "$admin" = "" || "$language" = "" ]]; then - echo "Unable to upgrade, please contact support" - ynh_die + echo "Unable to upgrade, please contact support" + ynh_die fi # If port_web doesn't exist, create it, need for old install @@ -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=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) 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=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) 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=$(head -n128 /dev/urandom | tail -n +1 | tr -dc -d 'a-z0-9' | head -c128) fi ynh_app_setting_set --app=$app --key=otp_secret --value="$otp_secret" fi @@ -172,30 +172,30 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=14 + ynh_script_progression --message="Upgrading source files..." --weight=14 - # Download Mastodon - tmpdir="$(mktemp -d)" + # Download Mastodon + tmpdir="$(mktemp -d)" - mkdir $tmpdir/system - if [ -d "$final_path/live/public/system" ]; then - rsync -a "$final_path/live/public/system" "$tmpdir/." - fi - rsync -a "$config" "$tmpdir/." - ynh_secure_remove --file="$final_path/live" - ynh_setup_source --dest_dir="$final_path/live" + mkdir $tmpdir/system + if [ -d "$final_path/live/public/system" ]; then + rsync -a "$final_path/live/public/system" "$tmpdir/." + fi + rsync -a "$config" "$tmpdir/." + ynh_secure_remove --file="$final_path/live" + ynh_setup_source --dest_dir="$final_path/live" - # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 - ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" - - if [ -d "$tmpdir/system" ]; then - rsync -a "$tmpdir/system" "$final_path/live/public/." - fi - rsync -a "$tmpdir/.env.production" "$final_path/live/." - ynh_secure_remove --file="$tmpdir" + # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 + ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" - # Clean files which are not needed anymore - ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" + if [ -d "$tmpdir/system" ]; then + rsync -a "$tmpdir/system" "$final_path/live/public/." + fi + rsync -a "$tmpdir/.env.production" "$final_path/live/." + ynh_secure_remove --file="$tmpdir" + + # Clean files which are not needed anymore + ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" fi #================================================= @@ -285,15 +285,15 @@ ynh_script_progression --message="Upgrading Mastodon..." --weight=2640 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 + 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 popd # Recalculate and store the checksum of the file for the next upgrade. From 27628985664a552291b74d11df8f104c5977eb6c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 13:51:42 +0200 Subject: [PATCH 035/101] typo --- scripts/upgrade | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index bf81be9..e4295fe 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -212,7 +212,7 @@ ynh_script_progression --message="Upgrading dependencies..." --weight=24 ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= From 1f9dc463f214a8692e99ca1f3273461dda55e8fd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 26 May 2020 14:39:04 +0200 Subject: [PATCH 036/101] switching from add_header to more_set_headers --- conf/nginx.conf | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index d348613..866fcc7 100644 --- a/conf/nginx.conf +++ b/conf/nginx.conf @@ -19,14 +19,14 @@ location / { } location ~ ^/(emoji|packs|system/accounts/avatars|system/media_attachments/files) { - add_header Cache-Control "public, max-age=31536000, immutable"; - add_header Strict-Transport-Security "max-age=31536000"; + more_set_headers "Cache-Control: public, max-age=31536000, immutable"; + more_set_headers "Strict-Transport-Security: max-age=31536000"; try_files $uri @proxy; } location /sw.js { - add_header Cache-Control "public, max-age=0"; - add_header Strict-Transport-Security "max-age=31536000"; + more_set_headers "Cache-Control: public, max-age=0"; + more_set_headers "Strict-Transport-Security: max-age=31536000"; try_files $uri @proxy; } @@ -49,8 +49,8 @@ location @proxy { proxy_cache_valid 200 7d; proxy_cache_valid 410 24h; proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504; - add_header X-Cached $upstream_cache_status; - add_header Strict-Transport-Security "max-age=31536000"; + more_set_headers "X-Cached: $upstream_cache_status"; + more_set_headers "Strict-Transport-Security: max-age=31536000"; tcp_nodelay on; } From 81ff2eef08d08086c6ff647c3c5e6cfe15525a30 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 29 May 2020 22:31:25 +0200 Subject: [PATCH 037/101] Backup to node 10 --- scripts/_common.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index dc466ba..2cf8424 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -11,7 +11,7 @@ RUBY_VERSION="2.6.5" BUNDLER_VERSION="1.17.3" -NODEJS_VERSION="12" +NODEJS_VERSION="10" MEMORY_NEEDED="2560" From 960d1c7d65dea1730ddb50adf0953b70993c5141 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 30 May 2020 00:20:28 +0200 Subject: [PATCH 038/101] Bump to last ynh_install_ruby version --- scripts/ynh_install_ruby__2 | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index f064c08..df03e07 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -22,8 +22,8 @@ SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > " # Build an app.src for ruby-build mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20191004.tar.gz -SOURCE_SUM=6f053957acb0af6d621ebf2b9dacc9c265844b2dc6842a021eb10f0a70094fe8" > "../conf/ruby-build.src" + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20200520.tar.gz +SOURCE_SUM=52be6908a94fbd4a94f5064e8b19d4a3baa4b773269c3884165518d83bcc8922" > "../conf/ruby-build.src" # Download and extract ruby-build ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build @@ -79,7 +79,10 @@ ynh_install_ruby () { if ! type rbenv > /dev/null 2>&1 then ynh_install_rbenv - elif dpkg --compare-versions "$(/opt/rbenv/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2" + elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2" + then + ynh_install_rbenv + elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt "20200520" then ynh_install_rbenv fi @@ -91,7 +94,7 @@ ynh_install_ruby () { test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby # Install the requested version of ruby - CONFIGURE_OPTS="--disable-install-doc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version + CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version # Store the ID of this app and the version of ruby requested for it echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version" From 8fea96dcd81f40923ba2f599c3b7ab838429f2de Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 2 Jun 2020 18:34:04 +0200 Subject: [PATCH 039/101] apply last example_ynh for ynh_script_progression --- scripts/backup | 7 +++---- scripts/install | 46 ++++++++++++++++++++++------------------------ scripts/remove | 25 ++++++++++++------------- scripts/restore | 36 ++++++++++++++++++------------------ scripts/upgrade | 44 ++++++++++++++++++++++---------------------- 5 files changed, 77 insertions(+), 81 deletions(-) diff --git a/scripts/backup b/scripts/backup index 9159b31..c1d4f6f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -13,7 +13,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { ynh_clean_check_starting @@ -24,7 +23,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=2 +ynh_print_info --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -68,7 +67,7 @@ ynh_backup --src_path="/etc/cron.d/$app" #================================================= # BACKUP THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Backing up the PostgreSQL database..." --weight=4 +ynh_print_info --message="Backing up the PostgreSQL database..." ynh_psql_dump_db --database="$db_name" > db.sql @@ -76,4 +75,4 @@ ynh_psql_dump_db --database="$db_name" > db.sql # END OF SCRIPT #================================================= -ynh_script_progression --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." --last +ynh_print_info --message="Backup script completed for $app. (YunoHost will then actually copy those files to the archive)." diff --git a/scripts/install b/scripts/install index 77c3cca..ebc4173 100644 --- a/scripts/install +++ b/scripts/install @@ -14,7 +14,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=1 ynh_clean_setup () { ynh_clean_check_starting @@ -25,7 +24,6 @@ ynh_abort_if_errors #================================================= # RETRIEVE ARGUMENTS FROM THE MANIFEST #================================================= -ynh_script_progression --message="Retrieving arguments from the manifest..." --weight=1 domain=$YNH_APP_ARG_DOMAIN path_url="/" @@ -40,7 +38,7 @@ app=$YNH_APP_INSTANCE_NAME #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= -ynh_script_progression --message="Validating installation parameters..." --weight=2 +ynh_script_progression --message="Validating installation parameters..." final_path=/var/www/$app test ! -e "$final_path" || ynh_die --message="This path already contains a folder" @@ -51,7 +49,7 @@ ynh_webpath_register --app=$app --domain=$domain --path_url=$path_url #================================================= # STORE SETTINGS FROM MANIFEST #================================================= -ynh_script_progression --message="Storing installation settings..." --weight=2 +ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url @@ -64,7 +62,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." --weight=1 +ynh_script_progression --message="Configuring firewall..." # Find an available port port_web=$(ynh_find_port --port=3000) @@ -76,7 +74,7 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= # INSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Installing dependencies..." --weight=86 +ynh_script_progression --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies @@ -85,7 +83,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a PostgreSQL database..." --weight=5 +ynh_script_progression --message="Creating a MySQL database..." # Create postgresql database db_name="${app}_production" @@ -100,7 +98,7 @@ ynh_psql_execute_as_root --sql="ALTER USER $db_user CREATEDB;" #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= -ynh_script_progression --message="Setting up source files..." --weight=5 +ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src @@ -113,7 +111,7 @@ ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_strin #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." --weight=3 +ynh_script_progression --message="Configuring nginx web server..." # Create a dedicated nginx config ynh_add_nginx_config 'port_web port_stream' @@ -121,7 +119,7 @@ ynh_add_nginx_config 'port_web port_stream' #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Configuring system user..." --weight=4 +ynh_script_progression --message="Configuring system user..." # Create a system user ynh_system_user_create --username=$app --home_dir=$final_path @@ -131,7 +129,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap is needed..." --weight=4 +ynh_script_progression --message="Adding swap is needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -141,13 +139,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=424 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -158,7 +156,7 @@ popd #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=2 +ynh_script_progression --message="Modifying a config file..." config="$final_path/live/.env.production" cp -f ../conf/.env.production.sample "$config" @@ -189,7 +187,7 @@ ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="m #================================================= # INSTALLING MASTODON #================================================= -ynh_script_progression --message="Installing Mastodon..." --weight=2230 +ynh_script_progression --message="Installing Mastodon..." chown -R "$app": "$final_path" @@ -221,7 +219,7 @@ ynh_secure_remove --file="$final_path/live/key.txt" #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app @@ -229,7 +227,7 @@ cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Configuring a systemd service..." --weight=5 +ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" @@ -244,7 +242,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming #================================================= # STORE THE CONFIG FILE CHECKSUM #================================================= -ynh_script_progression --message="Storing the config file checksum..." --weight=1 +ynh_script_progression --message="Storing the config file checksum..." # Calculate and store the config file checksum into the app settings ynh_store_file_checksum --file="$config" @@ -254,7 +252,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=9 +ynh_script_progression --message="Securing files and directories..." # Set permissions to app files chown -R "$app": "$final_path" @@ -262,7 +260,7 @@ chown -R "$app": "$final_path" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -271,7 +269,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=47 +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" @@ -280,7 +278,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." --weight=2 +ynh_script_progression --message="Configuring SSOwat..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -292,7 +290,7 @@ fi #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -300,4 +298,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Installation of $app completed" --last +ynh_script_progression --message="Installation of $app completed" diff --git a/scripts/remove b/scripts/remove index d955a8a..9fac8f2 100644 --- a/scripts/remove +++ b/scripts/remove @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=6 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -28,31 +28,30 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -ynh_script_progression --message="Removing service integration in YunoHost..." --weight=2 # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null then - ynh_script_progression --message="Removing $app-web service..." --weight=2 + ynh_script_progression --message="Removing $app-web service..." yunohost service remove "$app-web" fi if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null then - ynh_script_progression --message="Removing $app-sidekiq service..." --weight=2 + ynh_script_progression --message="Removing $app-sidekiq service..." yunohost service remove "$app-sidekiq" fi if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null then - ynh_script_progression --message="Removing $app-streaming service..." --weight=2 + ynh_script_progression --message="Removing $app-streaming service..." yunohost service remove "$app-streaming" fi #================================================= # STOP AND REMOVE SERVICE #================================================= -ynh_script_progression --message="Stopping and removing the systemd service..." --weight=27 +ynh_script_progression --message="Stopping and removing the systemd service..." # Remove the dedicated systemd config ynh_remove_systemd_config --service="$app-web" @@ -62,7 +61,7 @@ ynh_remove_systemd_config --service="$app-streaming" #================================================= # REMOVE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Removing the PostgreSQL database..." --weight=4 +ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" @@ -70,7 +69,7 @@ ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" #================================================= # REMOVE DEPENDENCIES #================================================= -ynh_script_progression --message="Removing dependencies..." --weight=28 +ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_ruby @@ -81,7 +80,7 @@ ynh_remove_extra_repo #================================================= # REMOVE APP MAIN DIR #================================================= -ynh_script_progression --message="Removing app main directory..." --weight=16 +ynh_script_progression --message="Removing app main directory..." # Remove the app directory securely ynh_secure_remove --file="$final_path" @@ -89,7 +88,7 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." --weight=2 +ynh_script_progression --message="Removing nginx web server configuration..." # Remove the dedicated nginx config ynh_remove_nginx_config @@ -99,7 +98,7 @@ ynh_remove_nginx_config #================================================= # REMOVE THE CRON FILE #================================================= -ynh_script_progression --message="Removing the cron file..." --weight=2 +ynh_script_progression --message="Removing the cron file..." # Remove a cron file ynh_secure_remove --file="/etc/cron.d/$app" @@ -112,7 +111,7 @@ ynh_del_swap #================================================= # REMOVE DEDICATED USER #================================================= -ynh_script_progression --message="Removing the dedicated system user..." --weight=2 +ynh_script_progression --message="Removing the dedicated system user..." # Delete a system user ynh_system_user_delete --username=$app @@ -121,4 +120,4 @@ ynh_system_user_delete --username=$app # END OF SCRIPT #================================================= -ynh_script_progression --message="Removal of $app completed" --last +ynh_script_progression --message="Removal of $app completed" diff --git a/scripts/restore b/scripts/restore index 694b649..513d924 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,7 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." --weight=2 +ynh_script_progression --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -26,7 +26,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." --weight=2 +ynh_script_progression --message="Loading settings..." app=$YNH_APP_INSTANCE_NAME @@ -40,7 +40,7 @@ db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= # CHECK IF THE APP CAN BE RESTORED #================================================= -ynh_script_progression --message="Validating restoration parameters..." --weight=2 +ynh_script_progression --message="Validating restoration parameters..." ynh_webpath_available --domain=$domain --path_url=$path_url \ || ynh_die --message="Path not available: ${domain}${path_url}" @@ -52,21 +52,21 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring nginx configuration..." --weight=1 +ynh_script_progression --message="Restoring the nginx configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" #================================================= # RESTORE THE APP MAIN DIR #================================================= -ynh_script_progression --message="Restoring the app main directory..." --weight=105 +ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" #================================================= # RECREATE THE DEDICATED USER #================================================= -ynh_script_progression --message="Recreating the dedicated system user..." --weight=5 +ynh_script_progression --message="Recreating the dedicated system user..." # Create the dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -74,7 +74,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # RESTORE USER RIGHTS #================================================= -ynh_script_progression --message="Restoring users rights..." --weight=4 +ynh_script_progression --message="Restoring user rights..." # Restore permissions on app files chown -R $app: $final_path @@ -84,7 +84,7 @@ chown -R $app: $final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." --weight=4 +ynh_script_progression --message="Adding swap if needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -94,13 +94,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # REINSTALL DEPENDENCIES #================================================= -ynh_script_progression --message="Reinstalling dependencies..." --weight=63 +ynh_script_progression --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies @@ -109,7 +109,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=393 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -120,7 +120,7 @@ popd #================================================= # RESTORE THE POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Restoring the PostgreSQL database..." --weight=18 +ynh_script_progression --message="Restoring the PostgreSQL database..." ynh_psql_test_if_first_run ynh_psql_setup_db --db_user=$db_user --db_name=$db_name --db_pwd=$db_pwd @@ -130,7 +130,7 @@ ynh_psql_execute_file_as_root --file="./db.sql" --database="$db_name" #================================================= # RESTORE SYSTEMD #================================================= -ynh_script_progression --message="Restoring the systemd configuration..." --weight=3 +ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" @@ -140,7 +140,7 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -149,7 +149,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=41 +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" @@ -158,7 +158,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RESTORE THE CRON FILE #================================================= -ynh_script_progression --message="Restoring the cron file..." --weight=2 +ynh_script_progression --message="Restoring the cron file..." ynh_restore_file --origin_path="/etc/cron.d/$app" @@ -167,7 +167,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -175,4 +175,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Restoration completed for $app" --last +ynh_script_progression --message="Restoration completed for $app" diff --git a/scripts/upgrade b/scripts/upgrade index e4295fe..8441307 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -14,7 +14,7 @@ source /usr/share/yunohost/helpers #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading installation settings..." --weight=4 +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -40,14 +40,14 @@ vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key) #================================================= # CHECK VERSION #================================================= -ynh_script_progression --message="Checking version..." --weight=1 +ynh_script_progression --message="Checking version..." upgrade_type=$(ynh_check_app_version_changed) #================================================= # ENSURE DOWNWARD COMPATIBILITY #================================================= -ynh_script_progression --message="Ensuring downward compatibility..." --weight=1 +ynh_script_progression --message="Ensuring downward compatibility..." config="$final_path/live/.env.production" @@ -131,7 +131,7 @@ ynh_remove_extra_repo #================================================= # BACKUP BEFORE UPGRADE THEN ACTIVE TRAP #================================================= -ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." --weight=442 +ynh_script_progression --message="Backing up the app before upgrading (may take a while)..." # Backup the current version of the app ynh_backup_before_upgrade @@ -160,7 +160,7 @@ path_url=$(ynh_normalize_url_path --path_url=$path_url) #================================================= # STOP SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Stopping a systemd service..." --weight=22 +ynh_script_progression --message="Stopping a systemd service..." ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" @@ -172,7 +172,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=sy if [ "$upgrade_type" == "UPGRADE_APP" ] then - ynh_script_progression --message="Upgrading source files..." --weight=14 + ynh_script_progression --message="Upgrading source files..." # Download Mastodon tmpdir="$(mktemp -d)" @@ -201,14 +201,14 @@ fi #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." --weight=3 +ynh_script_progression --message="Upgrading nginx web server configuration..." ynh_add_nginx_config 'port_web port_stream' #================================================= # UPGRADE DEPENDENCIES #================================================= -ynh_script_progression --message="Upgrading dependencies..." --weight=24 +ynh_script_progression --message="Upgrading dependencies..." ynh_remove_nodejs ynh_install_nodejs --nodejs_version=$NODEJS_VERSION @@ -218,7 +218,7 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE DEDICATED USER #================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." --weight=7 +ynh_script_progression --message="Making sure dedicated system user exists..." # Create a dedicated user (if not existing) ynh_system_user_create --username=$app --home_dir=$final_path @@ -228,7 +228,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap if needed..." --weight=7 +ynh_script_progression --message="Adding swap if needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 @@ -238,13 +238,13 @@ if [ $total_memory -lt $MEMORY_NEEDED ]; then swap_needed=$(($MEMORY_NEEDED - $total_memory)) fi -ynh_script_progression --message="Adding $swap_needed Mo to swap..." --weight=1 +ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed #================================================= # INSTALLING RUBY AND BUNDLER #================================================= -ynh_script_progression --message="Installing Ruby..." --weight=424 +ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" @@ -255,7 +255,7 @@ popd #================================================= # MODIFY A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." --weight=1 +ynh_script_progression --message="Modifying a config file..." ynh_backup_if_checksum_is_different --file="$config" cp -f ../conf/.env.production.sample "$config" @@ -280,7 +280,7 @@ ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapi #================================================= # UPGRADE MASTODON #================================================= -ynh_script_progression --message="Upgrading Mastodon..." --weight=2640 +ynh_script_progression --message="Upgrading Mastodon..." chown -R "$app": "$final_path" @@ -302,7 +302,7 @@ ynh_store_file_checksum --file="$config" #================================================= # SETUP THE CRON FILE #================================================= -ynh_script_progression --message="Setuping the cron file..." --weight=1 +ynh_script_progression --message="Setuping the cron file..." ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" cp -f ../conf/cron /etc/cron.d/$app @@ -310,7 +310,7 @@ cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD #================================================= -ynh_script_progression --message="Upgrading systemd configuration..." --weight=13 +ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" @@ -325,7 +325,7 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Integrating service in YunoHost..." --weight=3 +ynh_script_progression --message="Integrating service in YunoHost..." yunohost service add "$app-web" --description "$app web service" --log_type "systemd" yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" @@ -336,7 +336,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" --l #================================================= # SECURE FILES AND DIRECTORIES #================================================= -ynh_script_progression --message="Securing files and directories..." --weight=9 +ynh_script_progression --message="Securing files and directories..." # Set permissions on app files chown -R $app: $final_path @@ -344,7 +344,7 @@ chown -R $app: $final_path #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." --weight=1 +ynh_script_progression --message="Upgrading SSOwat configuration..." # Make app public if necessary if [ $is_public -eq 1 ] @@ -356,7 +356,7 @@ fi #================================================= # START SYSTEMD SERVICE #================================================= -ynh_script_progression --message="Starting a systemd service..." --weight=48 +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" @@ -365,7 +365,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." --weight=2 +ynh_script_progression --message="Reloading nginx web server..." ynh_systemd_action --service_name=nginx --action=reload @@ -373,4 +373,4 @@ ynh_systemd_action --service_name=nginx --action=reload # END OF SCRIPT #================================================= -ynh_script_progression --message="Upgrade of $app completed" --last +ynh_script_progression --message="Upgrade of $app completed" From d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 4 Jun 2020 00:36:02 +0200 Subject: [PATCH 040/101] Implement new nodejs helper --- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-streaming.service | 4 ++-- conf/mastodon-web.service | 2 +- manifest.json | 2 +- scripts/install | 11 +++-------- scripts/upgrade | 11 +++-------- 6 files changed, 11 insertions(+), 21 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index 73f29e5..a4fc0da 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -9,7 +9,7 @@ Environment="RAILS_ENV=production" Environment="DB_POOL=25" Environment="MALLOC_ARENA_MAX=2" - ExecStart=__RBENVROOT__/shims/bundle exec sidekiq -c 25 + ExecStart=__RBENV_ROOT__/shims/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-streaming.service b/conf/mastodon-streaming.service index 2e130d5..94309c1 100644 --- a/conf/mastodon-streaming.service +++ b/conf/mastodon-streaming.service @@ -9,8 +9,8 @@ Environment="NODE_ENV=production" Environment="PORT=__PORT_STREAM__" Environment="STREAMING_CLUSTER_NUM=1" - Environment=PATH=__NODEJS_PATH__ - ExecStart=__NODEJS_PATH__/node ./streaming + Environment=__YNH_LOAD_NODE_PATH__ + ExecStart=__YNH_NODE__ ./streaming TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 14d1260..bb07cf4 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" - ExecStart=__RBENVROOT__/shims/bundle exec puma -C config/puma.rb + ExecStart=__RBENV_ROOT__/shims/bundle exec puma -C config/puma.rb ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 Restart=always diff --git a/manifest.json b/manifest.json index 9041ab7..a6dbf25 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.8.1" + "yunohost": ">= 3.8.2" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index ebc4173..53b598b 100644 --- a/scripts/install +++ b/scripts/install @@ -230,14 +230,9 @@ cp -f ../conf/cron /etc/cron.d/$app ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config -ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service" -ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" -ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" #================================================= # STORE THE CONFIG FILE CHECKSUM diff --git a/scripts/upgrade b/scripts/upgrade index 8441307..6445cc8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -313,14 +313,9 @@ cp -f ../conf/cron /etc/cron.d/$app ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/mastodon-web.service" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-web.service" -ynh_replace_string --match_string="__RBENVROOT__" --replace_string="$RBENV_ROOT" --target_file="../conf/mastodon-sidekiq.service" -ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/mastodon-streaming.service" -ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/mastodon-streaming.service" -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" #================================================= # INTEGRATE SERVICE IN YUNOHOST From e99891174efebaf8642d695f307f13f1f0f3f358 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 10 Jun 2020 09:31:25 +0200 Subject: [PATCH 041/101] Update README_fr.md --- README_fr.md | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/README_fr.md b/README_fr.md index 684d762..b0bde0b 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,24 +1,24 @@ # Mastodon pour YunoHost -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) +[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) [![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Mastodon rapidement et simplement sur un serveur Yunohost. +> *Ce package vous permet d'installer Mastodon rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* ## Vue d'ensemble -Mastodon est un réseau social gratuit et open source. Une alternative décentralisée aux plates-formes commerciales, elle évite les risques d'une seule société qui monopolise votre communication. +Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. **Version incluse:** 3.1.2 ## Points importants à lire avant l'installation -1. **Mastodon** nécessite un **nom de domaine** dédié, par exemple: mastodon.domain.tld +1. **Mastodon** nécessite un **nom de domaine** dédié, par exemple : mastodon.domain.tld 1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon avec des droits d'administration. -1. A la fin de l'installation, un mail est envoyé à cet utilisateur avec le mot de passe qui a été généré automatiquement. -1. Il semble important de fermer les inscriptions pour votre Mastodon, pour que ça reste une instance privé. Nous vous invitons à bloquer les instances distantes malfaisantes depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. +1. À la fin de l'installation, un mail est envoyé à cet utilisateur avec un mot de passe généré automatiquement. +1. Pour que votre instance Mastodon reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances distantes indésirables depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. ## Captures d'écran @@ -28,28 +28,28 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra ### Installation -#### Utilisation de __screen__ en cas de déconnection +#### Utilisation de *screen* en cas de déconnection ``` $ sudo apt-get install screen $ screen $ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git ``` -Récuperer l'installation après une deconnection: +Récupérer l'installation après une deconnection : ``` $ screen -d $ screen -r ``` -L'utilisateur admin est crée automatiquement comme: user@domain.tld +L'utilisateur admin est créé automatiquement comme : user@domain.tld -### Mise àjour +### Mise à jour -#### Utilisation de __screen__ fortement recommandé +#### Utilisation de *screen* fortement recommandée `$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug ` ## Documentation - * Documentation officielle: https://docs.joinmastodon.org/ + * Documentation officielle : https://docs.joinmastodon.org/ ## Caractéristiques spécifiques YunoHost @@ -59,15 +59,15 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a #### Architectures supportées -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) ## Links - * Signaler un bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues - * Site de l'application: https://joinmastodon.org/ - * Dépôt de l'application principale: https://github.com/tootsuite/mastodon - * Site web YunoHost: https://yunohost.org/ + * Signaler un bug : https://github.com/YunoHost-Apps/mastodon_ynh/issues + * Site de l'application : https://joinmastodon.org/ + * Dépôt de l'application principale : https://github.com/tootsuite/mastodon + * Site web YunoHost : https://yunohost.org/ --- From d1a881a27bf47c26ea34df8921734effc2466dd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Wed, 10 Jun 2020 09:44:17 +0200 Subject: [PATCH 042/101] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 5ae936a..d1e4ef7 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Mastodon for YunoHost -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) +[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) [![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) *[Lire ce readme en français.](./README_fr.md)* @@ -9,7 +9,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* ## Overview -Mastodon is a free, open-source social network. A decentralized alternative to commercial platforms, it avoids the risks of a single company monopolizing your communication. +Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. **Shipped version:** 3.1.2 @@ -28,7 +28,7 @@ Mastodon is a free, open-source social network. A decentralized alternative to c ### Install -#### Using __screen__ in case of disconnect +#### Using *screen* in case of disconnect ``` $ sudo apt-get install screen $ screen @@ -42,7 +42,7 @@ $ screen -r ### Update -#### Using __screen__ highly recommended +#### Using *screen* highly recommended `$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug ` @@ -58,7 +58,7 @@ LDAP authentication is activated. All YunoHost users can authenticate. #### Supported architectures -* x86-64b - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) ## Links From 953ed889ce161cacde7eb2c4abc5ff1bc9ee418f Mon Sep 17 00:00:00 2001 From: HugoPoi Date: Fri, 26 Jun 2020 22:20:54 +0200 Subject: [PATCH 043/101] perf(upgrade): use mv in place of rsync for system directory --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index 6445cc8..6ed16ef 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -179,7 +179,7 @@ then mkdir $tmpdir/system if [ -d "$final_path/live/public/system" ]; then - rsync -a "$final_path/live/public/system" "$tmpdir/." + mv --verbose --no-target-directory --backup=numbered "$final_path/live/public/system" "$final_path/system.tmp" fi rsync -a "$config" "$tmpdir/." ynh_secure_remove --file="$final_path/live" @@ -188,8 +188,8 @@ then # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" - if [ -d "$tmpdir/system" ]; then - rsync -a "$tmpdir/system" "$final_path/live/public/." + if [ -d "$final_path/system.tmp" ]; then + mv --verbose --no-target-directory "$final_path/system.tmp" "$final_path/live/public/system" fi rsync -a "$tmpdir/.env.production" "$final_path/live/." ynh_secure_remove --file="$tmpdir" From aa87c94ae0b5134a90fb17e90b9d7c3296abfe47 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 9 Aug 2020 00:06:17 +0200 Subject: [PATCH 044/101] Upgrade to 3.2.0 --- README.md | 2 +- README_fr.md | 2 +- check_process | 4 + conf/.env.production.sample | 249 +++++++----------------------------- conf/app.src | 4 +- conf/jessie.src | 6 + manifest.json | 2 +- scripts/_common.sh | 4 +- scripts/install | 13 +- scripts/upgrade | 12 +- 10 files changed, 79 insertions(+), 219 deletions(-) create mode 100644 conf/jessie.src diff --git a/README.md b/README.md index d1e4ef7..590b11d 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 3.1.2 +**Shipped version:** 3.2.0 (3.1.2 on Jessie) ## Important points to read before installing diff --git a/README_fr.md b/README_fr.md index b0bde0b..9b2367e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse:** 3.1.2 +**Version incluse:** 3.2.0 (3.1.2 on Jessie) ## Points importants à lire avant l'installation diff --git a/check_process b/check_process index 6050dcd..0d29e43 100644 --- a/check_process +++ b/check_process @@ -17,6 +17,8 @@ upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 # 3.1.2~ynh3 upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 + # 3.1.2~ynh4 + upgrade=1 from_commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef 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. @@ -34,3 +36,5 @@ Notification=all name=3.1.2~ynh2 ; commit=6b30109fc986d83166b1805ec3ad7e28200e3743 name=3.1.2~ynh3 + ; commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef + name=3.1.2~ynh4 diff --git a/conf/.env.production.sample b/conf/.env.production.sample index d27bf87..b189b53 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -1,69 +1,50 @@ -# Service dependencies -# You may set REDIS_URL instead for more advanced options -# You may also set REDIS_NAMESPACE to share Redis between multiple Mastodon servers +# This is a sample configuration file. You can generate your configuration +# with the `rake mastodon:setup` interactive setup wizard, but to customize +# your setup even further, you'll need to edit it manually. This sample does +# not demonstrate all available configuration options. Please look at +# https://docs.joinmastodon.org/admin/config/ for the full documentation. + +# Federation +# ---------- +# This identifies your server and cannot be changed safely later +# ---------- +LOCAL_DOMAIN=__DOMAIN__ + +# Redis +# ----- REDIS_HOST=localhost REDIS_PORT=6379 -# You may set DATABASE_URL instead for more advanced options + +# PostgreSQL +# ---------- DB_HOST=localhost DB_USER=__DB_USER__ DB_NAME=__DB_NAME__ DB_PASS=__DB_PWD__ DB_PORT=5432 -# Optional ElasticSearch configuration -# You may also set ES_PREFIX to share the same cluster between multiple Mastodon servers (falls back to REDIS_NAMESPACE if not set) + +# ElasticSearch (optional) +# ------------------------ # ES_ENABLED=true # ES_HOST=es # ES_PORT=9200 -# Federation -# Note: Changing LOCAL_DOMAIN at a later time will cause unwanted side effects, including breaking all existing federation. -# LOCAL_DOMAIN should *NOT* contain the protocol part of the domain e.g https://example.com. -LOCAL_DOMAIN=__DOMAIN__ - -# Changing LOCAL_HTTPS in production is no longer supported. (Mastodon will always serve https:// links) - -# Use this only if you need to run mastodon on a different domain than the one used for federation. -# You can read more about this option on https://github.com/tootsuite/documentation/blob/master/Running-Mastodon/Serving_a_different_domain.md -# DO *NOT* USE THIS UNLESS YOU KNOW *EXACTLY* WHAT YOU ARE DOING. -# WEB_DOMAIN=mastodon.example.com - -# Use this if you want to have several aliases handler@example1.com -# handler@example2.com etc. for the same user. LOCAL_DOMAIN should not -# be added. Comma separated values -# ALTERNATE_DOMAINS=example1.com,example2.com - -# Application secrets -# Generate each with the `RAILS_ENV=production bundle exec rake secret` task (`docker-compose run --rm web rake secret` if you use docker compose) +# Secrets +# ------- +# Make sure to use `rake secret` to generate secrets +# ------- SECRET_KEY_BASE=__SECRET_KEY_BASE__ OTP_SECRET=__OTP_SECRET__ -# VAPID keys (used for push notifications -# You can generate the keys using the following command (first is the private key, second is the public one) -# You should only generate this once per instance. If you later decide to change it, all push subscription will -# be invalidated, requiring the users to access the website again to resubscribe. -# -# Generate with `RAILS_ENV=production bundle exec rake mastodon:webpush:generate_vapid_key` task (`docker-compose run --rm web rake mastodon:webpush:generate_vapid_key` if you use docker compose) -# -# For more information visit https://rossta.net/blog/using-the-web-push-api-with-vapid.html +# Web Push +# -------- +# Generate with `rake mastodon:webpush:generate_vapid_key` +# -------- VAPID_PRIVATE_KEY=__VAPID_PRIVATE_KEY__ VAPID_PUBLIC_KEY=__VAPID_PUBLIC_KEY__ -# Registrations -# Single user mode will disable registrations and redirect frontpage to the first profile -# SINGLE_USER_MODE=true -# Prevent registrations with following e-mail domains -# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc -# Only allow registrations with the following e-mail domains -# EMAIL_DOMAIN_WHITELIST=example1.com|example2.de|etc - -# Optionally change default language -DEFAULT_LOCALE=__LANGUAGE__ - -# E-mail configuration -# Note: Mailgun and SparkPost (https://sparkpo.st/smtp) each have good free tiers -# If you want to use an SMTP server without authentication (e.g local Postfix relay) -# then set SMTP_AUTH_METHOD and SMTP_OPENSSL_VERIFY_MODE to 'none' and -# *comment* SMTP_LOGIN and SMTP_PASSWORD (leaving them blank is not enough). +# Sending mail +# ------------ SMTP_SERVER=localhost SMTP_PORT=25 #SMTP_LOGIN= @@ -78,22 +59,20 @@ SMTP_OPENSSL_VERIFY_MODE=none #SMTP_ENABLE_STARTTLS_AUTO=true #SMTP_TLS=true -# Optional user upload path and URL (images, avatars). Default is :rails_root/public/system. If you set this variable, you are responsible for making your HTTP server (eg. nginx) serve these files. -# PAPERCLIP_ROOT_PATH=/var/lib/mastodon/public-system -# PAPERCLIP_ROOT_URL=/system +# Registrations +# ------------ +# Single user mode will disable registrations and redirect frontpage to the first profile +# SINGLE_USER_MODE=true +# Prevent registrations with following e-mail domains +# EMAIL_DOMAIN_BLACKLIST=example1.com|example2.de|etc +# Only allow registrations with the following e-mail domains +# EMAIL_DOMAIN_WHITELIST=example1.com|example2.de|etc -# Optional asset host for multi-server setups -# The asset host must allow cross origin request from WEB_DOMAIN or LOCAL_DOMAIN -# if WEB_DOMAIN is not set. For example, the server may have the -# following header field: -# Access-Control-Allow-Origin: https://example.com/ -# CDN_HOST=https://assets.example.com +# Optionally change default language +DEFAULT_LOCALE=__LANGUAGE__ -# S3 (optional) -# The attachment host must allow cross origin request from WEB_DOMAIN or -# LOCAL_DOMAIN if WEB_DOMAIN is not set. For example, the server may have the -# following header field: -# Access-Control-Allow-Origin: https://192.168.1.123:9000/ +# File storage (optional) +# ----------------------- # S3_ENABLED=true # S3_BUCKET= # AWS_ACCESS_KEY_ID= @@ -101,75 +80,10 @@ SMTP_OPENSSL_VERIFY_MODE=none # S3_REGION= # S3_PROTOCOL=http # S3_HOSTNAME=192.168.1.123:9000 - -# S3 (Minio Config (optional) Please check Minio instance for details) -# The attachment host must allow cross origin request - see the description -# above. -# S3_ENABLED=true -# S3_BUCKET= -# AWS_ACCESS_KEY_ID= -# AWS_SECRET_ACCESS_KEY= -# S3_REGION= -# S3_PROTOCOL=https -# S3_HOSTNAME= -# S3_ENDPOINT= -# S3_SIGNATURE_VERSION= - -# Google Cloud Storage (optional) -# Use S3 compatible API. Since GCS does not support Multipart Upload, -# increase the value of S3_MULTIPART_THRESHOLD to disable Multipart Upload. -# The attachment host must allow cross origin request - see the description -# above. -# S3_ENABLED=true -# AWS_ACCESS_KEY_ID= -# AWS_SECRET_ACCESS_KEY= -# S3_REGION= -# S3_PROTOCOL=https -# S3_HOSTNAME=storage.googleapis.com -# S3_ENDPOINT=https://storage.googleapis.com -# S3_MULTIPART_THRESHOLD=52428801 # 50.megabytes - -# Swift (optional) -# The attachment host must allow cross origin request - see the description -# above. -# SWIFT_ENABLED=true -# SWIFT_USERNAME= -# For Keystone V3, the value for SWIFT_TENANT should be the project name -# SWIFT_TENANT= -# SWIFT_PASSWORD= -# Some OpenStack V3 providers require PROJECT_ID (optional) -# SWIFT_PROJECT_ID= -# Keystone V2 and V3 URLs are supported. Use a V3 URL if possible to avoid -# issues with token rate-limiting during high load. -# SWIFT_AUTH_URL= -# SWIFT_CONTAINER= -# SWIFT_OBJECT_URL= -# SWIFT_REGION= -# Defaults to 'default' -# SWIFT_DOMAIN_NAME= -# Defaults to 60 seconds. Set to 0 to disable -# SWIFT_CACHE_TTL= - -# Optional alias for S3 (e.g. to serve files on a custom domain, possibly using Cloudfront or Cloudflare) # S3_ALIAS_HOST= -# Streaming API integration -# STREAMING_API_BASE_URL= - -# Advanced settings -# If you need to use pgBouncer, you need to disable prepared statements: -# PREPARED_STATEMENTS=false - -# Cluster number setting for streaming API server. -# If you comment out following line, cluster number will be `numOfCpuCores - 1`. -STREAMING_CLUSTER_NUM=1 - -# Docker mastodon user -# If you use Docker, you may want to assign UID/GID manually. -# UID=1000 -# GID=1000 - # LDAP authentication (optional) +# ----------------------- LDAP_ENABLED=true LDAP_HOST=localhost LDAP_PORT=389 @@ -184,80 +98,3 @@ LDAP_UID_CONVERSION_ENABLED=true LDAP_UID_CONVERSION_SEARCH=., - LDAP_UID_CONVERSION_REPLACE=_ LDAP_TLS_NO_VERIFY=true - -# PAM authentication (optional) -# PAM authentication uses for the email generation the "email" pam variable -# and optional as fallback PAM_DEFAULT_SUFFIX -# The pam environment variable "email" is provided by: -# https://github.com/devkral/pam_email_extractor -# PAM_ENABLED=true -# Fallback email domain for email address generation (LOCAL_DOMAIN by default) -# PAM_EMAIL_DOMAIN=example.com -# Name of the pam service (pam "auth" section is evaluated) -# PAM_DEFAULT_SERVICE=rpam -# Name of the pam service used for checking if an user can register (pam "account" section is evaluated) (nil (disabled) by default) -# PAM_CONTROLLED_SERVICE=rpam - -# Global OAuth settings (optional) : -# If you have only one strategy, you may want to enable this -# OAUTH_REDIRECT_AT_SIGN_IN=true - -# Optional CAS authentication (cf. omniauth-cas) : -# CAS_ENABLED=true -# CAS_URL=https://sso.myserver.com/ -# CAS_HOST=sso.myserver.com/ -# CAS_PORT=443 -# CAS_SSL=true -# CAS_VALIDATE_URL= -# CAS_CALLBACK_URL= -# CAS_LOGOUT_URL= -# CAS_LOGIN_URL= -# CAS_UID_FIELD='user' -# CAS_CA_PATH= -# CAS_DISABLE_SSL_VERIFICATION=false -# CAS_UID_KEY='user' -# CAS_NAME_KEY='name' -# CAS_EMAIL_KEY='email' -# CAS_NICKNAME_KEY='nickname' -# CAS_FIRST_NAME_KEY='firstname' -# CAS_LAST_NAME_KEY='lastname' -# CAS_LOCATION_KEY='location' -# CAS_IMAGE_KEY='image' -# CAS_PHONE_KEY='phone' - -# Optional SAML authentication (cf. omniauth-saml) -# SAML_ENABLED=true -# SAML_ACS_URL=http://localhost:3000/auth/auth/saml/callback -# SAML_ISSUER=https://example.com -# SAML_IDP_SSO_TARGET_URL=https://idp.testshib.org/idp/profile/SAML2/Redirect/SSO -# SAML_IDP_CERT= -# SAML_IDP_CERT_FINGERPRINT= -# SAML_NAME_IDENTIFIER_FORMAT= -# SAML_CERT= -# SAML_PRIVATE_KEY= -# SAML_SECURITY_WANT_ASSERTION_SIGNED=true -# SAML_SECURITY_WANT_ASSERTION_ENCRYPTED=true -# SAML_SECURITY_ASSUME_EMAIL_IS_VERIFIED=true -# SAML_ATTRIBUTES_STATEMENTS_UID="urn:oid:0.9.2342.19200300.100.1.1" -# SAML_ATTRIBUTES_STATEMENTS_EMAIL="urn:oid:1.3.6.1.4.1.5923.1.1.1.6" -# SAML_ATTRIBUTES_STATEMENTS_FULL_NAME="urn:oid:2.16.840.1.113730.3.1.241" -# SAML_ATTRIBUTES_STATEMENTS_FIRST_NAME="urn:oid:2.5.4.42" -# SAML_ATTRIBUTES_STATEMENTS_LAST_NAME="urn:oid:2.5.4.4" -# SAML_UID_ATTRIBUTE="urn:oid:0.9.2342.19200300.100.1.1" -# SAML_ATTRIBUTES_STATEMENTS_VERIFIED= -# SAML_ATTRIBUTES_STATEMENTS_VERIFIED_EMAIL= - -# Use HTTP proxy for outgoing request (optional) -# http_proxy=http://gateway.local:8118 -# Access control for hidden service. -# ALLOW_ACCESS_TO_HIDDEN_SERVICE=true - -# Authorized fetch mode (optional) -# Require remote servers to authentify when fetching toots, see -# https://docs.joinmastodon.org/admin/config/#authorized_fetch -# AUTHORIZED_FETCH=true - -# Whitelist mode (optional) -# Only allow federation with whitelisted domains, see -# https://docs.joinmastodon.org/admin/config/#whitelist_mode -# WHITELIST_MODE=true diff --git a/conf/app.src b/conf/app.src index fc275ee..920f9da 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.1.2.tar.gz -SOURCE_SUM=c12fd8c1b426861825d37d2eab1d6356be05b2b321eae0c1b87f80fcc11b0da7 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.0.tar.gz +SOURCE_SUM=7ab99ccc6d6ce2ac2d5aea82a2fc057dd357126cb572e4fb39531931dc078904 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/jessie.src b/conf/jessie.src new file mode 100644 index 0000000..fc275ee --- /dev/null +++ b/conf/jessie.src @@ -0,0 +1,6 @@ +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.1.2.tar.gz +SOURCE_SUM=c12fd8c1b426861825d37d2eab1d6356be05b2b321eae0c1b87f80fcc11b0da7 +SOURCE_SUM_PRG=sha256sum +SOURCE_FORMAT=tar.gz +SOURCE_IN_SUBDIR=true +SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index a6dbf25..d516472 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.1.2~ynh4", + "version": "3.2.0~ynh1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index 2cf8424..d03e8ff 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,11 +7,11 @@ # dependencies used by the app pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https" -RUBY_VERSION="2.6.5" +RUBY_VERSION="2.6.6" BUNDLER_VERSION="1.17.3" -NODEJS_VERSION="10" +NODEJS_VERSION="12" MEMORY_NEEDED="2560" diff --git a/scripts/install b/scripts/install index 53b598b..0c92114 100644 --- a/scripts/install +++ b/scripts/install @@ -103,10 +103,17 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src mkdir $final_path -ynh_setup_source --dest_dir="$final_path/live" -# Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 -ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" +if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_setup_source --dest_dir="$final_path/live" +else + ynh_script_progression --message="Setting up source files..." + + ynh_setup_source --dest_dir="$final_path/live" --source_id=jessie + + # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 + ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" +fi #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index 6ed16ef..f10087a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -183,10 +183,16 @@ then fi rsync -a "$config" "$tmpdir/." ynh_secure_remove --file="$final_path/live" - ynh_setup_source --dest_dir="$final_path/live" + if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_setup_source --dest_dir="$final_path/live" + else + ynh_script_progression --message="Setting up source files..." - # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 - ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" + ynh_setup_source --dest_dir="$final_path/live" --source_id=jessie + + # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 + ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" + fi if [ -d "$final_path/system.tmp" ]; then mv --verbose --no-target-directory "$final_path/system.tmp" "$final_path/live/public/system" From 39fb4fe405e7d419f818ae31d7e05a3cbd64d0ba Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 9 Aug 2020 10:39:43 +0200 Subject: [PATCH 045/101] fixing version for Jessier and stretch --- scripts/_common.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index d03e8ff..ad4ed8e 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -7,14 +7,18 @@ # dependencies used by the app pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git-core g++ libprotobuf-dev protobuf-compiler pkg-config gcc autoconf bison build-essential libssl-dev libyaml-dev libreadline6-dev zlib1g-dev libncurses5-dev libffi-dev libgdbm3|libgdbm6 libgdbm-dev redis-server redis-tools postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https" -RUBY_VERSION="2.6.6" - -BUNDLER_VERSION="1.17.3" - -NODEJS_VERSION="12" - MEMORY_NEEDED="2560" +if [ "$(lsb_release --codename --short)" = "buster" ]; then + RUBY_VERSION="2.6.6" + BUNDLER_VERSION="1.17.3" + NODEJS_VERSION="12" +else + RUBY_VERSION="2.6.5" + BUNDLER_VERSION="1.17.3" + NODEJS_VERSION="10" +fi + #================================================= # PERSONAL HELPERS #================================================= From 46225b6e68e0c5295020d98699a3b780a1d9037b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 20 Oct 2020 23:38:23 +0200 Subject: [PATCH 046/101] Upgrade 3.2.1 --- README.md | 2 +- README_fr.md | 2 +- check_process | 4 ++++ conf/app.src | 4 ++-- manifest.json | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 590b11d..3d6499a 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 3.2.0 (3.1.2 on Jessie) +**Shipped version:** 3.2.1 (3.1.2 on Jessie) ## Important points to read before installing diff --git a/README_fr.md b/README_fr.md index 9b2367e..3627959 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse:** 3.2.0 (3.1.2 on Jessie) +**Version incluse:** 3.2.1 (3.1.2 on Jessie) ## Points importants à lire avant l'installation diff --git a/check_process b/check_process index 0d29e43..9338fb7 100644 --- a/check_process +++ b/check_process @@ -19,6 +19,8 @@ upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 # 3.1.2~ynh4 upgrade=1 from_commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef + # 3.2.0~ynh1 + upgrade=1 from_commit=bde14cc4496445fdfed4616ac44fc9527c8369fd 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. @@ -38,3 +40,5 @@ Notification=all name=3.1.2~ynh3 ; commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef name=3.1.2~ynh4 + ; commit=bde14cc4496445fdfed4616ac44fc9527c8369fd + name=3.2.0~ynh1 diff --git a/conf/app.src b/conf/app.src index 920f9da..571866d 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.0.tar.gz -SOURCE_SUM=7ab99ccc6d6ce2ac2d5aea82a2fc057dd357126cb572e4fb39531931dc078904 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.1.tar.gz +SOURCE_SUM=429dbe1166948e2863dd97b7d5458d18887e7a75b7ff5005cfa50828f9c7b9e2 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index d516472..f590076 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.0~ynh1", + "version": "3.2.1~ynh1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ From 8a505d8c85cf812c48595b2a6ff47c9a90866fa5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 29 Oct 2020 23:23:19 +0100 Subject: [PATCH 047/101] Remove Jessie support --- README.md | 2 +- README_fr.md | 2 +- conf/jessie.src | 6 ------ manifest.json | 2 +- scripts/install | 13 +------------ scripts/upgrade | 12 ++---------- 6 files changed, 6 insertions(+), 31 deletions(-) delete mode 100644 conf/jessie.src diff --git a/README.md b/README.md index 3d6499a..400138c 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 3.2.1 (3.1.2 on Jessie) +**Shipped version:** 3.2.1 ## Important points to read before installing diff --git a/README_fr.md b/README_fr.md index 3627959..548c3e6 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse:** 3.2.1 (3.1.2 on Jessie) +**Version incluse:** 3.2.1 ## Points importants à lire avant l'installation diff --git a/conf/jessie.src b/conf/jessie.src deleted file mode 100644 index fc275ee..0000000 --- a/conf/jessie.src +++ /dev/null @@ -1,6 +0,0 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.1.2.tar.gz -SOURCE_SUM=c12fd8c1b426861825d37d2eab1d6356be05b2b321eae0c1b87f80fcc11b0da7 -SOURCE_SUM_PRG=sha256sum -SOURCE_FORMAT=tar.gz -SOURCE_IN_SUBDIR=true -SOURCE_FILENAME= diff --git a/manifest.json b/manifest.json index f590076..84dbe56 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 3.8.2" + "yunohost": ">= 4.0" }, "multi_instance": true, "services": [ diff --git a/scripts/install b/scripts/install index 0c92114..01a2efc 100644 --- a/scripts/install +++ b/scripts/install @@ -102,18 +102,7 @@ ynh_script_progression --message="Setting up source files..." ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src -mkdir $final_path - -if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_setup_source --dest_dir="$final_path/live" -else - ynh_script_progression --message="Setting up source files..." - - ynh_setup_source --dest_dir="$final_path/live" --source_id=jessie - - # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 - ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" -fi +ynh_setup_source --dest_dir="$final_path/live" #================================================= # NGINX CONFIGURATION diff --git a/scripts/upgrade b/scripts/upgrade index f10087a..2914550 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -183,16 +183,8 @@ then fi rsync -a "$config" "$tmpdir/." ynh_secure_remove --file="$final_path/live" - if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_setup_source --dest_dir="$final_path/live" - else - ynh_script_progression --message="Setting up source files..." - - ynh_setup_source --dest_dir="$final_path/live" --source_id=jessie - - # Temporary workaround for https://github.com/tootsuite/mastodon/issues/13292 - ynh_replace_string --match_string="sidekiq-unique-jobs (6.0.18)" --replace_string="sidekiq-unique-jobs (6.0.20)" --target_file="$final_path/live/Gemfile.lock" - fi + + ynh_setup_source --dest_dir="$final_path/live" if [ -d "$final_path/system.tmp" ]; then mv --verbose --no-target-directory "$final_path/system.tmp" "$final_path/live/public/system" From f9080ece1011bb919bdac84a51d9261de90dcea1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 4 Nov 2020 19:44:41 +0100 Subject: [PATCH 048/101] limit tests to be made --- check_process | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/check_process b/check_process index 9338fb7..7c95e64 100644 --- a/check_process +++ b/check_process @@ -14,9 +14,9 @@ setup_public=1 upgrade=1 # 3.1.2~ynh2 - upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 + #upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 # 3.1.2~ynh3 - upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 + #upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 # 3.1.2~ynh4 upgrade=1 from_commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef # 3.2.0~ynh1 From b93733d7266f54d97eda4ccab3f28b4d799c095b Mon Sep 17 00:00:00 2001 From: Kay0u Date: Fri, 11 Dec 2020 10:48:57 +0100 Subject: [PATCH 049/101] 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 050/101] 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 051/101] 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 052/101] 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 053/101] 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": [ From 78d6d26eeb29a00fd1d1d87b59de59f1e3ad376b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 22 Dec 2020 19:59:13 +0100 Subject: [PATCH 054/101] Upgrade to 3.2.2 --- README.md | 2 +- README_fr.md | 2 +- check_process | 4 ++++ conf/app.src | 4 ++-- manifest.json | 2 +- 5 files changed, 9 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 400138c..19b1ee1 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 3.2.1 +**Shipped version:** 3.2.2 ## Important points to read before installing diff --git a/README_fr.md b/README_fr.md index 548c3e6..6c6ee1e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse:** 3.2.1 +**Version incluse:** 3.2.2 ## Points importants à lire avant l'installation diff --git a/check_process b/check_process index 843ff98..6fbc748 100644 --- a/check_process +++ b/check_process @@ -23,6 +23,8 @@ upgrade=1 from_commit=bde14cc4496445fdfed4616ac44fc9527c8369fd # 3.2.1~ynh1 upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697 + # 3.2.1~ynh2 + upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 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. @@ -46,3 +48,5 @@ Notification=all name=3.2.0~ynh1 ; commit=248b717f373f3c82bdb19c33cf20980494608697 name=3.2.1~ynh1 + ; commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 + name=3.2.1~ynh2 diff --git a/conf/app.src b/conf/app.src index 571866d..5d0c0b4 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.1.tar.gz -SOURCE_SUM=429dbe1166948e2863dd97b7d5458d18887e7a75b7ff5005cfa50828f9c7b9e2 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.2.tar.gz +SOURCE_SUM=298396b1bd0065689c3d9225c8466c6651979834acb4eec511057ff1ba630781 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 9c2a68d..1fc7555 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~ynh2", + "version": "3.2.2~ynh1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ From 0963d081aad00c2657c01affcb6d3f970c742186 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 6 Jan 2021 01:46:32 +0100 Subject: [PATCH 055/101] Upgrade to 3.3.0~ynh1 --- README.md | 2 +- README_fr.md | 2 +- check_process | 4 ++++ conf/app.src | 4 ++-- manifest.json | 2 +- scripts/_common.sh | 12 +++--------- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 19b1ee1..dc0c3c2 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,7 @@ If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. -**Shipped version:** 3.2.2 +**Shipped version:** 3.3.0 ## Important points to read before installing diff --git a/README_fr.md b/README_fr.md index 6c6ee1e..5f41969 100644 --- a/README_fr.md +++ b/README_fr.md @@ -11,7 +11,7 @@ Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. -**Version incluse:** 3.2.2 +**Version incluse:** 3.3.0 ## Points importants à lire avant l'installation diff --git a/check_process b/check_process index 6fbc748..233a374 100644 --- a/check_process +++ b/check_process @@ -25,6 +25,8 @@ upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697 # 3.2.1~ynh2 upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 + # 3.2.2~ynh1 + upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c 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. @@ -50,3 +52,5 @@ Notification=all name=3.2.1~ynh1 ; commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 name=3.2.1~ynh2 + ; commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c + name=3.2.2~ynh1 diff --git a/conf/app.src b/conf/app.src index 5d0c0b4..1f196ca 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.2.2.tar.gz -SOURCE_SUM=298396b1bd0065689c3d9225c8466c6651979834acb4eec511057ff1ba630781 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.3.0.tar.gz +SOURCE_SUM=ffbaeaf18d9c440ac61c6c5c29fd6581b88c1d2843170f2cb5f0fcf8dcc0ecd6 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/manifest.json b/manifest.json index 1fc7555..3dcd20d 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.2~ynh1", + "version": "3.3.0~ynh1", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ diff --git a/scripts/_common.sh b/scripts/_common.sh index ad4ed8e..1c28aec 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -9,15 +9,9 @@ pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git MEMORY_NEEDED="2560" -if [ "$(lsb_release --codename --short)" = "buster" ]; then - RUBY_VERSION="2.6.6" - BUNDLER_VERSION="1.17.3" - NODEJS_VERSION="12" -else - RUBY_VERSION="2.6.5" - BUNDLER_VERSION="1.17.3" - NODEJS_VERSION="10" -fi +RUBY_VERSION="2.7.2" +BUNDLER_VERSION="1.17.3" +NODEJS_VERSION="12" #================================================= # PERSONAL HELPERS From 43b89206b18f095d9f9d3e38993db88ac511b609 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 7 Jan 2021 20:33:33 +0100 Subject: [PATCH 056/101] upgrade ruby-build --- scripts/ynh_install_ruby__2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index df03e07..74de90e 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -22,8 +22,8 @@ SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > " # Build an app.src for ruby-build mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20200520.tar.gz -SOURCE_SUM=52be6908a94fbd4a94f5064e8b19d4a3baa4b773269c3884165518d83bcc8922" > "../conf/ruby-build.src" + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20201225.tar.gz +SOURCE_SUM=54cae123c2758e7714c66aca7ef8bc7f29cda8583891191ceb3053c6d098ecf1" > "../conf/ruby-build.src" # Download and extract ruby-build ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build From 94e8f5c8c8a1497aab24e207a448bb21180bac1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ric=20Gaspar?= <46165813+ericgaspar@users.noreply.github.com> Date: Sat, 9 Jan 2021 16:21:48 +0100 Subject: [PATCH 057/101] Set badge to SVG --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 19b1ee1..ab13c01 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Mastodon for YunoHost [![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) +[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon) *[Lire ce readme en français.](./README_fr.md)* From 6f911bd9a22c5ea6314d32958bf2736d497d3894 Mon Sep 17 00:00:00 2001 From: Alexandre Aubin Date: Sat, 9 Jan 2021 22:44:16 +0100 Subject: [PATCH 058/101] Finding an available port --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index d4d51d9..a005eba 100644 --- a/scripts/install +++ b/scripts/install @@ -62,7 +62,7 @@ ynh_app_setting_set --app=$app --key=language --value=$language #================================================= # FIND AND OPEN A PORT #================================================= -ynh_script_progression --message="Configuring firewall..." +ynh_script_progression --message="Finding an available port..." # Find an available port port_web=$(ynh_find_port --port=3000) From aa8928abd9d670920a23e922ab6d188ba530ffb1 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Feb 2021 19:22:07 +0100 Subject: [PATCH 059/101] Apply last example_ynh --- README.md | 11 ++++--- README_fr.md | 13 ++++---- check_process | 8 +---- conf/app.src | 1 + issue_template.md | 55 ++++++++++++++++++++++++++++++++++ pull_request_template.md | 4 +-- scripts/install | 12 ++++---- scripts/remove | 8 ++--- scripts/restore | 7 ++--- scripts/upgrade | 65 ++++++++++------------------------------ 10 files changed, 98 insertions(+), 86 deletions(-) create mode 100644 issue_template.md diff --git a/README.md b/README.md index 6f760f4..5336221 100644 --- a/README.md +++ b/README.md @@ -1,12 +1,12 @@ # Mastodon for YunoHost -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) +[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) [![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon) *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Mastodon quickly and simply on a YunoHost server. -If you don't have YunoHost, please see [here](https://yunohost.org/#/install) to know how to install and enjoy it.* +> *This package allows you to install Mastodon quickly and simply on a YunoHost server. +If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. @@ -70,10 +70,9 @@ LDAP authentication is activated. All YunoHost users can authenticate. --- -Developers info ----------------- +## Developer info -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). To try the testing branch, please proceed like that. ``` diff --git a/README_fr.md b/README_fr.md index 5f41969..6553753 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,12 +1,12 @@ # Mastodon pour YunoHost -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) +[![Niveau d'intégration](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) +[![Installer Mastodon avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon) *[Read this readme in english.](./README.md)* > *Ce package vous permet d'installer Mastodon rapidement et simplement sur un serveur YunoHost. -Si vous n'avez pas YunoHost, regardez [ici](https://yunohost.org/#/install) pour savoir comment l'installer et en profiter.* +Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. @@ -53,7 +53,7 @@ L'utilisateur admin est créé automatiquement comme : user@domain.tld ## Caractéristiques spécifiques YunoHost -#### Support multi-utilisateurs +#### Support multi-utilisateur L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier. @@ -62,7 +62,7 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a * x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) * ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) -## Links +## Liens * Signaler un bug : https://github.com/YunoHost-Apps/mastodon_ynh/issues * Site de l'application : https://joinmastodon.org/ @@ -71,8 +71,7 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a --- -Informations pour les développeurs ----------------- +## Informations pour les développeurs Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). diff --git a/check_process b/check_process index 233a374..a5f7d53 100644 --- a/check_process +++ b/check_process @@ -1,5 +1,4 @@ -;; Nom du test - auto_remove=1 +;; Test complet ; Manifest domain="domain.tld" (DOMAIN) admin="john" (USER) @@ -29,13 +28,8 @@ upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c 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. - # incorrect_path=1 port_already_use=0 change_url=0 -;;; Levels - # If the level 5 (Package linter) is forced to 1. Please add justifications here. - Level 5=auto ;;; Options Email=yalh@yahoo.com Notification=all diff --git a/conf/app.src b/conf/app.src index 1f196ca..6fb011a 100644 --- a/conf/app.src +++ b/conf/app.src @@ -4,3 +4,4 @@ SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true SOURCE_FILENAME= +SOURCE_EXTRACT=true diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..c6c9254 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to Mastodon itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install mastodon + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* diff --git a/pull_request_template.md b/pull_request_template.md index 7f09e84..6c28fc5 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -13,6 +13,4 @@ ## Package_check results --- -*If you have access to [App Continuous Integration for packagers](https://yunohost.org/#/packaging_apps_ci) you can provide a link to the package_check results like below, replacing '-NUM-' in this link by the PR number and USERNAME by your username on the ci-apps-dev. Or you provide a screenshot or a pastebin of the results* - -[![Build Status](https://ci-apps-dev.yunohost.org/jenkins/job/mastodon_ynh%20PR-NUM-%20(USERNAME)/badge/icon)](https://ci-apps-dev.yunohost.org/jenkins/job/mastodon_ynh%20PR-NUM-%20(USERNAME)/) +* An automatic package_check will be launch at https://ci-apps-dev.yunohost.org/, when you add a specific comment to your Pull Request: "!testme", "!gogogadgetoci" or "By the power of systemd, I invoke The Great App CI to test this Pull Request!"* diff --git a/scripts/install b/scripts/install index a005eba..8f4ca05 100644 --- a/scripts/install +++ b/scripts/install @@ -54,7 +54,6 @@ ynh_script_progression --message="Storing installation settings..." ynh_app_setting_set --app=$app --key=domain --value=$domain ynh_app_setting_set --app=$app --key=path --value=$path_url ynh_app_setting_set --app=$app --key=admin --value=$admin -ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=language --value=$language #================================================= @@ -83,9 +82,9 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st #================================================= # CREATE A POSTGRESQL DATABASE #================================================= -ynh_script_progression --message="Creating a MySQL database..." +ynh_script_progression --message="Creating a PostgreSQL database..." -# Create postgresql database +# Create PostgreSQL database db_name="${app}_production" db_user=$app db_pwd=$(ynh_string_random --length=30) @@ -269,13 +268,14 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # SETUP SSOWAT #================================================= -ynh_script_progression --message="Configuring SSOwat..." +ynh_script_progression --message="Configuring permissions..." # Make app public if necessary if [ $is_public -eq 1 ] then - # unprotected_uris allows SSO credentials to be passed anyway. - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" + # Everyone can access the app. + # The "main" permission is automatically created before the install script. + ynh_permission_update --permission="main" --add="visitors" fi #================================================= diff --git a/scripts/remove b/scripts/remove index 9fac8f2..46a78ab 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,7 +20,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$app +db_user=$db_name final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= @@ -32,19 +32,19 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # Remove the service from the list of services known by Yunohost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null then - ynh_script_progression --message="Removing $app-web service..." + ynh_script_progression --message="Removing $app-web service integration..." yunohost service remove "$app-web" fi if ynh_exec_warn_less yunohost service status "$app-sidekiq" >/dev/null then - ynh_script_progression --message="Removing $app-sidekiq service..." + ynh_script_progression --message="Removing $app-sidekiq service integration..." yunohost service remove "$app-sidekiq" fi if ynh_exec_warn_less yunohost service status "$app-streaming" >/dev/null then - ynh_script_progression --message="Removing $app-streaming service..." + ynh_script_progression --message="Removing $app-streaming service integration..." yunohost service remove "$app-streaming" fi diff --git a/scripts/restore b/scripts/restore index 84610eb..aef19ad 100644 --- a/scripts/restore +++ b/scripts/restore @@ -15,7 +15,6 @@ source /usr/share/yunohost/helpers #================================================= # MANAGE SCRIPT FAILURE #================================================= -ynh_script_progression --message="Managing script failure..." ynh_clean_setup () { ynh_clean_check_starting @@ -34,7 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$app +db_user=$db_name db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= @@ -135,7 +134,7 @@ ynh_script_progression --message="Restoring the systemd configuration..." ynh_restore_file --origin_path="/etc/systemd/system/$app-web.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-sidekiq.service" ynh_restore_file --origin_path="/etc/systemd/system/$app-streaming.service" -systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" +systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet #================================================= # INTEGRATE SERVICE IN YUNOHOST @@ -167,7 +166,7 @@ ynh_restore_file --origin_path="/etc/cron.d/$app" #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/upgrade b/scripts/upgrade index a045f46..8ab0fb5 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,6 +37,8 @@ otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret) vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key) vapid_public_key=$(ynh_app_setting_get --app=$app --key=vapid_public_key) +config="$final_path/live/.env.production" + #================================================= # CHECK VERSION #================================================= @@ -49,39 +51,27 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." -config="$final_path/live/.env.production" -# If db_name doesn't exist, create it -if [ -z "$db_name" ]; then - db_name="${app}_production" - ynh_app_setting_set --app=$app --key=db_name --value=$db_name +# Cleaning legacy permissions +if ynh_legacy_permissions_exists; then + ynh_legacy_permissions_delete_all + + ynh_app_setting_delete --app=$app --key=is_public fi -# If final_path doesn't exist, create it -if [ -z "$final_path" ]; then - final_path=/var/www/$app - ynh_app_setting_set --app=$app --key=final_path --value=$final_path -fi - -# Check if admin is not null -if [[ "$admin" = "" || "$language" = "" ]]; then - echo "Unable to upgrade, please contact support" - ynh_die -fi - -# If port_web doesn't exist, create it, need for old install +# If port_web doesn't exist, create it, needed for old install if [[ -z "$port_web" ]]; then port_web=3000 ynh_app_setting_set --app=$app --key=port_web --value=$port_web fi -# If port_web doesn't exist, create it, need for old install +# If port_web doesn't exist, create it, needed for old install if [[ -z "$port_stream" ]]; then port_stream=4000 ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream fi -# If db_pwd doesn't exist, create it, need for old install +# If db_pwd doesn't exist, create it, needed for old install if [[ -z "$db_pwd" ]]; then db_pwd=$(ynh_string_random) ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd @@ -143,18 +133,6 @@ ynh_clean_setup () { # Exit if an error occurs during the execution of the script ynh_abort_if_errors -#================================================= -# CHECK THE PATH -#================================================= - -# Normalize the URL path syntax -# N.B. : this is for app installations before YunoHost 2.7 -# where this value might be something like /foo/ or foo/ -# instead of /foo .... -# If nobody installed your app before 2.7, then you may -# safely remove this line -path_url=$(ynh_normalize_url_path --path_url=$path_url) - #================================================= # STANDARD UPGRADE STEPS #================================================= @@ -201,6 +179,7 @@ fi #================================================= ynh_script_progression --message="Upgrading nginx web server configuration..." +# Create a dedicated NGINX config ynh_add_nginx_config 'port_web port_stream' #================================================= @@ -315,15 +294,6 @@ ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" -- ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" -#================================================= -# INTEGRATE SERVICE IN YUNOHOST -#================================================= -ynh_script_progression --message="Integrating service in YunoHost..." - -yunohost service add "$app-web" --description "$app web service" --log_type "systemd" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" -yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" - #================================================= # GENERIC FINALIZATION #================================================= @@ -335,16 +305,13 @@ ynh_script_progression --message="Securing files and directories..." chown -R $app: $final_path #================================================= -# SETUP SSOWAT +# INTEGRATE SERVICE IN YUNOHOST #================================================= -ynh_script_progression --message="Upgrading SSOwat configuration..." +ynh_script_progression --message="Integrating service in YunoHost..." -# Make app public if necessary -if [ $is_public -eq 1 ] -then - # unprotected_uris allows SSO credentials to be passed anyway - ynh_app_setting_set --app=$app --key=unprotected_uris --value="/" -fi +yunohost service add "$app-web" --description "$app web service" --log_type "systemd" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" +yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" #================================================= # START SYSTEMD SERVICE From d7936c0e110f2cb14aa387100b6978b827046969 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Feb 2021 19:47:47 +0100 Subject: [PATCH 060/101] Update manifest.json --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 1fc7555..f6771cc 100644 --- a/manifest.json +++ b/manifest.json @@ -23,7 +23,7 @@ } ], "requirements": { - "yunohost": ">= 4.0" + "yunohost": ">= 4.1.3" }, "multi_instance": true, "services": [ From 057a2804247cc396a224df4b80427d3c9f7fe636 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Feb 2021 19:56:04 +0100 Subject: [PATCH 061/101] Create issue_template.md --- issue_template.md | 55 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 issue_template.md diff --git a/issue_template.md b/issue_template.md new file mode 100644 index 0000000..c6c9254 --- /dev/null +++ b/issue_template.md @@ -0,0 +1,55 @@ +--- +name: Bug report +about: When creating a bug report, please use the following template to provide all the relevant information and help debugging efficiently. + +--- + +**How to post a meaningful bug report** +1. *Read this whole template first.* +2. *Determine if you are on the right place:* + - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* + - *Otherwise, the issue may be due to Mastodon itself. Refer to its documentation or repository for help.* + - *When in doubt, post here and we will figure it out together.* +3. *Delete the italic comments as you write over them below, and remove this guide.* +--- + +### Describe the bug + +*A clear and concise description of what the bug is.* + +### Context + +- Hardware: *VPS bought online / Old laptop or computer / Raspberry Pi at home / Internet Cube with VPN / Other ARM board / ...* +- YunoHost version: x.x.x +- I have access to my server: *Through SSH | through the webadmin | direct access via keyboard / screen | ...* +- Are you in a special context or did you perform some particular tweaking on your YunoHost instance?: *no / yes* + - If yes, please explain: +- Using, or trying to install package version/branch: +- If upgrading, current package version: *can be found in the admin, or with `yunohost app info $app_id`* + +### Steps to reproduce + +- *If you performed a command from the CLI, the command itself is enough. For example:* + ```sh + sudo yunohost app install mastodon + ``` +- *If you used the webadmin, please perform the equivalent command from the CLI first.* +- *If the error occurs in your browser, explain what you did:* + 1. *Go to '...'* + 2. *Click on '...'* + 3. *Scroll down to '...'* + 4. *See error* + +### Expected behavior + +*A clear and concise description of what you expected to happen. You can remove this section if the command above is enough to understand your intent.* + +### Logs + +*When an operation fails, YunoHost provides a simple way to share the logs.* +- *In the webadmin, the error message contains a link to the relevant log page. On that page, you will be able to 'Share with Yunopaste'. If you missed it, the logs of previous operations are also available under Tools > Logs.* +- *In command line, the command to share the logs is displayed at the end of the operation and looks like `yunohost log display [log name] --share`. If you missed it, you can find the log ID of a previous operation using `yunohost log list`.* + +*After sharing the log, please copypaste directly the link provided by YunoHost (to help readability, no need to copypaste the entire content of the log here, just the link is enough...)* + +*If applicable and useful, add screenshots to help explain your problem.* From c2784f1c3188f679c18f868f208d22ee2bfd4dea Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 17 Feb 2021 19:57:15 +0100 Subject: [PATCH 062/101] Update upgrade --- scripts/upgrade | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/upgrade b/scripts/upgrade index 8ab0fb5..4b0c4ae 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -21,7 +21,6 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) admin=$(ynh_app_setting_get --app=$app --key=admin) -is_public=$(ynh_app_setting_get --app=$app --key=is_public) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) From 162a807f5ba1c2ce3e3f7420dc7ba1bdc906537a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 21 Feb 2021 22:27:05 +0100 Subject: [PATCH 063/101] Using option '--log_type systemd' with 'yunohost service add' is not relevant anymore --- scripts/install | 6 +++--- scripts/restore | 6 +++--- scripts/upgrade | 6 +++--- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/install b/scripts/install index 8f4ca05..a7ee1cb 100644 --- a/scripts/install +++ b/scripts/install @@ -252,9 +252,9 @@ chown -R "$app": "$final_path" #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" --log_type "systemd" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" -yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" +yunohost service add "$app-web" --description "$app web service" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" +yunohost service add "$app-streaming" --description "$app streaming service" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/restore b/scripts/restore index aef19ad..11729d4 100644 --- a/scripts/restore +++ b/scripts/restore @@ -141,9 +141,9 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" --log_type "systemd" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" -yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" +yunohost service add "$app-web" --description "$app web service" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" +yunohost service add "$app-streaming" --description "$app streaming service" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index 4b0c4ae..cd84ac8 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -308,9 +308,9 @@ chown -R $app: $final_path #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" --log_type "systemd" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" --log_type "systemd" -yunohost service add "$app-streaming" --description "$app streaming service" --log_type "systemd" +yunohost service add "$app-web" --description "$app web service" +yunohost service add "$app-sidekiq" --description "$app sidekiq service" +yunohost service add "$app-streaming" --description "$app streaming service" #================================================= # START SYSTEMD SERVICE From 1859c63f83e4d7b3d267226f48e72d0b7a967b0b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 21 Feb 2021 22:27:47 +0100 Subject: [PATCH 064/101] It looks like you forgot to enable setup_private test in check_process ? --- check_process | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/check_process b/check_process index a5f7d53..72f8049 100644 --- a/check_process +++ b/check_process @@ -9,7 +9,7 @@ setup_sub_dir=0 setup_root=1 setup_nourl=0 - setup_private=0 + setup_private=1 setup_public=1 upgrade=1 # 3.1.2~ynh2 From 88969d7b7ad4e3581599f748ea3b61dfc51c19a5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 23 Feb 2021 04:14:27 +0100 Subject: [PATCH 065/101] Fix bad database user name --- scripts/remove | 2 +- scripts/restore | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/remove b/scripts/remove index 46a78ab..0c71d04 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,7 +20,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +db_user=$app final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= diff --git a/scripts/restore b/scripts/restore index 11729d4..e51126f 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$db_name +db_user=$app db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= From b2af9c3f5ec4be1fbd10a9f14e7889aefec6b081 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Feb 2021 06:35:45 +0100 Subject: [PATCH 066/101] Fix ynh_install_ruby --- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-web.service | 2 +- scripts/install | 16 ++--- scripts/upgrade | 12 ++-- scripts/ynh_install_ruby__2 | 122 +++++++++++++++++++++++----------- 5 files changed, 100 insertions(+), 54 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index 7031e63..f0948a6 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -9,7 +9,7 @@ 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 +ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 1f5b6be..33e3feb 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ User=__APP__ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" -ExecStart=__RBENV_ROOT__/shims/bundle exec puma -C config/puma.rb +ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec puma -C config/puma.rb ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 Restart=always diff --git a/scripts/install b/scripts/install index a7ee1cb..368dcad 100644 --- a/scripts/install +++ b/scripts/install @@ -144,8 +144,8 @@ ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" - gem update --system - gem install bundler:$BUNDLER_VERSION --no-document + /opt/rbenv/versions/$app/bin/gem update --system + /opt/rbenv/versions/$app/bin/gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= @@ -188,14 +188,14 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - 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 /opt/rbenv/versions/$app/bin/bundle config deployment 'true' + sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config without 'development test' + sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) sudo -u $app PATH=$PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - 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 /opt/rbenv/versions/$app/bin/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/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 diff --git a/scripts/upgrade b/scripts/upgrade index cd84ac8..dcbe9b0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -262,13 +262,13 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - 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 /opt/rbenv/versions/$app/bin/bundle config deployment 'true' + sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config without 'development test' + sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/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 /opt/rbenv/versions/$app/bin/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails db:migrate sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear popd diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 74de90e..e885b96 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -2,30 +2,41 @@ # Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args +rbenv_version=1.1.2 +rbenv_rubybuild_version=20201225 +rbenv_aliases_version=1.1.0 rbenv_install_dir="/opt/rbenv" # RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable. export RBENV_ROOT="$rbenv_install_dir" -# Install ruby version management +# Install Ruby Version Management # # [internal] # # usage: ynh_install_rbenv ynh_install_rbenv () { - echo "Installation of rbenv - ruby version management" >&2 + ynh_print_info --message="Installation of rbenv - Ruby Version Management - rbenv-${rbenv_version}/ruby-build-${rbenv_rubybuild_version}" + # Build an app.src for rbenv mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v1.1.2.tar.gz + echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v${rbenv_version}.tar.gz SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src" # Download and extract rbenv - ynh_setup_source "$rbenv_install_dir" rbenv + ynh_setup_source --dest_dir="$rbenv_install_dir" --source_id=rbenv # Build an app.src for ruby-build mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v20201225.tar.gz + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v${rbenv_rubybuild_version}.tar.gz SOURCE_SUM=54cae123c2758e7714c66aca7ef8bc7f29cda8583891191ceb3053c6d098ecf1" > "../conf/ruby-build.src" # Download and extract ruby-build - ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build + ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/ruby-build" --source_id=ruby-build + + # Build an app.src for ruby-build + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/tpope/rbenv-aliases/archive/v${rbenv_aliases_version}.tar.gz +SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > "../conf/rbenv-aliases.src" + # Download and extract ruby-build + ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/rbenv-aliases" --source_id=rbenv-aliases (cd $rbenv_install_dir ./src/configure && make -C src) @@ -36,12 +47,12 @@ if [ ! -d $rbenv_install_dir/shims ] ; then fi } -# Install a specific version of ruby +# Install a specific version of Ruby # -# ynh_install_ruby will install the version of ruby provided as argument by using rbenv. +# ynh_install_ruby will install the version of Ruby provided as argument by using rbenv. # -# rbenv (ruby version management) stores the target ruby version in a .ruby_version file created in the target folder (using rbenv local ) -# It then uses that information for every ruby user that uses rbenv provided ruby command +# rbenv (Ruby Version Management) stores the target Ruby version in a .ruby_version file created in the target folder (using rbenv local ) +# It then uses that information for every Ruby user that uses rbenv provided Ruby command # # This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv # for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin) @@ -51,38 +62,41 @@ fi # When not possible (e.g. in systemd service definition), please use direct path # to rbenv shims (e.g. $RBENV_ROOT/shims/bundle) # -# usage: ynh_install_ruby ruby_version user +# usage: ynh_install_ruby --ruby_version=ruby_version # | arg: -v, --ruby_version= - Version of ruby to install. -# If possible, prefer to use major version number (e.g. 8 instead of 8.10.0). -# The crontab will handle the update of minor versions when needed. ynh_install_ruby () { # Declare an array to define the options of this helper. declare -Ar args_array=( [v]=ruby_version= ) - # Use rbenv, https://github.com/rbenv/rbenv to manage the ruby versions local ruby_version # Manage arguments with getopts ynh_handle_getopts_args "$@" - # Create $rbenv_install_dir + # Store ruby_version into the config of this app + ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$ruby_version + + # Create $rbenv_install_dir if doesn't exist already mkdir -p "$rbenv_install_dir/plugins/ruby-build" + # Create the file if doesn't exist already + touch "$rbenv_install_dir/ynh_app_version" + # Load rbenv path in PATH CLEAR_PATH="$rbenv_install_dir/bin:$PATH" - # Remove /usr/local/bin in PATH in case of ruby prior installation + # Remove /usr/local/bin in PATH in case of Ruby prior installation PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') - # Move an existing ruby binary, to avoid to block rbenv + # Move an existing Ruby binary, to avoid to block rbenv test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv # If rbenv is not previously setup, install it if ! type rbenv > /dev/null 2>&1 then ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt "1.1.2" + elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt ${rbenv_version} then ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt "20200520" + elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt ${rbenv_rubybuild_version} then ynh_install_rbenv fi @@ -90,57 +104,89 @@ ynh_install_ruby () { # Restore /usr/local/bin in PATH (if needed) PATH=$CLEAR_PATH - # And replace the old ruby binary + # And replace the old Ruby binary test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby - # Install the requested version of ruby + # Install the requested version of Ruby + ynh_print_info --message="Installation of Ruby-"$ruby_version CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version - # Store the ID of this app and the version of ruby requested for it - echo "$YNH_APP_ID:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version" + # Do not add twice the same line + if ! grep --quiet "$YNH_APP_INSTANCE_NAME:$ruby_version" "$rbenv_install_dir/ynh_app_version" + then - # Store ruby_version into the config of this app - ynh_app_setting_set $app ruby_version $ruby_version + # Remove previous version + if grep --quiet "$YNH_APP_INSTANCE_NAME:" "$rbenv_install_dir/ynh_app_version" + then + rbenv alias $YNH_APP_INSTANCE_NAME --remove + sed --in-place "/$YNH_APP_INSTANCE_NAME:/d" "$rbenv_install_dir/ynh_app_version" + fi - # Set environment for ruby users + # Store the ID of this app and the version of Ruby requested for it + echo "$YNH_APP_INSTANCE_NAME:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version" + fi + + # Remove no more needed Ruby version + installed_ruby_version=$(rbenv versions --bare --skip-aliases | grep -Ev '/') + for installed_version in $installed_ruby_version + do + if ! grep --quiet "$installed_version" "$rbenv_install_dir/ynh_app_version" + then + ynh_print_info --message="Removing of ruby-"$installed_version + $rbenv_install_dir/bin/rbenv uninstall --force $installed_version + fi + done + + # Set environment for Ruby users echo "#rbenv export RBENV_ROOT=$rbenv_install_dir export PATH=\"$rbenv_install_dir/bin:$PATH\" eval \"\$(rbenv init -)\" #rbenv" > /etc/profile.d/rbenv.sh - # Load the right environment for the Installation + # Load the environment eval "$(rbenv init -)" (cd $final_path rbenv local $ruby_version) + + rbenv alias $YNH_APP_INSTANCE_NAME $ruby_version } -# Remove the version of ruby used by the app. +# Remove the version of Ruby used by the app. # -# This helper will check if another app uses the same version of ruby, -# if not, this version of ruby will be removed. -# If no other app uses ruby, rbenv will be also removed. +# This helper will check if another app uses the same version of Ruby, +# if not, this version of Ruby will be removed. +# If no other app uses Ruby, rbenv will be also removed. # # usage: ynh_remove_ruby ynh_remove_ruby () { - ruby_version=$(ynh_app_setting_get $app ruby_version) + local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version) + + # Load rbenv path in PATH + CLEAR_PATH="$rbenv_install_dir/bin:$PATH" + + # Remove /usr/local/bin in PATH in case of Ruby prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + +rbenv alias $YNH_APP_INSTANCE_NAME --remove # Remove the line for this app - sed --in-place "/$YNH_APP_ID:$ruby_version/d" "$rbenv_install_dir/ynh_app_version" + sed --in-place "/$YNH_APP_INSTANCE_NAME:$ruby_version/d" "$rbenv_install_dir/ynh_app_version" - # If no other app uses this version of ruby, remove it. + # If no other app uses this version of Ruby, remove it. if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version" then + ynh_print_info --message="Removing of Ruby-"$ruby_version $rbenv_install_dir/bin/rbenv uninstall --force $ruby_version fi - # Remove rbenv environment configuration - rm /etc/profile.d/rbenv.sh - # If no other app uses rbenv, remove rbenv and dedicated group if [ ! -s "$rbenv_install_dir/ynh_app_version" ] then - ynh_secure_remove "$rbenv_install_dir" + ynh_print_info --message="Removing of rbenv" + ynh_secure_remove --file="$rbenv_install_dir" + # Remove rbenv environment configuration + rm /etc/profile.d/rbenv.sh fi } From 9691d954dc29f8d3468b8de87d934d5954320871 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Feb 2021 07:11:45 +0100 Subject: [PATCH 067/101] RBENV_ROOT --- conf/mastodon-sidekiq.service | 2 +- conf/mastodon-web.service | 2 +- scripts/install | 16 ++++++++-------- scripts/upgrade | 12 ++++++------ 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/conf/mastodon-sidekiq.service b/conf/mastodon-sidekiq.service index f0948a6..094813f 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/mastodon-sidekiq.service @@ -9,7 +9,7 @@ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="DB_POOL=25" Environment="MALLOC_ARENA_MAX=2" -ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec sidekiq -c 25 +ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-web.service b/conf/mastodon-web.service index 33e3feb..e853df5 100644 --- a/conf/mastodon-web.service +++ b/conf/mastodon-web.service @@ -8,7 +8,7 @@ User=__APP__ WorkingDirectory=__FINALPATH__/live Environment="RAILS_ENV=production" Environment="PORT=__PORT_WEB__" -ExecStart=/opt/rbenv/versions/__APP__/bin/bundle exec puma -C config/puma.rb +ExecStart=__RBENV_ROOT__/versions/__APP__/bin/bundle exec puma -C config/puma.rb ExecReload=/bin/kill -SIGUSR1 $MAINPID TimeoutSec=15 Restart=always diff --git a/scripts/install b/scripts/install index 368dcad..1447309 100644 --- a/scripts/install +++ b/scripts/install @@ -144,8 +144,8 @@ ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" - /opt/rbenv/versions/$app/bin/gem update --system - /opt/rbenv/versions/$app/bin/gem install bundler:$BUNDLER_VERSION --no-document + $RBENV_ROOT/versions/$app/bin/gem update --system + $RBENV_ROOT/versions/$app/bin/gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= @@ -188,14 +188,14 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config deployment 'true' - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config without 'development test' - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true' + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test' + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) sudo -u $app PATH=$PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails db:setup --quiet - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails assets:precompile --quiet - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/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 diff --git a/scripts/upgrade b/scripts/upgrade index dcbe9b0..6f14af2 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -262,13 +262,13 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config deployment 'true' - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle config without 'development test' - sudo -u $app PATH=$PATH /opt/rbenv/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true' + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test' + sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) sudo -u $app PATH=$PATH yarn install --pure-lockfile - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails assets:clean - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails assets:precompile - sudo -u $app RAILS_ENV=production PATH=$PATH /opt/rbenv/versions/$app/bin/bundle exec rails db:migrate + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:migrate sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear popd From 867c83b3f8e768cf110b8d9f1426a2751a88339a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Feb 2021 07:47:09 +0100 Subject: [PATCH 068/101] Fix rbenv alias not existing in previous version --- scripts/ynh_install_ruby__2 | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index e885b96..1d9bf8d 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -118,7 +118,10 @@ ynh_install_ruby () { # Remove previous version if grep --quiet "$YNH_APP_INSTANCE_NAME:" "$rbenv_install_dir/ynh_app_version" then - rbenv alias $YNH_APP_INSTANCE_NAME --remove + if grep --quiet "$YNH_APP_INSTANCE_NAME" $(rbenv alias --list) + then + rbenv alias $YNH_APP_INSTANCE_NAME --remove + fi sed --in-place "/$YNH_APP_INSTANCE_NAME:/d" "$rbenv_install_dir/ynh_app_version" fi From bd5d50e8b25db7cf4f49129e5b04f53834add424 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 27 Feb 2021 20:31:22 +0100 Subject: [PATCH 069/101] Implement ynh_add_config --- conf/.env.production.sample | 2 +- scripts/install | 36 ++++++++++++++---------------------- scripts/upgrade | 35 ++++------------------------------- 3 files changed, 19 insertions(+), 54 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index b189b53..00f7973 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -49,7 +49,7 @@ SMTP_SERVER=localhost SMTP_PORT=25 #SMTP_LOGIN= #SMTP_PASSWORD= -SMTP_FROM_ADDRESS=__SMTP_FROM_ADDRESS__ +SMTP_FROM_ADDRESS=__ADMIN_EMAIL__ #SMTP_REPLY_TO= #SMTP_DOMAIN= # defaults to LOCAL_DOMAIN SMTP_DELIVERY_METHOD=sendmail # delivery method can also be smtp diff --git a/scripts/install b/scripts/install index 1447309..7d72758 100644 --- a/scripts/install +++ b/scripts/install @@ -65,9 +65,9 @@ ynh_script_progression --message="Finding an available port..." # Find an available port port_web=$(ynh_find_port --port=3000) -port_stream=$(ynh_find_port --port=4000) -# Open this port ynh_app_setting_set --app=$app --key=port_web --value=$port_web + +port_stream=$(ynh_find_port --port=4000) ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= @@ -154,31 +154,25 @@ popd ynh_script_progression --message="Modifying a config file..." config="$final_path/live/.env.production" -cp -f ../conf/.env.production.sample "$config" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$config" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="$config" language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" - -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=$(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=$(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" +ynh_add_config --template="../conf/.env.production.sample" --destination="$config" + +vapid_private_key="" +vapid_public_key="" + ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml" ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml" +ynh_store_file_checksum --file="$final_path/live/config/settings.yml" + #================================================= # INSTALLING MASTODON #================================================= @@ -201,14 +195,13 @@ pushd "$final_path/live" popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") -vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") - -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="$config" -ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$config" - ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private_key" + +vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" +ynh_add_config --template="../conf/.env.production.sample" --destination="$config" + ynh_secure_remove --file="$final_path/live/key.txt" #================================================= @@ -216,8 +209,7 @@ ynh_secure_remove --file="$final_path/live/key.txt" #================================================= ynh_script_progression --message="Setuping the cron file..." -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -cp -f ../conf/cron /etc/cron.d/$app +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # SETUP SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index 6f14af2..1f6d9ed 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -30,7 +30,6 @@ admin_mail=$(ynh_user_get_info --username=$admin --key='mail') port_web=$(ynh_app_setting_get --app=$app --key=port_web) port_stream=$(ynh_app_setting_get --app=$app --key=port_stream) -paperclip_secret=$(ynh_app_setting_get --app=$app --key=paperclip_secret) secret_key_base=$(ynh_app_setting_get --app=$app --key=secret_key_base) otp_secret=$(ynh_app_setting_get --app=$app --key=otp_secret) vapid_private_key=$(ynh_app_setting_get --app=$app --key=vapid_private_key) @@ -79,14 +78,8 @@ if [[ -z "$db_pwd" ]]; then ynh_replace_string --match_string="DB_PASS=" --replace_string="DB_PASS=${db_pwd}" --target_file="$config" fi -# If paperclip_secret doesn't exist, retrieve it or create it -if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(grep -oP "PAPERCLIP_SECRET=\K\w+" $config) - if [[ -z "$paperclip_secret" ]]; then - paperclip_secret=$(ynh_string_random --length=128) - fi - ynh_app_setting_set --app=$app --key=paperclip_secret --value="$paperclip_secret" -fi +# Remove paperclip_secret +ynh_app_setting_delete --app=$app --key=paperclip_secret # If secret_key_base doesn't exist, retrieve it or create it if [[ -z "$secret_key_base" ]]; then @@ -233,25 +226,9 @@ popd #================================================= ynh_script_progression --message="Modifying a config file..." -ynh_backup_if_checksum_is_different --file="$config" -cp -f ../conf/.env.production.sample "$config" -ynh_replace_string --match_string="__DB_USER__" --replace_string="$app" --target_file="$config" -ynh_replace_string --match_string="__DB_NAME__" --replace_string="$db_name" --target_file="$config" -ynh_replace_string --match_string="__DB_PWD__" --replace_string="$db_pwd" --target_file="$config" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="$config" -ynh_replace_string --match_string="__SMTP_FROM_ADDRESS__" --replace_string="$admin_mail" --target_file="$config" - language="$(echo $language | head -c 2)" -ynh_replace_string --match_string="__LANGUAGE__" --replace_string="$language" --target_file="$config" -ynh_replace_string --match_string="PAPERCLIP_SECRET=" --replace_string="PAPERCLIP_SECRET=$paperclip_secret" --target_file="$config" - -ynh_replace_string --match_string="__SECRET_KEY_BASE__" --replace_string="$secret_key_base" --target_file="$config" - -ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret" --target_file="$config" - -ynh_replace_string --match_string="__VAPID_PRIVATE_KEY__" --replace_string="$vapid_private_key" --target_file="$config" -ynh_replace_string --match_string="__VAPID_PUBLIC_KEY__" --replace_string="$vapid_public_key" --target_file="$config" +ynh_add_config --template="../conf/.env.production.sample" --destination="$config" #================================================= # UPGRADE MASTODON @@ -272,16 +249,12 @@ pushd "$final_path/live" 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. -ynh_store_file_checksum --file="$config" - #================================================= # SETUP THE CRON FILE #================================================= ynh_script_progression --message="Setuping the cron file..." -ynh_replace_string --match_string="__FINAL_PATH__" --replace_string="$final_path" --target_file="../conf/cron" -cp -f ../conf/cron /etc/cron.d/$app +ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" #================================================= # SETUP SYSTEMD From f6eb84a96e20920caf6393636eeb1757d0666fbe Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 28 Feb 2021 23:41:20 +0100 Subject: [PATCH 070/101] fix __ADMIN_EMAIL__ missing --- conf/.env.production.sample | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 00f7973..f41c4dc 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -49,7 +49,7 @@ SMTP_SERVER=localhost SMTP_PORT=25 #SMTP_LOGIN= #SMTP_PASSWORD= -SMTP_FROM_ADDRESS=__ADMIN_EMAIL__ +SMTP_FROM_ADDRESS=__ADMIN_MAIL__ #SMTP_REPLY_TO= #SMTP_DOMAIN= # defaults to LOCAL_DOMAIN SMTP_DELIVERY_METHOD=sendmail # delivery method can also be smtp From 384ebfa72c31d44b72063ef449297589a126bfc9 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Mar 2021 00:37:33 +0100 Subject: [PATCH 071/101] fix missing __VAPID_PRIVATE_KEY__ --- scripts/install | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 7d72758..dc8b1ff 100644 --- a/scripts/install +++ b/scripts/install @@ -163,11 +163,11 @@ ynh_app_setting_set --app="$app" --key=secret_key_base --value="$secret_key_base otp_secret=$(ynh_string_random --length=128) ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" -ynh_add_config --template="../conf/.env.production.sample" --destination="$config" - vapid_private_key="" vapid_public_key="" +ynh_add_config --template="../conf/.env.production.sample" --destination="$config" + ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml" ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml" From e70f09a5d3794532f87678ba14a0e82906b36a81 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Mar 2021 01:10:48 +0100 Subject: [PATCH 072/101] Fix auth header ERR! Error: Invalid access token --- scripts/install | 2 ++ scripts/upgrade | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/scripts/install b/scripts/install index dc8b1ff..dd00359 100644 --- a/scripts/install +++ b/scripts/install @@ -270,6 +270,8 @@ then ynh_permission_update --permission="main" --add="visitors" fi +ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" + #================================================= # RELOAD NGINX #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 1f6d9ed..34db7f3 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -57,6 +57,11 @@ if ynh_legacy_permissions_exists; then ynh_app_setting_delete --app=$app --key=is_public fi +# Create a permission if needed +if ! ynh_permission_exists --permission="api"; then + ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --auth_header="false" --show_tile="false" --protected="true" +fi + # If port_web doesn't exist, create it, needed for old install if [[ -z "$port_web" ]]; then port_web=3000 From fcef659e0d6af040860828ffdbce5d488cbbd376 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 1 Mar 2021 21:15:26 +0100 Subject: [PATCH 073/101] Fix missing variable during upgrade --- scripts/install | 4 ++-- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index dd00359..7d21d45 100644 --- a/scripts/install +++ b/scripts/install @@ -85,8 +85,8 @@ ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ st ynh_script_progression --message="Creating a PostgreSQL database..." # Create PostgreSQL database -db_name="${app}_production" -db_user=$app +db_name=$(ynh_sanitize_dbid --db_name="${app}_production") +db_user=$(ynh_sanitize_dbid --db_name=$app) db_pwd=$(ynh_string_random --length=30) ynh_app_setting_set --app=$app --key=db_name --value=$db_name ynh_app_setting_set --app=$app --key=db_pwd --value=$db_pwd diff --git a/scripts/remove b/scripts/remove index 0c71d04..6b16380 100644 --- a/scripts/remove +++ b/scripts/remove @@ -20,7 +20,7 @@ app=$YNH_APP_INSTANCE_NAME domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$app +db_user=$(ynh_sanitize_dbid --db_name=$app) final_path=$(ynh_app_setting_get --app=$app --key=final_path) #================================================= diff --git a/scripts/restore b/scripts/restore index e51126f..6744ddb 100644 --- a/scripts/restore +++ b/scripts/restore @@ -33,7 +33,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) path_url=$(ynh_app_setting_get --app=$app --key=path) final_path=$(ynh_app_setting_get --app=$app --key=final_path) db_name=$(ynh_app_setting_get --app=$app --key=db_name) -db_user=$app +db_user=$(ynh_sanitize_dbid --db_name=$app) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 34db7f3..bbbe50b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -24,7 +24,7 @@ admin=$(ynh_app_setting_get --app=$app --key=admin) final_path=$(ynh_app_setting_get --app=$app --key=final_path) language=$(ynh_app_setting_get --app=$app --key=language) db_name=$(ynh_app_setting_get --app=$app --key=db_name) - +db_user=$(ynh_sanitize_dbid --db_name=$app) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) admin_mail=$(ynh_user_get_info --username=$admin --key='mail') port_web=$(ynh_app_setting_get --app=$app --key=port_web) From 5ce2a24649e12a087ce2a424d418262b1425ffb5 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Mar 2021 01:10:38 +0100 Subject: [PATCH 074/101] ynh_ruby_3 --- conf/cron | 10 +- scripts/install | 27 +-- scripts/remove | 2 +- scripts/upgrade | 26 +-- scripts/ynh_install_ruby__2 | 322 ++++++++++++++++++++++-------------- 5 files changed, 231 insertions(+), 156 deletions(-) diff --git a/conf/cron b/conf/cron index 776808b..a15c428 100644 --- a/conf/cron +++ b/conf/cron @@ -1,5 +1,5 @@ -@daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl statuses remove -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl preview_cards remove +@daily cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl media remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl media remove-orphans +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl accounts cull +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl statuses remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl preview_cards remove diff --git a/scripts/install b/scripts/install index 7d21d45..204bb52 100644 --- a/scripts/install +++ b/scripts/install @@ -75,9 +75,10 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= ynh_script_progression --message="Installing dependencies..." -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # CREATE A POSTGRESQL DATABASE @@ -142,10 +143,10 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Installing Ruby..." -ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" - $RBENV_ROOT/versions/$app/bin/gem update --system - $RBENV_ROOT/versions/$app/bin/gem install bundler:$BUNDLER_VERSION --no-document + ynh_use_ruby + $ynh_gem update --system + $ynh_gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= @@ -181,17 +182,17 @@ ynh_script_progression --message="Installing Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config deployment 'true' + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config without 'development test' + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true' - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test' - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) - sudo -u $app PATH=$PATH yarn install --pure-lockfile + sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:setup --quiet - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile --quiet - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/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 + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl accounts modify "$admin" --approve popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") diff --git a/scripts/remove b/scripts/remove index 6b16380..8a465a4 100644 --- a/scripts/remove +++ b/scripts/remove @@ -73,8 +73,8 @@ ynh_script_progression --message="Removing dependencies..." # Remove metapackage and its dependencies ynh_remove_ruby -ynh_remove_app_dependencies ynh_remove_nodejs +ynh_remove_app_dependencies ynh_remove_extra_repo #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index bbbe50b..27aaff0 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -184,10 +184,10 @@ ynh_add_nginx_config 'port_web port_stream' #================================================= ynh_script_progression --message="Upgrading dependencies..." -ynh_remove_nodejs -ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # CREATE DEDICATED USER @@ -220,10 +220,10 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Installing Ruby..." -ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" - gem update --system - gem install bundler:$BUNDLER_VERSION --no-document + ynh_use_ruby + $ynh_gem update --system + $ynh_gem install bundler:$BUNDLER_VERSION --no-document popd #================================================= @@ -243,15 +243,15 @@ ynh_script_progression --message="Upgrading Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config deployment 'true' + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config without 'development test' + sudo -u $app $ynh_ruby_load_path $ruby_path/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config deployment 'true' - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle config without 'development test' - sudo -u $app PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) - sudo -u $app PATH=$PATH yarn install --pure-lockfile - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:clean - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails assets:precompile - sudo -u $app RAILS_ENV=production PATH=$PATH $RBENV_ROOT/versions/$app/bin/bundle exec rails db:migrate - sudo -u $app RAILS_ENV=production PATH=$PATH bin/tootctl cache clear + sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:migrate + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl cache clear popd #================================================= diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 1d9bf8d..b8de713 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -1,11 +1,10 @@ #!/bin/bash -# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args - rbenv_version=1.1.2 -rbenv_rubybuild_version=20201225 +ruby_build_version=20201225 rbenv_aliases_version=1.1.0 rbenv_install_dir="/opt/rbenv" +ruby_version_path="$rbenv_install_dir/versions" # RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable. export RBENV_ROOT="$rbenv_install_dir" @@ -14,37 +13,104 @@ export RBENV_ROOT="$rbenv_install_dir" # [internal] # # usage: ynh_install_rbenv +# +# Requires YunoHost version 2.7.12 or higher. ynh_install_rbenv () { - ynh_print_info --message="Installation of rbenv - Ruby Version Management - rbenv-${rbenv_version}/ruby-build-${rbenv_rubybuild_version}" + ynh_print_info --message="Installation of rbenv - Ruby Version Management - rbenv-${rbenv_version}/ruby-build-${ruby_build_version}" - # Build an app.src for rbenv - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v${rbenv_version}.tar.gz + # Build an app.src for rbenv + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v${rbenv_version}.tar.gz SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src" - # Download and extract rbenv - ynh_setup_source --dest_dir="$rbenv_install_dir" --source_id=rbenv + # Download and extract rbenv + ynh_setup_source --dest_dir="$rbenv_install_dir" --source_id=rbenv - # Build an app.src for ruby-build - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v${rbenv_rubybuild_version}.tar.gz + # Build an app.src for ruby-build + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v${ruby_build_version}.tar.gz SOURCE_SUM=54cae123c2758e7714c66aca7ef8bc7f29cda8583891191ceb3053c6d098ecf1" > "../conf/ruby-build.src" - # Download and extract ruby-build - ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/ruby-build" --source_id=ruby-build + # Download and extract ruby-build + ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/ruby-build" --source_id=ruby-build - # Build an app.src for ruby-build - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/tpope/rbenv-aliases/archive/v${rbenv_aliases_version}.tar.gz + # Build an app.src for rbenv-aliases + mkdir -p "../conf" + echo "SOURCE_URL=https://github.com/tpope/rbenv-aliases/archive/v${rbenv_aliases_version}.tar.gz SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > "../conf/rbenv-aliases.src" - # Download and extract ruby-build - ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/rbenv-aliases" --source_id=rbenv-aliases + # Download and extract rbenv-aliases + ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/rbenv-aliases" --source_id=rbenv-aliases - (cd $rbenv_install_dir - ./src/configure && make -C src) + (cd $rbenv_install_dir + ./src/configure && make -C src) -# Create shims directory if needed -if [ ! -d $rbenv_install_dir/shims ] ; then - mkdir $rbenv_install_dir/shims -fi + # Create shims directory if needed + if [ ! -d $rbenv_install_dir/shims ] ; then + mkdir $rbenv_install_dir/shims + fi +} + +# Load the version of Ruby for an app, and set variables. +# +# ynh_use_ruby has to be used in any app scripts before using Ruby for the first time. +# This helper will provide alias and variables to use in your scripts. +# +# To use gem or Ruby, use the alias `ynh_gem` and `ynh_ruby` +# Those alias will use the correct version installed for the app +# For example: use `ynh_gem install` instead of `gem install` +# +# With `sudo` or `ynh_exec_as`, use instead the fallback variables `$ynh_gem` and `$ynh_ruby` +# And propagate $PATH to sudo with $ynh_ruby_load_path +# Exemple: `ynh_exec_as $app $ynh_ruby_load_path $ynh_gem install` +# +# $PATH contains the path of the requested version of Ruby. +# However, $PATH is duplicated into $ruby_path to outlast any manipulation of $PATH +# You can use the variable `$ynh_ruby_load_path` to quickly load your Ruby version +# in $PATH for an usage into a separate script. +# Exemple: $ynh_ruby_load_path $final_path/script_that_use_gem.sh` +# +# +# Finally, to start a Ruby service with the correct version, 2 solutions +# Either the app is dependent of Ruby or gem, but does not called it directly. +# In such situation, you need to load PATH +# `Environment="__YNH_RUBY_LOAD_ENV_PATH__"` +# `ExecStart=__FINALPATH__/my_app` +# You will replace __YNH_RUBY_LOAD_ENV_PATH__ with $ynh_ruby_load_path +# +# Or Ruby start the app directly, then you don't need to load the PATH variable +# `ExecStart=__YNH_RUBY__ my_app run` +# You will replace __YNH_RUBY__ with $ynh_ruby +# +# +# one other variable is also available +# - $ruby_path: The absolute path to Ruby binaries for the chosen version. +# +# usage: ynh_use_ruby +# +# Requires YunoHost version 2.7.12 or higher. +ynh_use_ruby () { + # Get the absolute path of this version of Ruby + ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin" + + # Allow alias to be used into bash script + shopt -s expand_aliases + + # Create an alias for the specific version of Ruby and a variable as fallback + ynh_ruby="$ruby_path/ruby" + alias ynh_ruby="$ynh_ruby" + # And gem + ynh_gem="$ruby_path/gem" + alias ynh_gem="$ynh_gem" + + # Load the path of this version of Ruby in $PATH + if [[ :$PATH: != *":$ruby_path"* ]]; then + PATH="$ruby_path:$PATH" + fi + ruby_path="$PATH" + # Create an alias to easily load the PATH + ynh_ruby_load_path="PATH=$ruby_path" + + # Sets the local application-specific Ruby version + (cd $final_path + rbenv local $ruby_version) } # Install a specific version of Ruby @@ -64,132 +130,140 @@ fi # # usage: ynh_install_ruby --ruby_version=ruby_version # | arg: -v, --ruby_version= - Version of ruby to install. +# +# Requires YunoHost version 2.7.12 or higher. ynh_install_ruby () { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [v]=ruby_version= ) - local ruby_version - # Manage arguments with getopts - ynh_handle_getopts_args "$@" + # Declare an array to define the options of this helper. + local legacy_args=v + local -A args_array=( [v]=ruby_version= ) + local ruby_version + # Manage arguments with getopts + ynh_handle_getopts_args "$@" - # Store ruby_version into the config of this app - ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$ruby_version + # Store ruby_version into the config of this app + ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$ruby_version - # Create $rbenv_install_dir if doesn't exist already - mkdir -p "$rbenv_install_dir/plugins/ruby-build" + # Create $rbenv_install_dir if doesn't exist already + mkdir -p "$rbenv_install_dir/plugins/ruby-build" - # Create the file if doesn't exist already - touch "$rbenv_install_dir/ynh_app_version" + # Load rbenv path in PATH + local CLEAR_PATH="$rbenv_install_dir/bin:$PATH" - # Load rbenv path in PATH - CLEAR_PATH="$rbenv_install_dir/bin:$PATH" + # Remove /usr/local/bin in PATH in case of Ruby prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') - # Remove /usr/local/bin in PATH in case of Ruby prior installation - PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + # Move an existing Ruby binary, to avoid to block rbenv + test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv - # Move an existing Ruby binary, to avoid to block rbenv - test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv - - # If rbenv is not previously setup, install it - if ! type rbenv > /dev/null 2>&1 - then - ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt ${rbenv_version} - then - ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt ${rbenv_rubybuild_version} - then - ynh_install_rbenv - fi - - # Restore /usr/local/bin in PATH (if needed) - PATH=$CLEAR_PATH - - # And replace the old Ruby binary - test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby - - # Install the requested version of Ruby - ynh_print_info --message="Installation of Ruby-"$ruby_version - CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version - - # Do not add twice the same line - if ! grep --quiet "$YNH_APP_INSTANCE_NAME:$ruby_version" "$rbenv_install_dir/ynh_app_version" - then - - # Remove previous version - if grep --quiet "$YNH_APP_INSTANCE_NAME:" "$rbenv_install_dir/ynh_app_version" + # If rbenv is not previously setup, install it + if ! type rbenv > /dev/null 2>&1 + then + ynh_install_rbenv + elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt $rbenv_version + then + ynh_install_rbenv + elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt $ruby_build_version + then + ynh_install_rbenv + elif dpkg --compare-versions "$($rbenv_install_dir/plugins/rbenv-aliases/bin/rbenv-aliases --version | cut -d" " -f2)" lt $rbenv_aliases_version + then + ynh_install_rbenv + fi + + # Restore /usr/local/bin in PATH + PATH=$CLEAR_PATH + + # And replace the old Ruby binary + test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby + + # Install the requested version of Ruby + ynh_print_info --message="Installation of Ruby-"$ruby_version + CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version + + # Remove app virtualenv + if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME" 1>/dev/null 2>&1` then - if grep --quiet "$YNH_APP_INSTANCE_NAME" $(rbenv alias --list) - then rbenv alias $YNH_APP_INSTANCE_NAME --remove - fi - sed --in-place "/$YNH_APP_INSTANCE_NAME:/d" "$rbenv_install_dir/ynh_app_version" fi - # Store the ID of this app and the version of Ruby requested for it - echo "$YNH_APP_INSTANCE_NAME:$ruby_version" | tee --append "$rbenv_install_dir/ynh_app_version" - fi + # Create app virtualenv + rbenv alias $YNH_APP_INSTANCE_NAME $ruby_version - # Remove no more needed Ruby version - installed_ruby_version=$(rbenv versions --bare --skip-aliases | grep -Ev '/') - for installed_version in $installed_ruby_version - do - if ! grep --quiet "$installed_version" "$rbenv_install_dir/ynh_app_version" - then - ynh_print_info --message="Removing of ruby-"$installed_version - $rbenv_install_dir/bin/rbenv uninstall --force $installed_version - fi - done + # Cleanup Ruby versions + ynh_cleanup_ruby - # Set environment for Ruby users - echo "#rbenv + # Set environment for Ruby users + echo "#rbenv export RBENV_ROOT=$rbenv_install_dir export PATH=\"$rbenv_install_dir/bin:$PATH\" eval \"\$(rbenv init -)\" -#rbenv" > /etc/profile.d/rbenv.sh + #rbenv" > /etc/profile.d/rbenv.sh - # Load the environment - eval "$(rbenv init -)" - - (cd $final_path - rbenv local $ruby_version) - - rbenv alias $YNH_APP_INSTANCE_NAME $ruby_version + # Load the environment + eval "$(rbenv init -)" } # Remove the version of Ruby used by the app. # -# This helper will check if another app uses the same version of Ruby, -# if not, this version of Ruby will be removed. -# If no other app uses Ruby, rbenv will be also removed. +# This helper will also cleanup Ruby versions # # usage: ynh_remove_ruby ynh_remove_ruby () { - local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version) + local ruby_version=$(ynh_app_setting_get --app=$YNH_APP_INSTANCE_NAME --key=ruby_version) - # Load rbenv path in PATH - CLEAR_PATH="$rbenv_install_dir/bin:$PATH" + # Load rbenv path in PATH + local CLEAR_PATH="$rbenv_install_dir/bin:$PATH" - # Remove /usr/local/bin in PATH in case of Ruby prior installation - PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') + # Remove /usr/local/bin in PATH in case of Ruby prior installation + PATH=$(echo $CLEAR_PATH | sed 's@/usr/local/bin:@@') -rbenv alias $YNH_APP_INSTANCE_NAME --remove + rbenv alias $YNH_APP_INSTANCE_NAME --remove - # Remove the line for this app - sed --in-place "/$YNH_APP_INSTANCE_NAME:$ruby_version/d" "$rbenv_install_dir/ynh_app_version" + # Remove the line for this app + ynh_app_setting_delete --app=$YNH_APP_INSTANCE_NAME --key=ruby_version - # If no other app uses this version of Ruby, remove it. - if ! grep --quiet "$ruby_version" "$rbenv_install_dir/ynh_app_version" - then - ynh_print_info --message="Removing of Ruby-"$ruby_version - $rbenv_install_dir/bin/rbenv uninstall --force $ruby_version - fi - - # If no other app uses rbenv, remove rbenv and dedicated group - if [ ! -s "$rbenv_install_dir/ynh_app_version" ] - then - ynh_print_info --message="Removing of rbenv" - ynh_secure_remove --file="$rbenv_install_dir" - # Remove rbenv environment configuration - rm /etc/profile.d/rbenv.sh - fi + # Cleanup Ruby versions + ynh_cleanup_ruby } + +# Remove no more needed versions of Ruby used by the app. +# +# This helper will check what Ruby version are no more required, +# and uninstall them +# If no app uses Ruby, rbenv will be also removed. +# +# usage: ynh_cleanup_ruby +ynh_cleanup_ruby () { + + # List required Ruby version + local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') + local required_ruby_versions="" + for installed_app in $installed_apps + do + local installed_app_ruby_version=$(yunohost app setting $installed_app ruby_version) + if [[ $installed_app_ruby_version ]] + then + required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}" + fi + done + + # Remove no more needed Ruby version + local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/') + for installed_ruby_version in $installed_ruby_versions + do + if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1` + then + ynh_print_info --message="Removing of Ruby-"$installed_ruby_version + $rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version + fi + done + + # If none Ruby version is required + if [[ ! $required_ruby_versions ]] + then + # Remove rbenv environment configuration + ynh_print_info --message="Removing of rbenv-"$rbenv_version + ynh_secure_remove --file="$rbenv_install_dir" + rm /etc/profile.d/rbenv.sh + fi +} \ No newline at end of file From 9d612530cae529c94281cc089f13e5cf8eb56719 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Mar 2021 01:37:12 +0100 Subject: [PATCH 075/101] Update ynh_install_ruby__2 --- scripts/ynh_install_ruby__2 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index b8de713..0488d3c 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -87,6 +87,7 @@ SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > " # # Requires YunoHost version 2.7.12 or higher. ynh_use_ruby () { + ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version) # Get the absolute path of this version of Ruby ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin" From 8e84376b47555be3c88b1475f54f0fa232d115b8 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Mar 2021 01:52:44 +0100 Subject: [PATCH 076/101] Update install --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 204bb52..208b0d2 100644 --- a/scripts/install +++ b/scripts/install @@ -125,7 +125,7 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # ADD SWAP IF NEEDED #================================================= -ynh_script_progression --message="Adding swap is needed..." +ynh_script_progression --message="Adding swap if needed..." total_memory=$(ynh_get_ram --total) swap_needed=0 From 05e04a31490bb0ce04b0ad2d0d9133c83614650d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Mar 2021 01:52:48 +0100 Subject: [PATCH 077/101] Update ynh_install_ruby__2 --- scripts/ynh_install_ruby__2 | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 0488d3c..78f65ad 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -105,9 +105,8 @@ ynh_use_ruby () { if [[ :$PATH: != *":$ruby_path"* ]]; then PATH="$ruby_path:$PATH" fi - ruby_path="$PATH" # Create an alias to easily load the PATH - ynh_ruby_load_path="PATH=$ruby_path" + ynh_ruby_load_path="PATH=$PATH" # Sets the local application-specific Ruby version (cd $final_path From 560506c3e74bc7a2f7923b537d27c2b66079ce47 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 6 Mar 2021 02:15:48 +0100 Subject: [PATCH 078/101] fix bin/tootctl --- conf/cron | 10 +++++----- scripts/install | 4 ++-- scripts/upgrade | 2 +- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/conf/cron b/conf/cron index a15c428..776808b 100644 --- a/conf/cron +++ b/conf/cron @@ -1,5 +1,5 @@ -@daily cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl media remove -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl media remove-orphans -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl accounts cull -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl statuses remove -@monthly cd __FINAL_PATH__/live && RAILS_ENV=production __RUBY_PATH__/tootctl preview_cards remove +@daily cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl media remove-orphans +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl accounts cull +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl statuses remove +@monthly cd __FINAL_PATH__/live && RAILS_ENV=production bin/tootctl preview_cards remove diff --git a/scripts/install b/scripts/install index 208b0d2..977f0b6 100644 --- a/scripts/install +++ b/scripts/install @@ -191,8 +191,8 @@ pushd "$final_path/live" sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:setup --quiet sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile --quiet sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl accounts modify "$admin" --approve + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + sudo -u $app RAILS_ENV=production $ynh_ruby_load_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 27aaff0..2e8753b 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -251,7 +251,7 @@ pushd "$final_path/live" sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:clean sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:migrate - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/tootctl cache clear + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear popd #================================================= From 0fbd6a19a1f413cfa05480cf44f33f4edff0f655 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 7 Mar 2021 18:44:44 +0100 Subject: [PATCH 079/101] Update ynh_install_ruby__2 --- scripts/ynh_install_ruby__2 | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 78f65ad..b517fd3 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -163,9 +163,6 @@ ynh_install_ruby () { then ynh_install_rbenv elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt $ruby_build_version - then - ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/plugins/rbenv-aliases/bin/rbenv-aliases --version | cut -d" " -f2)" lt $rbenv_aliases_version then ynh_install_rbenv fi @@ -266,4 +263,4 @@ ynh_cleanup_ruby () { ynh_secure_remove --file="$rbenv_install_dir" rm /etc/profile.d/rbenv.sh fi -} \ No newline at end of file +} From c4c79475213f752a42d427a9be4be25b5dcca02e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 7 Mar 2021 20:17:05 +0100 Subject: [PATCH 080/101] simplification --- scripts/_common.sh | 2 +- scripts/install | 22 +++++++++++----------- scripts/restore | 4 ++-- scripts/upgrade | 20 ++++++++++---------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 1c28aec..b6f4796 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -10,7 +10,7 @@ pkg_dependencies="imagemagick ffmpeg libpq-dev libxml2-dev libxslt1-dev file git MEMORY_NEEDED="2560" RUBY_VERSION="2.7.2" -BUNDLER_VERSION="1.17.3" + NODEJS_VERSION="12" #================================================= diff --git a/scripts/install b/scripts/install index 977f0b6..a390c66 100644 --- a/scripts/install +++ b/scripts/install @@ -145,8 +145,8 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - $ynh_gem update --system - $ynh_gem install bundler:$BUNDLER_VERSION --no-document + ynh_gem update --system + ynh_gem install bundler --no-document popd #================================================= @@ -182,17 +182,17 @@ ynh_script_progression --message="Installing Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config deployment 'true' - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config without 'development test' - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app bin/bundle config deployment 'true' + sudo -u $app bin/bundle config without 'development test' + sudo -u $app bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:setup --quiet - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile --quiet - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts modify "$admin" --approve + sudo -u $app RAILS_ENV=production bin/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u $app RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + sudo -u $app RAILS_ENV=production bin/tootctl accounts modify "$admin" --approve popd vapid_private_key=$(grep -oP "VAPID_PRIVATE_KEY=\K.+" "$final_path/live/key.txt") @@ -254,7 +254,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" #================================================= 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}-web --action="start" --log_path=systemd --line_match="Listening on" 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 6744ddb..19a7715 100644 --- a/scripts/restore +++ b/scripts/restore @@ -113,7 +113,7 @@ ynh_script_progression --message="Installing Ruby..." ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" gem update --system - gem install bundler:$BUNDLER_VERSION --no-document + gem install bundler --no-document popd #================================================= @@ -150,7 +150,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" #================================================= 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}-web --action="start" --log_path=systemd --line_match="Listening on" 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 2e8753b..3f81e57 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -222,8 +222,8 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - $ynh_gem update --system - $ynh_gem install bundler:$BUNDLER_VERSION --no-document + ynh_gem update --system + ynh_gem install bundler --no-document popd #================================================= @@ -243,15 +243,15 @@ ynh_script_progression --message="Upgrading Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config deployment 'true' - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle config without 'development test' - sudo -u $app $ynh_ruby_load_path $ruby_path/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app bin/bundle config deployment 'true' + sudo -u $app bin/bundle config without 'development test' + sudo -u $app bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:clean - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails assets:precompile - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path $ruby_path/bundle exec rails db:migrate - sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear + sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production bin/bundle exec rails db:migrate + sudo -u $app RAILS_ENV=production bin/tootctl cache clear popd #================================================= @@ -295,7 +295,7 @@ yunohost service add "$app-streaming" --description "$app streaming service" #================================================= 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}-web --action="start" --log_path=systemd --line_match="Listening on" 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 91ef58fdea28d22e16999e72d2990281fb52b3c2 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Mar 2021 00:45:35 +0100 Subject: [PATCH 081/101] Several fixes --- scripts/install | 22 +++++++++++----------- scripts/restore | 9 +++++---- scripts/upgrade | 18 +++++++++--------- 3 files changed, 25 insertions(+), 24 deletions(-) diff --git a/scripts/install b/scripts/install index a390c66..a3bc479 100644 --- a/scripts/install +++ b/scripts/install @@ -75,9 +75,9 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream #================================================= ynh_script_progression --message="Installing dependencies..." -ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= @@ -145,7 +145,7 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - ynh_gem update --system + # ynh_gem update --system ynh_gem install bundler --no-document popd @@ -182,17 +182,17 @@ ynh_script_progression --message="Installing Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - sudo -u $app bin/bundle config deployment 'true' - sudo -u $app bin/bundle config without 'development test' - sudo -u $app bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true' + sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test' + sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile echo "SAFETY_ASSURED=1">> $config - sudo -u $app RAILS_ENV=production bin/bundle exec rails db:setup --quiet - sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:precompile --quiet - sudo -u $app RAILS_ENV=production bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt - sudo -u $app RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null - sudo -u $app RAILS_ENV=production bin/tootctl accounts modify "$admin" --approve + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:setup --quiet + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile --quiet + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rake mastodon:webpush:generate_vapid_key > key.txt + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null + sudo -u $app RAILS_ENV=production $ynh_ruby_load_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/restore b/scripts/restore index 19a7715..64ac8f8 100644 --- a/scripts/restore +++ b/scripts/restore @@ -101,19 +101,20 @@ ynh_add_swap --size=$swap_needed #================================================= ynh_script_progression --message="Reinstalling dependencies..." +ynh_install_app_dependencies $pkg_dependencies ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= # INSTALLING RUBY AND BUNDLER #================================================= ynh_script_progression --message="Installing Ruby..." -ynh_install_ruby --ruby_version=$RUBY_VERSION pushd "$final_path/live" - gem update --system - gem install bundler --no-document + ynh_use_ruby + # ynh_gem update --system + ynh_gem install bundler --no-document popd #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 3f81e57..7a095ad 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -185,8 +185,8 @@ ynh_add_nginx_config 'port_web port_stream' ynh_script_progression --message="Upgrading dependencies..." ynh_install_app_dependencies $pkg_dependencies -ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_nodejs --nodejs_version=$NODEJS_VERSION +ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" ynh_install_ruby --ruby_version=$RUBY_VERSION #================================================= @@ -222,7 +222,7 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - ynh_gem update --system + # ynh_gem update --system ynh_gem install bundler --no-document popd @@ -243,15 +243,15 @@ ynh_script_progression --message="Upgrading Mastodon..." chown -R "$app": "$final_path" pushd "$final_path/live" - sudo -u $app bin/bundle config deployment 'true' - sudo -u $app bin/bundle config without 'development test' - sudo -u $app bin/bundle install -j$(getconf _NPROCESSORS_ONLN) + sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true' + sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test' + sudo -u $app $ynh_ruby_load_path bin/bundle install -j$(getconf _NPROCESSORS_ONLN) ynh_use_nodejs sudo -u $app $ynh_node_load_PATH yarn install --pure-lockfile - sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:clean - sudo -u $app RAILS_ENV=production bin/bundle exec rails assets:precompile - sudo -u $app RAILS_ENV=production bin/bundle exec rails db:migrate - sudo -u $app RAILS_ENV=production bin/tootctl cache clear + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:clean + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails assets:precompile + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/bundle exec rails db:migrate + sudo -u $app RAILS_ENV=production $ynh_ruby_load_path bin/tootctl cache clear popd #================================================= From e4332ad1371693519afce985a7ac8a3b1853022b Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Mar 2021 00:57:36 +0100 Subject: [PATCH 082/101] ynh_gem update --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a3bc479..a37bbba 100644 --- a/scripts/install +++ b/scripts/install @@ -145,7 +145,7 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - # ynh_gem update --system + ynh_gem update --system ynh_gem install bundler --no-document popd diff --git a/scripts/restore b/scripts/restore index 64ac8f8..a8cfd30 100644 --- a/scripts/restore +++ b/scripts/restore @@ -113,7 +113,7 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - # ynh_gem update --system + ynh_gem update --system ynh_gem install bundler --no-document popd diff --git a/scripts/upgrade b/scripts/upgrade index 7a095ad..aa96bef 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -222,7 +222,7 @@ ynh_script_progression --message="Installing Ruby..." pushd "$final_path/live" ynh_use_ruby - # ynh_gem update --system + ynh_gem update --system ynh_gem install bundler --no-document popd From a8cc57fe43d0de1e021fd22504cd28e0bd91a462 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 8 Mar 2021 21:38:00 +0100 Subject: [PATCH 083/101] spacing --- scripts/ynh_install_ruby__2 | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index b517fd3..1f965e3 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -88,6 +88,7 @@ SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > " # Requires YunoHost version 2.7.12 or higher. ynh_use_ruby () { ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version) + # Get the absolute path of this version of Ruby ruby_path="$ruby_version_path/$YNH_APP_INSTANCE_NAME/bin" From c4d58a6ba36fecffc7f5a0340ef969ffa3334adb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Mar 2021 22:51:42 +0100 Subject: [PATCH 084/101] Switch to git --- scripts/ynh_install_ruby__2 | 167 +++++++++++++++++++++--------------- 1 file changed, 97 insertions(+), 70 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 1f965e3..b3e3922 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -1,53 +1,18 @@ #!/bin/bash -rbenv_version=1.1.2 -ruby_build_version=20201225 -rbenv_aliases_version=1.1.0 +ynh_ruby_try_bash_extension() { + if [ -x src/configure ]; then + src/configure && make -C src || { + echo "Optional bash extension failed to build, but things will still work normally." + } + fi +} + rbenv_install_dir="/opt/rbenv" ruby_version_path="$rbenv_install_dir/versions" # RBENV_ROOT is the directory of rbenv, it needs to be loaded as a environment variable. export RBENV_ROOT="$rbenv_install_dir" -# Install Ruby Version Management -# -# [internal] -# -# usage: ynh_install_rbenv -# -# Requires YunoHost version 2.7.12 or higher. -ynh_install_rbenv () { - ynh_print_info --message="Installation of rbenv - Ruby Version Management - rbenv-${rbenv_version}/ruby-build-${ruby_build_version}" - - # Build an app.src for rbenv - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/rbenv/archive/v${rbenv_version}.tar.gz -SOURCE_SUM=80ad89ffe04c0b481503bd375f05c212bbc7d44ef5f5e649e0acdf25eba86736" > "../conf/rbenv.src" - # Download and extract rbenv - ynh_setup_source --dest_dir="$rbenv_install_dir" --source_id=rbenv - - # Build an app.src for ruby-build - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/rbenv/ruby-build/archive/v${ruby_build_version}.tar.gz -SOURCE_SUM=54cae123c2758e7714c66aca7ef8bc7f29cda8583891191ceb3053c6d098ecf1" > "../conf/ruby-build.src" - # Download and extract ruby-build - ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/ruby-build" --source_id=ruby-build - - # Build an app.src for rbenv-aliases - mkdir -p "../conf" - echo "SOURCE_URL=https://github.com/tpope/rbenv-aliases/archive/v${rbenv_aliases_version}.tar.gz -SOURCE_SUM=12e89bc4499e85d8babac2b02bc8b66ceb0aa3f8047b26728a3eca8a6030273d" > "../conf/rbenv-aliases.src" - # Download and extract rbenv-aliases - ynh_setup_source --dest_dir="$rbenv_install_dir/plugins/rbenv-aliases" --source_id=rbenv-aliases - - (cd $rbenv_install_dir - ./src/configure && make -C src) - - # Create shims directory if needed - if [ ! -d $rbenv_install_dir/shims ] ; then - mkdir $rbenv_install_dir/shims - fi -} - # Load the version of Ruby for an app, and set variables. # # ynh_use_ruby has to be used in any app scripts before using Ruby for the first time. @@ -110,8 +75,9 @@ ynh_use_ruby () { ynh_ruby_load_path="PATH=$PATH" # Sets the local application-specific Ruby version - (cd $final_path - rbenv local $ruby_version) + pushd $final_path + $rbenv_install_dir/bin/rbenv local $ruby_version + popd } # Install a specific version of Ruby @@ -141,12 +107,6 @@ ynh_install_ruby () { # Manage arguments with getopts ynh_handle_getopts_args "$@" - # Store ruby_version into the config of this app - ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$ruby_version - - # Create $rbenv_install_dir if doesn't exist already - mkdir -p "$rbenv_install_dir/plugins/ruby-build" - # Load rbenv path in PATH local CLEAR_PATH="$rbenv_install_dir/bin:$PATH" @@ -156,18 +116,81 @@ ynh_install_ruby () { # Move an existing Ruby binary, to avoid to block rbenv test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv - # If rbenv is not previously setup, install it - if ! type rbenv > /dev/null 2>&1 - then - ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/bin/rbenv --version | cut -d" " -f2)" lt $rbenv_version - then - ynh_install_rbenv - elif dpkg --compare-versions "$($rbenv_install_dir/plugins/ruby-build/bin/ruby-build --version | cut -d" " -f2)" lt $ruby_build_version - then - ynh_install_rbenv + # Instal or update rbenv + rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | head -1)" + if [ -n "$rbenv" ]; then + ynh_print_info --message="rbenv already seems installed in \`$rbenv'." + pushd "${rbenv%/*/*}" + if git remote -v 2>/dev/null | grep -q rbenv; then + echo "Trying to update with git..." + git pull -q --tags origin master + cd .. + ynh_ruby_try_bash_extension + fi + popd + else + ynh_print_info --message="Installing rbenv with git..." + mkdir -p $rbenv_install_dir + pushd $rbenv_install_dir + git init -q + git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1 + git checkout -q -b master origin/master + ynh_ruby_try_bash_extension + rbenv=$rbenv_install_dir/bin/rbenv + popd fi + ruby_build="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-install rbenv-install | head -1)" + if [ -n "$ruby_build" ]; then + ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'." + pushd "${ruby_build%/*/*}" + if git remote -v 2>/dev/null | grep -q ruby-build; then + ynh_print_info --message="Trying to update rbenv with git..." + git pull -q origin master + fi + popd + else + ynh_print_info --message="Installing ruby-build with git..." + mkdir -p "${rbenv_install_dir}/plugins" + git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build" + fi + + rb_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)" + if [ -n "$rb_alias" ]; then + ynh_print_info --message="\`rbenv alias' command already available in \`$rb_alias'." + pushd "${rb_alias%/*/*}" + if git remote -v 2>/dev/null | grep -q rbenv-aliases; then + ynh_print_info --message="Trying to update rbenv-aliases with git..." + git pull -q origin master + fi + popd + else + ynh_print_info --message="Installing rbenv-aliases with git..." + mkdir -p "${rbenv_install_dir}/plugins" + git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase" + fi + + rb_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)" + if [ -n "$rb_latest" ]; then + ynh_print_info --message="\`rbenv latest' command already available in \`$rb_latest'." + pushd "${rb_latest%/*/*}" + if git remote -v 2>/dev/null | grep -q xxenv-latest; then + ynh_print_info --message="Trying to update xxenv-latest with git..." + git pull -q origin master + fi + popd + else + ynh_print_info --message="Installing xxenv-latest with git..." + mkdir -p "${rbenv_install_dir}/plugins" + git clone -q https://github.com/momo-lab/xxenv-latest.git "${rbenv_install_dir}/plugins/xxenv-latest" + fi + + # Enable caching + mkdir -p "${rbenv_install_dir}/cache" + + # Create shims directory if needed + mkdir -p "${rbenv_install_dir}/shims" + # Restore /usr/local/bin in PATH PATH=$CLEAR_PATH @@ -175,17 +198,21 @@ ynh_install_ruby () { test -x /usr/bin/ruby_rbenv && mv /usr/bin/ruby_rbenv /usr/bin/ruby # Install the requested version of Ruby - ynh_print_info --message="Installation of Ruby-"$ruby_version - CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $ruby_version + local final_ruby_version=$(rbenv latest --print $ruby_version) + ynh_print_info --message="Installing Ruby-$final_ruby_version" + CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1 + + # Store ruby_version into the config of this app + ynh_app_setting_set --app=$YNH_APP_INSTANCE_NAME --key=ruby_version --value=$final_ruby_version # Remove app virtualenv - if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME" 1>/dev/null 2>&1` + if `rbenv alias --list | grep --quiet "$YNH_APP_INSTANCE_NAME " 1>/dev/null 2>&1` then rbenv alias $YNH_APP_INSTANCE_NAME --remove fi # Create app virtualenv - rbenv alias $YNH_APP_INSTANCE_NAME $ruby_version + rbenv alias $YNH_APP_INSTANCE_NAME $final_ruby_version # Cleanup Ruby versions ynh_cleanup_ruby @@ -233,7 +260,7 @@ ynh_remove_ruby () { # usage: ynh_cleanup_ruby ynh_cleanup_ruby () { - # List required Ruby version + # List required Ruby versions local installed_apps=$(yunohost app list | grep -oP 'id: \K.*$') local required_ruby_versions="" for installed_app in $installed_apps @@ -245,13 +272,13 @@ ynh_cleanup_ruby () { fi done - # Remove no more needed Ruby version + # Remove no more needed Ruby versions local installed_ruby_versions=$(rbenv versions --bare --skip-aliases | grep -Ev '/') for installed_ruby_version in $installed_ruby_versions do if ! `echo ${required_ruby_versions} | grep "${installed_ruby_version}" 1>/dev/null 2>&1` then - ynh_print_info --message="Removing of Ruby-"$installed_ruby_version + ynh_print_info --message="Removing of Ruby-$installed_ruby_version" $rbenv_install_dir/bin/rbenv uninstall --force $installed_ruby_version fi done @@ -260,8 +287,8 @@ ynh_cleanup_ruby () { if [[ ! $required_ruby_versions ]] then # Remove rbenv environment configuration - ynh_print_info --message="Removing of rbenv-"$rbenv_version + ynh_print_info --message="Removing of rbenv-$rbenv_version" ynh_secure_remove --file="$rbenv_install_dir" - rm /etc/profile.d/rbenv.sh + ynh_secure_remove --file="/etc/profile.d/rbenv.sh" fi } From 05b6dc21ffacec0e7b97270bf80cc6a8a1753f65 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 12 Mar 2021 23:41:08 +0100 Subject: [PATCH 085/101] Update ynh_install_ruby__2 --- scripts/ynh_install_ruby__2 | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index b3e3922..89fbd05 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -155,10 +155,10 @@ ynh_install_ruby () { git clone -q https://github.com/rbenv/ruby-build.git "${rbenv_install_dir}/plugins/ruby-build" fi - rb_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)" - if [ -n "$rb_alias" ]; then - ynh_print_info --message="\`rbenv alias' command already available in \`$rb_alias'." - pushd "${rb_alias%/*/*}" + rbenv_alias="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-alias rbenv-alias | head -1)" + if [ -n "$rbenv_alias" ]; then + ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'." + pushd "${rbenv_alias%/*/*}" if git remote -v 2>/dev/null | grep -q rbenv-aliases; then ynh_print_info --message="Trying to update rbenv-aliases with git..." git pull -q origin master @@ -170,10 +170,10 @@ ynh_install_ruby () { git clone -q https://github.com/tpope/rbenv-aliases.git "${rbenv_install_dir}/plugins/rbenv-aliase" fi - rb_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)" - if [ -n "$rb_latest" ]; then - ynh_print_info --message="\`rbenv latest' command already available in \`$rb_latest'." - pushd "${rb_latest%/*/*}" + rbenv_latest="$(command -v "$rbenv_install_dir"/plugins/*/bin/rbenv-latest rbenv-latest | head -1)" + if [ -n "$rbenv_latest" ]; then + ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'." + pushd "${rbenv_latest%/*/*}" if git remote -v 2>/dev/null | grep -q xxenv-latest; then ynh_print_info --message="Trying to update xxenv-latest with git..." git pull -q origin master @@ -222,7 +222,7 @@ ynh_install_ruby () { export RBENV_ROOT=$rbenv_install_dir export PATH=\"$rbenv_install_dir/bin:$PATH\" eval \"\$(rbenv init -)\" - #rbenv" > /etc/profile.d/rbenv.sh +#rbenv" > /etc/profile.d/rbenv.sh # Load the environment eval "$(rbenv init -)" From 3fa6a835b570b181a2b5a95ac98c3b38f5738c3d Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Mar 2021 13:00:18 +0100 Subject: [PATCH 086/101] Manage previous rbenv installation --- scripts/ynh_install_ruby__2 | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 89fbd05..7afe7b5 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -3,7 +3,7 @@ ynh_ruby_try_bash_extension() { if [ -x src/configure ]; then src/configure && make -C src || { - echo "Optional bash extension failed to build, but things will still work normally." + ynh_print_info --message="Optional bash extension failed to build, but things will still work normally." } fi } @@ -84,9 +84,6 @@ ynh_use_ruby () { # # ynh_install_ruby will install the version of Ruby provided as argument by using rbenv. # -# rbenv (Ruby Version Management) stores the target Ruby version in a .ruby_version file created in the target folder (using rbenv local ) -# It then uses that information for every Ruby user that uses rbenv provided Ruby command -# # This helper creates a /etc/profile.d/rbenv.sh that configures PATH environment for rbenv # for every LOGIN user, hence your user must have a defined shell (as opposed to /usr/sbin/nologin) # @@ -116,16 +113,26 @@ ynh_install_ruby () { # Move an existing Ruby binary, to avoid to block rbenv test -x /usr/bin/ruby && mv /usr/bin/ruby /usr/bin/ruby_rbenv - # Instal or update rbenv - rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | head -1)" + # Install or update rbenv + rbenv="$(command -v rbenv $rbenv_install_dir/bin/rbenv | grep "$rbenv_install_dir/bin/rbenv" | head -1)" if [ -n "$rbenv" ]; then ynh_print_info --message="rbenv already seems installed in \`$rbenv'." pushd "${rbenv%/*/*}" - if git remote -v 2>/dev/null | grep -q rbenv; then - echo "Trying to update with git..." + if git remote -v 2>/dev/null | grep -q "origin https://github.com/rbenv/rbenv.git"; then + ynh_print_info --message="Trying to update with git..." git pull -q --tags origin master - cd .. ynh_ruby_try_bash_extension + else + ynh_print_info --message="Reinstalling rbenv with git..." + cd .. + ynh_secure_remove --file=$rbenv_install_dir + mkdir -p $rbenv_install_dir + cd $rbenv_install_dir + git init -q + git remote add -f -t master origin https://github.com/rbenv/rbenv.git > /dev/null 2>&1 + git checkout -q -b master origin/master + ynh_ruby_try_bash_extension + rbenv=$rbenv_install_dir/bin/rbenv fi popd else From 9588b8da9393f874f8678b2aa56cdfea8da794a7 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Mar 2021 15:05:48 +0100 Subject: [PATCH 087/101] Fix new rbenv install --list-all --- scripts/ynh_install_ruby__2 | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 7afe7b5..f9cc22a 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -206,6 +206,9 @@ ynh_install_ruby () { # Install the requested version of Ruby local final_ruby_version=$(rbenv latest --print $ruby_version) + if ! [ -n "$final_ruby_version" ]; then + final_ruby_version=$ruby_version + fi ynh_print_info --message="Installing Ruby-$final_ruby_version" CONFIGURE_OPTS="--disable-install-doc --with-jemalloc" MAKE_OPTS="-j2" rbenv install --skip-existing $final_ruby_version > /dev/null 2>&1 From 5ce2de89b9f32a0bd18efbc498c94af3f9d64d84 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Mar 2021 00:48:54 +0100 Subject: [PATCH 088/101] Do not use 'yunohost app setting' --- scripts/ynh_install_ruby__2 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index f9cc22a..9a63c67 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -275,7 +275,7 @@ ynh_cleanup_ruby () { local required_ruby_versions="" for installed_app in $installed_apps do - local installed_app_ruby_version=$(yunohost app setting $installed_app ruby_version) + local installed_app_ruby_version=$(ynh_app_setting_get --app=$installed_app --key="ruby_version") if [[ $installed_app_ruby_version ]] then required_ruby_versions="${installed_app_ruby_version}\n${required_ruby_versions}" From 2c6c2c02a131700dd1a243e6c94af7d78274174a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 14 Mar 2021 06:00:31 +0100 Subject: [PATCH 089/101] Fix repository detection --- scripts/ynh_install_ruby__2 | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index 9a63c67..a946903 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -118,7 +118,7 @@ ynh_install_ruby () { if [ -n "$rbenv" ]; then ynh_print_info --message="rbenv already seems installed in \`$rbenv'." pushd "${rbenv%/*/*}" - if git remote -v 2>/dev/null | grep -q "origin https://github.com/rbenv/rbenv.git"; then + if git remote -v 2>/dev/null | grep "https://github.com/rbenv/rbenv.git"; then ynh_print_info --message="Trying to update with git..." git pull -q --tags origin master ynh_ruby_try_bash_extension @@ -151,7 +151,7 @@ ynh_install_ruby () { if [ -n "$ruby_build" ]; then ynh_print_info --message="\`rbenv install' command already available in \`$ruby_build'." pushd "${ruby_build%/*/*}" - if git remote -v 2>/dev/null | grep -q ruby-build; then + if git remote -v 2>/dev/null | grep "https://github.com/rbenv/ruby-build.git"; then ynh_print_info --message="Trying to update rbenv with git..." git pull -q origin master fi @@ -166,7 +166,7 @@ ynh_install_ruby () { if [ -n "$rbenv_alias" ]; then ynh_print_info --message="\`rbenv alias' command already available in \`$rbenv_alias'." pushd "${rbenv_alias%/*/*}" - if git remote -v 2>/dev/null | grep -q rbenv-aliases; then + if git remote -v 2>/dev/null | grep "https://github.com/tpope/rbenv-aliases.git"; then ynh_print_info --message="Trying to update rbenv-aliases with git..." git pull -q origin master fi @@ -181,7 +181,7 @@ ynh_install_ruby () { if [ -n "$rbenv_latest" ]; then ynh_print_info --message="\`rbenv latest' command already available in \`$rbenv_latest'." pushd "${rbenv_latest%/*/*}" - if git remote -v 2>/dev/null | grep -q xxenv-latest; then + if git remote -v 2>/dev/null | grep "https://github.com/momo-lab/xxenv-latest.git"; then ynh_print_info --message="Trying to update xxenv-latest with git..." git pull -q origin master fi From b01227d32602fe2239f1c74fa8ac06940230c52e Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 22 Mar 2021 20:54:09 +0100 Subject: [PATCH 090/101] Update ynh_install_ruby__2 --- scripts/ynh_install_ruby__2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/scripts/ynh_install_ruby__2 b/scripts/ynh_install_ruby__2 index a946903..fae1755 100644 --- a/scripts/ynh_install_ruby__2 +++ b/scripts/ynh_install_ruby__2 @@ -50,7 +50,7 @@ export RBENV_ROOT="$rbenv_install_dir" # # usage: ynh_use_ruby # -# Requires YunoHost version 2.7.12 or higher. +# Requires YunoHost version 3.2.2 or higher. ynh_use_ruby () { ruby_version=$(ynh_app_setting_get --app=$app --key=ruby_version) @@ -95,7 +95,7 @@ ynh_use_ruby () { # usage: ynh_install_ruby --ruby_version=ruby_version # | arg: -v, --ruby_version= - Version of ruby to install. # -# Requires YunoHost version 2.7.12 or higher. +# Requires YunoHost version 3.2.2 or higher. ynh_install_ruby () { # Declare an array to define the options of this helper. local legacy_args=v From 91ad69fd115476853be326470d230e3798ea8ec0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Tue, 23 Mar 2021 20:41:14 +0100 Subject: [PATCH 091/101] Upgrade version --- check_process | 4 ++++ manifest.json | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/check_process b/check_process index 72f8049..64394f4 100644 --- a/check_process +++ b/check_process @@ -26,6 +26,8 @@ upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 # 3.2.2~ynh1 upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c + # 3.3.0~ynh1 + upgrade=1 from_commit=a7eb98db3fac0697b923072dcd78c1ca04bf0a12 backup_restore=1 multi_instance=1 port_already_use=0 @@ -48,3 +50,5 @@ Notification=all name=3.2.1~ynh2 ; commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c name=3.2.2~ynh1 + ; commit=a7eb98db3fac0697b923072dcd78c1ca04bf0a12 + name=3.3.0~ynh1 diff --git a/manifest.json b/manifest.json index 2d38584..5b89865 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.3.0~ynh1", + "version": "3.3.0~ynh2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", "maintainer": [ From b07683cc0130e0b5038371472aef015162759961 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 24 Mar 2021 19:58:27 +0100 Subject: [PATCH 092/101] Fix manually modified file --- scripts/install | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/install b/scripts/install index a37bbba..0b79b96 100644 --- a/scripts/install +++ b/scripts/install @@ -201,6 +201,8 @@ ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" +ynh_delete_file_checksum --file="$config" + ynh_add_config --template="../conf/.env.production.sample" --destination="$config" ynh_secure_remove --file="$final_path/live/key.txt" From f376290f1397f56e8d12bad5d15ac952fbdc25c6 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 00:18:53 +0200 Subject: [PATCH 093/101] Apply example_ynh --- README.md | 4 ++-- README_fr.md | 4 ++-- check_process | 6 +++++- manifest.json | 22 +++++----------------- scripts/backup | 2 +- scripts/install | 42 +++++++++++++++++++----------------------- scripts/remove | 6 +++--- scripts/restore | 40 ++++++++++++++++++---------------------- scripts/upgrade | 41 ++++++++++++++++++----------------------- 9 files changed, 73 insertions(+), 94 deletions(-) diff --git a/README.md b/README.md index 5336221..a4bd460 100644 --- a/README.md +++ b/README.md @@ -58,8 +58,8 @@ LDAP authentication is activated. All YunoHost users can authenticate. #### Supported architectures -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) ## Links diff --git a/README_fr.md b/README_fr.md index 6553753..1f1fc84 100644 --- a/README_fr.md +++ b/README_fr.md @@ -59,8 +59,8 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a #### Architectures supportées -* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) -* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon%20%28Apps%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) +* x86-64 - [![Build Status](https://ci-apps.yunohost.org/ci/logs/mastodon.svg)](https://ci-apps.yunohost.org/ci/apps/mastodon/) +* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/mastodon.svg)](https://ci-apps-arm.yunohost.org/ci/apps/mastodon/) ## Liens diff --git a/check_process b/check_process index 72f8049..e187789 100644 --- a/check_process +++ b/check_process @@ -26,10 +26,12 @@ upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 # 3.2.2~ynh1 upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c + # 3.3.0~ynh1 + upgrade=1 from_commit=1b7de8c3acc9607c619c02aae49a2485e40eef4d backup_restore=1 multi_instance=1 port_already_use=0 - change_url=0 + change_url=1 ;;; Options Email=yalh@yahoo.com Notification=all @@ -48,3 +50,5 @@ Notification=all name=3.2.1~ynh2 ; commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c name=3.2.2~ynh1 + ; commit=1b7de8c3acc9607c619c02aae49a2485e40eef4d + name=3.3.0~ynh1 diff --git a/manifest.json b/manifest.json index 2d38584..d6aa9f1 100644 --- a/manifest.json +++ b/manifest.json @@ -6,10 +6,13 @@ "en": "A libre and federated social network.", "fr": "Un réseau social libre et fédéré." }, - "version": "3.3.0~ynh1", + "version": "3.3.0~ynh2", "url": "https://github.com/tootsuite/mastodon", "license": "AGPL-3.0-or-later", - "maintainer": [ + "maintainer": { + "name": "yalh76" + }, + "previous_maintainer": [ { "name": "cyp", "email": "cyp@rouquin.me" @@ -17,9 +20,6 @@ { "name": "nemsia", "email": "nemsia@nemsia.org" - }, - { - "name": "yalh76" } ], "requirements": { @@ -34,28 +34,16 @@ { "name": "domain", "type": "domain", - "ask": { - "en": "Choose a domain for Mastodon", - "fr": "Choisissez un domaine pour Mastodon" - }, "example": "example.com" }, { "name": "admin", "type": "user", - "ask": { - "en": "Choose an admin user", - "fr": "Choisissez l'administrateur" - }, "example": "johndoe" }, { "name": "is_public", "type": "boolean", - "ask": { - "en": "Is it a public application?", - "fr": "Est-ce une application publique ?" - }, "default": true }, { diff --git a/scripts/backup b/scripts/backup index c1d4f6f..590ce0f 100644 --- a/scripts/backup +++ b/scripts/backup @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source /usr/share/yunohost/helpers diff --git a/scripts/install b/scripts/install index 7d21d45..da81c3b 100644 --- a/scripts/install +++ b/scripts/install @@ -76,9 +76,17 @@ ynh_app_setting_set --app=$app --key=port_stream --value=$port_stream ynh_script_progression --message="Installing dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Configuring system user..." + +# Create a system user +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= @@ -103,22 +111,18 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/live" +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Configuring nginx web server..." +ynh_script_progression --message="Configuring NGINX web server..." -# Create a dedicated nginx config +# Create a dedicated NGINX config ynh_add_nginx_config 'port_web port_stream' -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Configuring system user..." - -# Create a system user -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC SETUP #================================================= @@ -231,22 +235,14 @@ ynh_store_file_checksum --file="$config" #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions to app files -chown -R "$app": "$final_path" - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" -yunohost service add "$app-streaming" --description "$app streaming service" +yunohost service add "$app-web" --description="$app web service" +yunohost service add "$app-sidekiq" --description="$app sidekiq service" +yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE @@ -275,7 +271,7 @@ ynh_permission_create --permission="api" --url="/api" --allowed="visitors" --aut #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload diff --git a/scripts/remove b/scripts/remove index 6b16380..44c3bde 100644 --- a/scripts/remove +++ b/scripts/remove @@ -29,7 +29,7 @@ final_path=$(ynh_app_setting_get --app=$app --key=final_path) # REMOVE SERVICE INTEGRATION IN YUNOHOST #================================================= -# Remove the service from the list of services known by Yunohost (added from `yunohost service add`) +# Remove the service from the list of services known by YunoHost (added from `yunohost service add`) if ynh_exec_warn_less yunohost service status "$app-web" >/dev/null then ynh_script_progression --message="Removing $app-web service integration..." @@ -88,9 +88,9 @@ ynh_secure_remove --file="$final_path" #================================================= # REMOVE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Removing nginx web server configuration..." +ynh_script_progression --message="Removing NGINX web server configuration..." -# Remove the dedicated nginx config +# Remove the dedicated NGINX config ynh_remove_nginx_config #================================================= diff --git a/scripts/restore b/scripts/restore index 6744ddb..f51537a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -6,7 +6,7 @@ # IMPORT GENERIC HELPERS #================================================= -#Keep this path for calling _common.sh inside the execution's context of backup and restore scripts +# Keep this path for calling _common.sh inside the execution's context of backup and restore scripts source ../settings/scripts/_common.sh source ../settings/scripts/ynh_install_ruby__2 source ../settings/scripts/ynh_add_swap @@ -25,7 +25,7 @@ ynh_abort_if_errors #================================================= # LOAD SETTINGS #================================================= -ynh_script_progression --message="Loading settings..." +ynh_script_progression --message="Loading installation settings..." app=$YNH_APP_INSTANCE_NAME @@ -51,10 +51,18 @@ test ! -d $final_path \ #================================================= # RESTORE THE NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Restoring the nginx configuration..." +ynh_script_progression --message="Restoring the NGINX web server configuration..." ynh_restore_file --origin_path="/etc/nginx/conf.d/$domain.d/$app.conf" +#================================================= +# RECREATE THE DEDICATED USER +#================================================= +ynh_script_progression --message="Recreating the dedicated system user..." + +# Create the dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # RESTORE THE APP MAIN DIR #================================================= @@ -62,21 +70,9 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -#================================================= -# RECREATE THE DEDICATED USER -#================================================= -ynh_script_progression --message="Recreating the dedicated system user..." - -# Create the dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - -#================================================= -# RESTORE USER RIGHTS -#================================================= -ynh_script_progression --message="Restoring user rights..." - -# Restore permissions on app files -chown -R $app: $final_path +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" #================================================= # SPECIFIC RESTORATION @@ -102,7 +98,7 @@ ynh_add_swap --size=$swap_needed ynh_script_progression --message="Reinstalling dependencies..." ynh_install_nodejs --nodejs_version=$NODEJS_VERSION -ynh_install_app_dependencies $pkg_dependencies +ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" #================================================= @@ -141,9 +137,9 @@ systemctl enable "$app-web" "$app-sidekiq" "$app-streaming" --quiet #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" -yunohost service add "$app-streaming" --description "$app streaming service" +yunohost service add "$app-web" --description="$app web service" +yunohost service add "$app-sidekiq" --description="$app sidekiq service" +yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE diff --git a/scripts/upgrade b/scripts/upgrade index bbbe50b..c2c0819 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -49,7 +49,6 @@ upgrade_type=$(ynh_check_app_version_changed) #================================================= ynh_script_progression --message="Ensuring downward compatibility..." - # Cleaning legacy permissions if ynh_legacy_permissions_exists; then ynh_legacy_permissions_delete_all @@ -124,7 +123,7 @@ ynh_script_progression --message="Backing up the app before upgrading (may take ynh_backup_before_upgrade ynh_clean_setup () { ynh_clean_check_starting - # restore it if the upgrade fails + # Restore it if the upgrade fails ynh_restore_upgradebackup } # Exit if an error occurs during the execution of the script @@ -141,6 +140,14 @@ ynh_systemd_action --service_name=${app}-web --action="stop" --log_path=systemd ynh_systemd_action --service_name=${app}-sidekiq --action="stop" --log_path=systemd --line_match="Stopped" ynh_systemd_action --service_name=${app}-streaming --action="stop" --log_path=systemd --line_match="Stopped" +#================================================= +# CREATE DEDICATED USER +#================================================= +ynh_script_progression --message="Making sure dedicated system user exists..." + +# Create a dedicated user (if not existing) +ynh_system_user_create --username=$app --home_dir="$final_path" + #================================================= # DOWNLOAD, CHECK AND UNPACK SOURCE #================================================= @@ -171,10 +178,14 @@ then ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" fi +chmod 750 "$final_path" +chmod -R o-rwx "$final_path" +chown -R root:$app "$final_path" + #================================================= # NGINX CONFIGURATION #================================================= -ynh_script_progression --message="Upgrading nginx web server configuration..." +ynh_script_progression --message="Upgrading NGINX web server configuration..." # Create a dedicated NGINX config ynh_add_nginx_config 'port_web port_stream' @@ -189,14 +200,6 @@ ynh_install_nodejs --nodejs_version=$NODEJS_VERSION ynh_install_app_dependencies $pkg_dependencies ynh_install_extra_app_dependencies --repo="deb https://dl.yarnpkg.com/debian/ stable main" --package="yarn" --key="https://dl.yarnpkg.com/debian/pubkey.gpg" -#================================================= -# CREATE DEDICATED USER -#================================================= -ynh_script_progression --message="Making sure dedicated system user exists..." - -# Create a dedicated user (if not existing) -ynh_system_user_create --username=$app --home_dir=$final_path - #================================================= # SPECIFIC UPGRADE #================================================= @@ -273,22 +276,14 @@ ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming #================================================= # GENERIC FINALIZATION -#================================================= -# SECURE FILES AND DIRECTORIES -#================================================= -ynh_script_progression --message="Securing files and directories..." - -# Set permissions on app files -chown -R $app: $final_path - #================================================= # INTEGRATE SERVICE IN YUNOHOST #================================================= ynh_script_progression --message="Integrating service in YunoHost..." -yunohost service add "$app-web" --description "$app web service" -yunohost service add "$app-sidekiq" --description "$app sidekiq service" -yunohost service add "$app-streaming" --description "$app streaming service" +yunohost service add "$app-web" --description="$app web service" +yunohost service add "$app-sidekiq" --description="$app sidekiq service" +yunohost service add "$app-streaming" --description="$app streaming service" #================================================= # START SYSTEMD SERVICE @@ -302,7 +297,7 @@ ynh_systemd_action --service_name=${app}-streaming --action="start" --log_path=s #================================================= # RELOAD NGINX #================================================= -ynh_script_progression --message="Reloading nginx web server..." +ynh_script_progression --message="Reloading NGINX web server..." ynh_systemd_action --service_name=nginx --action=reload From f19e49ae9861a93b22640f11437b749a006be2cd Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 10 Apr 2021 20:28:06 +0200 Subject: [PATCH 094/101] Apply example_ynh --- scripts/install | 45 ++++++++++++++++++++++----------------------- scripts/restore | 14 +++++++------- scripts/upgrade | 27 +++++++++++++++------------ 3 files changed, 44 insertions(+), 42 deletions(-) diff --git a/scripts/install b/scripts/install index 91133d3..cf1ccf3 100644 --- a/scripts/install +++ b/scripts/install @@ -154,9 +154,9 @@ pushd "$final_path/live" popd #================================================= -# MODIFY A CONFIG FILE +# ADD A CONFIGURATION #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Adding a config file..." config="$final_path/live/.env.production" @@ -173,18 +173,32 @@ vapid_public_key="" ynh_add_config --template="../conf/.env.production.sample" --destination="$config" +chmod 400 "$config" +chown $app:$app "$config" + ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml" ynh_replace_string --match_string="min_invite_role: 'admin'" --replace_string="min_invite_role: 'none'" --target_file="$final_path/live/config/settings.yml" ynh_store_file_checksum --file="$final_path/live/config/settings.yml" +chmod 400 "$final_path/live/config/settings.yml" +chown $app:$app "$final_path/live/config/settings.yml" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Configuring a systemd service..." + +# Create a dedicated systemd config +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" + #================================================= # INSTALLING MASTODON #================================================= ynh_script_progression --message="Installing Mastodon..." -chown -R "$app": "$final_path" - pushd "$final_path/live" sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true' sudo -u $app $ynh_ruby_load_path bin/bundle config without 'development test' @@ -205,11 +219,14 @@ ynh_app_setting_set --app="$app" --key=vapid_private_key --value="$vapid_private vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K.+" "$final_path/live/key.txt") ynh_app_setting_set --app="$app" --key=vapid_public_key --value="$vapid_public_key" +ynh_secure_remove --file="$final_path/live/key.txt" + ynh_delete_file_checksum --file="$config" ynh_add_config --template="../conf/.env.production.sample" --destination="$config" -ynh_secure_remove --file="$final_path/live/key.txt" +chmod 400 "$config" +chown $app:$app "$config" #================================================= # SETUP THE CRON FILE @@ -218,24 +235,6 @@ ynh_script_progression --message="Setuping the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Configuring a systemd service..." - -# Create a dedicated systemd config -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" - -#================================================= -# STORE THE CONFIG FILE CHECKSUM -#================================================= -ynh_script_progression --message="Storing the config file checksum..." - -# Calculate and store the config file checksum into the app settings -ynh_store_file_checksum --file="$config" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/restore b/scripts/restore index 3e50248..0b389f0 100644 --- a/scripts/restore +++ b/scripts/restore @@ -92,6 +92,13 @@ fi ynh_script_progression --message="Adding $swap_needed Mo to swap..." ynh_add_swap --size=$swap_needed +#================================================= +# RESTORE THE CRON FILE +#================================================= +ynh_script_progression --message="Restoring the cron file..." + +ynh_restore_file --origin_path="/etc/cron.d/$app" + #================================================= # REINSTALL DEPENDENCIES #================================================= @@ -151,13 +158,6 @@ ynh_systemd_action --service_name=${app}-web --action="start" --log_path=systemd 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" -#================================================= -# RESTORE THE CRON FILE -#================================================= -ynh_script_progression --message="Restoring the cron file..." - -ynh_restore_file --origin_path="/etc/cron.d/$app" - #================================================= # GENERIC FINALIZATION #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index b4c16e1..870bd4c 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -230,14 +230,27 @@ pushd "$final_path/live" popd #================================================= -# MODIFY A CONFIG FILE +# UPDATE A CONFIG FILE #================================================= -ynh_script_progression --message="Modifying a config file..." +ynh_script_progression --message="Updating a config file..." language="$(echo $language | head -c 2)" ynh_add_config --template="../conf/.env.production.sample" --destination="$config" +chmod 400 "$config" +chown $app:$app "$config" + +#================================================= +# SETUP SYSTEMD +#================================================= +ynh_script_progression --message="Upgrading systemd configuration..." + +# Create a dedicated systemd config +ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" + #================================================= # UPGRADE MASTODON #================================================= @@ -264,16 +277,6 @@ ynh_script_progression --message="Setuping the cron file..." ynh_add_config --template="../conf/cron" --destination="/etc/cron.d/$app" -#================================================= -# SETUP SYSTEMD -#================================================= -ynh_script_progression --message="Upgrading systemd configuration..." - -# Create a dedicated systemd config -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" - #================================================= # GENERIC FINALIZATION #================================================= From 533654acefffcd052b09a79a8ca53783d73ada6a Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 11 Apr 2021 22:31:48 +0200 Subject: [PATCH 095/101] Fix rights --- scripts/install | 2 +- scripts/remove | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/install b/scripts/install index cf1ccf3..cf972be 100644 --- a/scripts/install +++ b/scripts/install @@ -114,7 +114,7 @@ ynh_setup_source --dest_dir="$final_path/live" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/remove b/scripts/remove index 586bf25..42b0109 100644 --- a/scripts/remove +++ b/scripts/remove @@ -64,7 +64,7 @@ ynh_remove_systemd_config --service="$app-streaming" ynh_script_progression --message="Removing the PostgreSQL database..." # Remove a database if it exists, along with the associated user -ynh_psql_remove_db --db_user="$db_user" --db_name="$db_name" +ynh_psql_remove_db --db_user=$db_user --db_name=$db_name #================================================= # REMOVE DEPENDENCIES diff --git a/scripts/restore b/scripts/restore index 0b389f0..d6d587a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 870bd4c..7122f77 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -180,7 +180,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R root:$app "$final_path" +chown -R $app:$app "$final_path" #================================================= # NGINX CONFIGURATION From 17c2d6b8c4f48f8dff77eb337327ec6421316d52 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Thu, 15 Apr 2021 20:28:26 +0200 Subject: [PATCH 096/101] Fix chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index cf972be..a5e8ba6 100644 --- a/scripts/install +++ b/scripts/install @@ -112,7 +112,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/live" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index d6d587a..e4a48fa 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 7122f77..2300d2e 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,7 @@ then ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" fi -chmod 750 "$final_path" +chmod -R 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 1684f2cf4d04b2a2f138db6b451af95e9f24c842 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:31:31 +0200 Subject: [PATCH 097/101] Fix recursive chmod --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index a5e8ba6..cf972be 100644 --- a/scripts/install +++ b/scripts/install @@ -112,7 +112,7 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path # Download, check integrity, uncompress and patch the source from app.src ynh_setup_source --dest_dir="$final_path/live" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/restore b/scripts/restore index e4a48fa..d6d587a 100644 --- a/scripts/restore +++ b/scripts/restore @@ -70,7 +70,7 @@ ynh_script_progression --message="Restoring the app main directory..." ynh_restore_file --origin_path="$final_path" -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" diff --git a/scripts/upgrade b/scripts/upgrade index 2300d2e..7122f77 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -178,7 +178,7 @@ then ynh_secure_remove --file="$final_path/live/config/initializers/timeout.rb" fi -chmod -R 750 "$final_path" +chmod 750 "$final_path" chmod -R o-rwx "$final_path" chown -R $app:$app "$final_path" From 98be88808aa5faa3251065ec09d844e4d10ee43c Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 18:51:14 +0200 Subject: [PATCH 098/101] Fix rights --- scripts/install | 2 +- scripts/restore | 2 +- scripts/upgrade | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index cf972be..f5da202 100644 --- a/scripts/install +++ b/scripts/install @@ -114,7 +114,7 @@ ynh_setup_source --dest_dir="$final_path/live" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION diff --git a/scripts/restore b/scripts/restore index d6d587a..7a3808b 100644 --- a/scripts/restore +++ b/scripts/restore @@ -72,7 +72,7 @@ ynh_restore_file --origin_path="$final_path" chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # SPECIFIC RESTORATION diff --git a/scripts/upgrade b/scripts/upgrade index 7122f77..86555dc 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -180,7 +180,7 @@ fi chmod 750 "$final_path" chmod -R o-rwx "$final_path" -chown -R $app:$app "$final_path" +chown -R $app:www-data "$final_path" #================================================= # NGINX CONFIGURATION From 1a2446992535ab2ac2676eee87dfc478b44bdceb Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 17 Apr 2021 19:20:13 +0200 Subject: [PATCH 099/101] Fix source --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 6fb011a..37e25d1 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/v3.3.0.tar.gz -SOURCE_SUM=ffbaeaf18d9c440ac61c6c5c29fd6581b88c1d2843170f2cb5f0fcf8dcc0ecd6 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/ca3bc1b09f344f38164aa65d2554cf50d5c10cc0.tar.gz +SOURCE_SUM=bb151900d2e76754b2d1ccb0845ffa834d02c170fc1d87b9458b6c8ced26c4f5 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From a81ad70b6a73814445c3bc7a624154326486ddb0 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Mon, 19 Apr 2021 20:41:16 +0200 Subject: [PATCH 100/101] Update app.src --- conf/app.src | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/app.src b/conf/app.src index 37e25d1..6383dac 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/ca3bc1b09f344f38164aa65d2554cf50d5c10cc0.tar.gz -SOURCE_SUM=bb151900d2e76754b2d1ccb0845ffa834d02c170fc1d87b9458b6c8ced26c4f5 +SOURCE_URL=https://github.com/tootsuite/mastodon/archive/1efcbb9cfe36d4428ef6af988bb0d7b25ace3971.tar.gz +SOURCE_SUM=4ecbfd34ea37d739fbcec11cf9b812e8d8f60f6367f8ce255a062d5d64d92557 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true From 43184e1904eb38dba11fa99be828bdfa736e6300 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Thu, 15 Apr 2021 22:46:03 +0200 Subject: [PATCH 101/101] Glitch it is Fix version --- README.md | 28 ++++++++-------- README_fr.md | 28 ++++++++-------- check_process | 32 ------------------- conf/app.src | 4 +-- ...ekiq.service => glitchsoc-sidekiq.service} | 0 ...ng.service => glitchsoc-streaming.service} | 0 ...odon-web.service => glitchsoc-web.service} | 0 issue_template.md | 4 +-- manifest.json | 8 ++--- scripts/install | 10 +++--- scripts/upgrade | 12 +++---- 11 files changed, 47 insertions(+), 79 deletions(-) rename conf/{mastodon-sidekiq.service => glitchsoc-sidekiq.service} (100%) rename conf/{mastodon-streaming.service => glitchsoc-streaming.service} (100%) rename conf/{mastodon-web.service => glitchsoc-web.service} (100%) diff --git a/README.md b/README.md index a4bd460..9aa9a0a 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ -# Mastodon for YunoHost +# Glich-Soc for YunoHost [![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon) +[![Install Glich-Soc with YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=glitchsoc) *[Lire ce readme en français.](./README_fr.md)* -> *This package allows you to install Mastodon quickly and simply on a YunoHost server. +> *This package allows you to install Glich-Soc quickly and simply on a YunoHost server. If you don't have YunoHost, please consult [the guide](https://yunohost.org/#/install) to learn how to install it.* ## Overview -Mastodon is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. +Glich-Soc is a free, open-source microblogging social network. It is a decentralized alternative to commercial platforms like Twitter and avoids the risks of a single company monopolizing your communication for commercial purposes. **Shipped version:** 3.3.0 ## Important points to read before installing -1. **Mastodon** require a dedicated **root domain**, eg. mastodon.domain.tld -1. The user choosen during the installation is automatically created in Mastodon with admin rights +1. **Glich-Soc** require a dedicated **root domain**, eg. glitchsoc.domain.tld +1. The user choosen during the installation is automatically created in Glich-Soc with admin rights 1. At the end of the installation a mail is sent to the user with the automatically generated password -1. It seems important to close the inscriptions for your Mastodon, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. +1. It seems important to close the inscriptions for your Glich-Soc, so that it remains a private body. We invite you to block remote malicious instances from the administration interface. You can also add text on your home page. ## Screenshots @@ -32,7 +32,7 @@ Mastodon is a free, open-source microblogging social network. It is a decentrali ``` $ sudo apt-get install screen $ screen -$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git +$ sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh.git ``` Recover after disconnect: ``` @@ -44,7 +44,7 @@ $ screen -r #### Using *screen* highly recommended -`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug ` +`$ sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh --debug ` ## Documentation @@ -63,20 +63,20 @@ LDAP authentication is activated. All YunoHost users can authenticate. ## Links - * Report a bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues + * Report a bug: https://github.com/YunoHost-Apps/glitch-soc_ynh/issues * App website: https://joinmastodon.org/ - * Upstream app repository: https://github.com/tootsuite/mastodon + * Upstream app repository: https://github.com/glitch-soc/mastodon * YunoHost website: https://yunohost.org/ --- ## Developer info -Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). +Please send your pull request to the [testing branch](https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing). To try the testing branch, please proceed like that. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug or -sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug ``` diff --git a/README_fr.md b/README_fr.md index 1f1fc84..fd1f776 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,24 +1,24 @@ -# Mastodon pour YunoHost +# Glich-Soc pour YunoHost [![Niveau d'intégration](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.status.svg) ![](https://ci-apps.yunohost.org/ci/badges/mastodon.maintain.svg) -[![Installer Mastodon avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=mastodon) +[![Installer Glich-Soc avec YunoHost](https://install-app.yunohost.org/install-with-yunohost.svg)](https://install-app.yunohost.org/?app=glitchsoc) *[Read this readme in english.](./README.md)* -> *Ce package vous permet d'installer Mastodon rapidement et simplement sur un serveur YunoHost. +> *Ce package vous permet d'installer Glich-Soc rapidement et simplement sur un serveur YunoHost. Si vous n'avez pas YunoHost, consultez [le guide](https://yunohost.org/#/install) pour apprendre comment l'installer.* ## Vue d'ensemble -Mastodon est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Mastodon évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. +Glich-Soc est un réseau social de microblog auto-hébergé et open source. C'est une alternative décentralisée aux plates-formes commerciales comme Twitter. Glich-Soc évite ainsi les risques qu'une seule société monopolise votre communication à des fins commerciales. **Version incluse:** 3.3.0 ## Points importants à lire avant l'installation -1. **Mastodon** nécessite un **nom de domaine** dédié, par exemple : mastodon.domain.tld -1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon avec des droits d'administration. +1. **Glich-Soc** nécessite un **nom de domaine** dédié, par exemple : glitchsoc.domain.tld +1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glich-Soc avec des droits d'administration. 1. À la fin de l'installation, un mail est envoyé à cet utilisateur avec un mot de passe généré automatiquement. -1. Pour que votre instance Mastodon reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances distantes indésirables depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. +1. Pour que votre instance Glich-Soc reste privée, il est important de fermer les inscriptions. Nous vous invitons à bloquer les instances distantes indésirables depuis l'interface d'administration. Vous pouvez également ajouter un texte sur votre page d'accueil dans l'administration. ## Captures d'écran @@ -32,7 +32,7 @@ Mastodon est un réseau social de microblog auto-hébergé et open source. C'est ``` $ sudo apt-get install screen $ screen -$ sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh.git +$ sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh.git ``` Récupérer l'installation après une deconnection : ``` @@ -45,7 +45,7 @@ L'utilisateur admin est créé automatiquement comme : user@domain.tld #### Utilisation de *screen* fortement recommandée -`$ sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh --debug ` +`$ sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh --debug ` ## Documentation @@ -64,20 +64,20 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a ## Liens - * Signaler un bug : https://github.com/YunoHost-Apps/mastodon_ynh/issues + * Signaler un bug : https://github.com/YunoHost-Apps/glitch-soc_ynh/issues * Site de l'application : https://joinmastodon.org/ - * Dépôt de l'application principale : https://github.com/tootsuite/mastodon + * Dépôt de l'application principale : https://github.com/glitch-soc/mastodon * Site web YunoHost : https://yunohost.org/ --- ## Informations pour les développeurs -Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). +Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. ``` -sudo yunohost app install https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +sudo yunohost app install https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug ou -sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +sudo yunohost app upgrade glitchsoc -u https://github.com/YunoHost-Apps/glitch-soc_ynh/tree/testing --debug ``` diff --git a/check_process b/check_process index b0acafe..03f517a 100644 --- a/check_process +++ b/check_process @@ -12,22 +12,6 @@ setup_private=1 setup_public=1 upgrade=1 - # 3.1.2~ynh2 - #upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 - # 3.1.2~ynh3 - #upgrade=1 from_commit=6b30109fc986d83166b1805ec3ad7e28200e3743 - # 3.1.2~ynh4 - upgrade=1 from_commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef - # 3.2.0~ynh1 - upgrade=1 from_commit=bde14cc4496445fdfed4616ac44fc9527c8369fd - # 3.2.1~ynh1 - upgrade=1 from_commit=248b717f373f3c82bdb19c33cf20980494608697 - # 3.2.1~ynh2 - upgrade=1 from_commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 - # 3.2.2~ynh1 - upgrade=1 from_commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c - # 3.3.0~ynh1 - upgrade=1 from_commit=a7eb98db3fac0697b923072dcd78c1ca04bf0a12 backup_restore=1 multi_instance=1 port_already_use=0 @@ -36,19 +20,3 @@ Email=yalh@yahoo.com Notification=all ;;; Upgrade options - ; commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 - name=3.1.2~ynh2 - ; commit=6b30109fc986d83166b1805ec3ad7e28200e3743 - name=3.1.2~ynh3 - ; commit=d3df899e0a99a63ee1cf7ad845cc513aeaaf30ef - name=3.1.2~ynh4 - ; commit=bde14cc4496445fdfed4616ac44fc9527c8369fd - name=3.2.0~ynh1 - ; commit=248b717f373f3c82bdb19c33cf20980494608697 - name=3.2.1~ynh1 - ; commit=74908bf3e70c134bc838c7db3ae8b5aa0938cd75 - name=3.2.1~ynh2 - ; commit=a233ccc644d97aa89756fac9f0ce68c98d81d27c - name=3.2.2~ynh1 - ; commit=a7eb98db3fac0697b923072dcd78c1ca04bf0a12 - name=3.3.0~ynh1 diff --git a/conf/app.src b/conf/app.src index 6383dac..4ac0034 100644 --- a/conf/app.src +++ b/conf/app.src @@ -1,5 +1,5 @@ -SOURCE_URL=https://github.com/tootsuite/mastodon/archive/1efcbb9cfe36d4428ef6af988bb0d7b25ace3971.tar.gz -SOURCE_SUM=4ecbfd34ea37d739fbcec11cf9b812e8d8f60f6367f8ce255a062d5d64d92557 +SOURCE_URL=https://github.com/glitch-soc/mastodon/archive/df326b8b5c0659edb2aca77690a892f228b0e099.tar.gz +SOURCE_SUM=9791bd00b76653908fd0d66533e5b31eecff6759f77794e8b64a4ebe2fe3ae50 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/mastodon-sidekiq.service b/conf/glitchsoc-sidekiq.service similarity index 100% rename from conf/mastodon-sidekiq.service rename to conf/glitchsoc-sidekiq.service diff --git a/conf/mastodon-streaming.service b/conf/glitchsoc-streaming.service similarity index 100% rename from conf/mastodon-streaming.service rename to conf/glitchsoc-streaming.service diff --git a/conf/mastodon-web.service b/conf/glitchsoc-web.service similarity index 100% rename from conf/mastodon-web.service rename to conf/glitchsoc-web.service diff --git a/issue_template.md b/issue_template.md index c6c9254..07fe1ff 100644 --- a/issue_template.md +++ b/issue_template.md @@ -8,7 +8,7 @@ about: When creating a bug report, please use the following template to provide 1. *Read this whole template first.* 2. *Determine if you are on the right place:* - *If you were performing an action on the app from the webadmin or the CLI (install, update, backup, restore, change_url...), you are on the right place!* - - *Otherwise, the issue may be due to Mastodon itself. Refer to its documentation or repository for help.* + - *Otherwise, the issue may be due to Glich-Soc itself. Refer to its documentation or repository for help.* - *When in doubt, post here and we will figure it out together.* 3. *Delete the italic comments as you write over them below, and remove this guide.* --- @@ -31,7 +31,7 @@ about: When creating a bug report, please use the following template to provide - *If you performed a command from the CLI, the command itself is enough. For example:* ```sh - sudo yunohost app install mastodon + sudo yunohost app install glitchsoc ``` - *If you used the webadmin, please perform the equivalent command from the CLI first.* - *If the error occurs in your browser, explain what you did:* diff --git a/manifest.json b/manifest.json index d6aa9f1..1eb1dfe 100644 --- a/manifest.json +++ b/manifest.json @@ -1,13 +1,13 @@ { - "name": "Mastodon", - "id": "mastodon", + "name": "Glich-Soc", + "id": "glitchsoc", "packaging_format": 1, "description": { "en": "A libre and federated social network.", "fr": "Un réseau social libre et fédéré." }, - "version": "3.3.0~ynh2", - "url": "https://github.com/tootsuite/mastodon", + "version": "2021-04-11-ynh2", + "url": "https://github.com/glitch-soc/mastodon", "license": "AGPL-3.0-or-later", "maintainer": { "name": "yalh76" diff --git a/scripts/install b/scripts/install index f5da202..47f636e 100644 --- a/scripts/install +++ b/scripts/install @@ -190,14 +190,14 @@ chown $app:$app "$final_path/live/config/settings.yml" ynh_script_progression --message="Configuring a systemd service..." # Create a dedicated systemd config -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" +ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" #================================================= -# INSTALLING MASTODON +# INSTALLING GLITCH-SOC #================================================= -ynh_script_progression --message="Installing Mastodon..." +ynh_script_progression --message="Installing Glich-Soc..." pushd "$final_path/live" sudo -u $app $ynh_ruby_load_path bin/bundle config deployment 'true' diff --git a/scripts/upgrade b/scripts/upgrade index 86555dc..8fd69e4 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -156,7 +156,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." - # Download Mastodon + # Download Glich-Soc tmpdir="$(mktemp -d)" mkdir $tmpdir/system @@ -247,14 +247,14 @@ chown $app:$app "$config" ynh_script_progression --message="Upgrading systemd configuration..." # Create a dedicated systemd config -ynh_add_systemd_config --service="$app-web" --template="mastodon-web.service" --others_var="port_web RBENV_ROOT" -ynh_add_systemd_config --service="$app-sidekiq" --template="mastodon-sidekiq.service" --others_var="RBENV_ROOT" -ynh_add_systemd_config --service="$app-streaming" --template="mastodon-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" +ynh_add_systemd_config --service="$app-web" --template="glitchsoc-web.service" --others_var="port_web RBENV_ROOT" +ynh_add_systemd_config --service="$app-sidekiq" --template="glitchsoc-sidekiq.service" --others_var="RBENV_ROOT" +ynh_add_systemd_config --service="$app-streaming" --template="glitchsoc-streaming.service" --others_var="port_stream ynh_node_load_PATH ynh_node" #================================================= -# UPGRADE MASTODON +# UPGRADE GLITCH-SOC #================================================= -ynh_script_progression --message="Upgrading Mastodon..." +ynh_script_progression --message="Upgrading Glich-Soc..." chown -R "$app": "$final_path"