From edaa25d408fe5de17ed72db67c5f07ac4f47c7e3 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 13:55:46 +0200 Subject: [PATCH 01/15] Port for Glitch-Soc --- README.md | 38 +++++++----------- README_fr.md | 39 +++++++------------ conf/.env.production.sample | 27 +++++++++++++ conf/app.src | 4 +- conf/cron | 2 +- ...sidekiq.service => glitch-sidekiq.service} | 2 +- ...aming.service => glitch-streaming.service} | 0 ...astodon-web.service => glitch-web.service} | 2 +- manifest.json | 18 +++------ pull_request_template.md | 6 --- scripts/install | 33 +++++++--------- scripts/upgrade | 29 +++++++------- 12 files changed, 95 insertions(+), 105 deletions(-) rename conf/{mastodon-sidekiq.service => glitch-sidekiq.service} (83%) rename conf/{mastodon-streaming.service => glitch-streaming.service} (100%) rename conf/{mastodon-web.service => glitch-web.service} (84%) diff --git a/README.md b/README.md index bd421eb..90509d4 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,21 @@ -# Mastodon for YunoHost - -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) +# Glitch-Soc for YunoHost *[Lire ce readme en français.](./README_fr.md)* -> *This package allow you to install Mastodon quickly and simply on a YunoHost server. +> *This package allow you to install Glitch-Soc 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.* ## 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. +Glitch-Soc 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 Glitch-Soc instance and participate in the social network seamlessly. -**Shipped version:** 3.1.2 +**Shipped version:** 3.1.4 ## 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. **Glitch-Soc** require a dedicated **root domain**, eg. glitch.domain.tld +1. The user choosen during the installation is automatically created in Glitch-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 Glitch-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 +29,7 @@ Mastodon is a free, open-source social network. A decentralized alternative to c ``` $ 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/Tagadda/glitch-soc_ynh.git ``` Recover after disconnect: ``` @@ -44,7 +41,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 glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh --debug ` ## Documentation @@ -56,16 +53,11 @@ $ screen -r 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/) -* 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 - * Report a bug: https://github.com/YunoHost-Apps/mastodon_ynh/issues - * App website: https://joinmastodon.org/ - * Upstream app repository: https://github.com/tootsuite/mastodon + * Report a bug: https://github.com/Tagadda/glitch-soc_ynh/issues + * App website: https://glitch-soc.github.io/docs/ + * Upstream app repository: https://github.com/glitch-soc/mastodon * YunoHost website: https://yunohost.org/ --- @@ -73,11 +65,11 @@ LDAP authentication is activated. All YunoHost users can authenticate. Developers info ---------------- -Please do your pull request to the [testing branch](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). +Please do your pull request to the [testing branch](https://github.com/Tagadda/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/Tagadda/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 glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh/tree/testing --debug ``` diff --git a/README_fr.md b/README_fr.md index ea8fc4f..c4fcede 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,24 +1,21 @@ -# Mastodon pour YunoHost - -[![Integration level](https://dash.yunohost.org/integration/mastodon.svg)](https://dash.yunohost.org/appci/app/mastodon) -[![Install Mastodon with YunoHost](https://install-app.yunohost.org/install-with-yunohost.png)](https://install-app.yunohost.org/?app=mastodon) +# Glitch-Soc pour YunoHost *[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 Glitch-Soc 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. 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. +Glitch-Soc 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 Glitch-Soc et participer au réseau social de façon transparente. **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. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Mastodon avec des droits d'administration. +1. **Glitch-Soc** nécessite un **nom de domaine** dédié, par exemple: glitch.domain.tld +1. L'utilisateur sélectionné pendant l'installation sera créé automatiquement dans Glitch-Soc 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. Il semble important de fermer les inscriptions pour votre Glitch-Soc, 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. ## Captures d'écran @@ -32,7 +29,7 @@ Mastodon est un réseau social gratuit et open source. Une alternative décentra ``` $ 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/Tagadda/glitch-soc_ynh.git ``` Récuperer l'installation après une deconnection: ``` @@ -43,9 +40,9 @@ L'utilisateur admin est crée automatiquement comme: user@domain.tld ### 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 ` +`$ sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh --debug ` ## Documentation @@ -57,16 +54,11 @@ L'utilisateur admin est crée automatiquement comme: user@domain.tld L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier. -#### 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/) -* 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 + * Signaler un bug: https://github.com/Tagadda/glitch-soc_ynh/issues + * Site de l'application: https://glitch-soc.github.io/docs/ + * Dépôt de l'application principale: https://github.com/glitch-soc/mastodon * Site web YunoHost: https://yunohost.org/ --- @@ -74,11 +66,10 @@ L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'a 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/Tagadda/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 -ou -sudo yunohost app upgrade mastodon -u https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing --debug +sudo yunohost app install https://github.com/Tagadda/glitch-soc_ynh/tree/testing +sudo yunohost app upgrade glitch-soc -u https://github.com/Tagadda/glitch-soc_ynh/tree/testing --debug ``` diff --git a/conf/.env.production.sample b/conf/.env.production.sample index d27bf87..3304864 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -261,3 +261,30 @@ LDAP_TLS_NO_VERIFY=true # Only allow federation with whitelisted domains, see # https://docs.joinmastodon.org/admin/config/#whitelist_mode # WHITELIST_MODE=true + +# Glitch-Soc Specifics + +# Maximum allowed character count +# MAX_TOOT_CHARS=500 + +# Maximum number of pinned posts +# MAX_PINNED_TOOTS=5 + +# Maximum allowed bio characters +# MAX_BIO_CHARS=500 + +# Maximim number of profile fields allowed +# MAX_PROFILE_FIELDS=4 + +# Maximum allowed display name characters +# MAX_DISPLAY_NAME_CHARS=30 + +# Maximum image and video/audio upload sizes +# Units are in bytes +# 1048576 bytes equals 1 megabyte +# MAX_IMAGE_SIZE=8388608 +# MAX_VIDEO_SIZE=41943040 + +# Maximum search results to display +# Only relevant when elasticsearch is installed +# MAX_SEARCH_RESULTS=20 diff --git a/conf/app.src b/conf/app.src index fc275ee..c63dd6f 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/glitch-soc/mastodon/archive/b7e178d2e4102bdaa1ea41dfd8ed50093cf3f60a.tar.gz +SOURCE_SUM=ff33ac8a06e8701a21fda86a568e0c1a320419adebb03967102b73bf6b7aa929 SOURCE_SUM_PRG=sha256sum SOURCE_FORMAT=tar.gz SOURCE_IN_SUBDIR=true diff --git a/conf/cron b/conf/cron index 9a984a3..a435084 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 && /opt/rbenv/versions/2.6.6/bin/bundle exec rake __USER__:media:remove_remote diff --git a/conf/mastodon-sidekiq.service b/conf/glitch-sidekiq.service similarity index 83% rename from conf/mastodon-sidekiq.service rename to conf/glitch-sidekiq.service index d5fc7e1..1085e1f 100644 --- a/conf/mastodon-sidekiq.service +++ b/conf/glitch-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=/opt/rbenv/versions/2.6.6/bin/bundle exec sidekiq -c 25 TimeoutSec=15 Restart=always StandardError=syslog diff --git a/conf/mastodon-streaming.service b/conf/glitch-streaming.service similarity index 100% rename from conf/mastodon-streaming.service rename to conf/glitch-streaming.service diff --git a/conf/mastodon-web.service b/conf/glitch-web.service similarity index 84% rename from conf/mastodon-web.service rename to conf/glitch-web.service index bb65afe..234320f 100644 --- a/conf/mastodon-web.service +++ b/conf/glitch-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=/opt/rbenv/versions/2.6.6/bin/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 5925f8f..6be6ec4 100644 --- a/manifest.json +++ b/manifest.json @@ -1,25 +1,17 @@ { - "name": "Mastodon", - "id": "mastodon", + "name": "Glitch-Soc", + "id": "glitch-soc", "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", + "version": "2020-05-14~ynh1", + "url": "https://glitch-soc.github.io/docs/", "license": "AGPL-3.0-or-later", "maintainer": [ { - "name": "cyp", - "email": "cyp@rouquin.me" - }, - { - "name": "nemsia", - "email": "nemsia@nemsia.org" - }, - { - "name": "yalh76" + "name": "Tagada" } ], "requirements": { diff --git a/pull_request_template.md b/pull_request_template.md index 7f09e84..69ce5a0 100644 --- a/pull_request_template.md +++ b/pull_request_template.md @@ -10,9 +10,3 @@ - [ ] Fix or enhancement tested. - [ ] Upgrade from last version tested. - [ ] Can be reviewed and tested. - -## 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)/) diff --git a/scripts/install b/scripts/install index cb059ba..27ca9ec 100644 --- a/scripts/install +++ b/scripts/install @@ -110,9 +110,6 @@ ynh_app_setting_set --app=$app --key=final_path --value=$final_path 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" - #================================================= # NGINX CONFIGURATION #================================================= @@ -153,9 +150,9 @@ 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=2.6.6 +/opt/rbenv/versions/2.6.6/bin/gem update --system +/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document #================================================= # MODIFY A CONFIG FILE @@ -185,20 +182,20 @@ ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" #================================================= -# INSTALLING MASTODON +# INSTALLING Glitch-Soc #================================================= -ynh_script_progression --message="Installing Mastodon..." --weight=2230 +ynh_script_progression --message="Installing Glitch-Soc..." --weight=2230 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 /opt/rbenv/versions/2.6.6/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" 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 /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:setup --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile --quiet + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/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 popd @@ -231,12 +228,12 @@ 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_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_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/glitch-web.service" +ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/glitch-streaming.service" +ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/glitch-streaming.service" +ynh_add_systemd_config --service="$app-web" --template="glitch-web.service" +ynh_add_systemd_config --service="$app-sidekiq" --template="glitch-sidekiq.service" +ynh_add_systemd_config --service="$app-streaming" --template="glitch-streaming.service" #================================================= # STORE THE CONFIG FILE CHECKSUM diff --git a/scripts/upgrade b/scripts/upgrade index 153437b..b0d4931 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -174,7 +174,7 @@ if [ "$upgrade_type" == "UPGRADE_APP" ] then ynh_script_progression --message="Upgrading source files..." --weight=14 - # Download Mastodon + # Download Glitch-Soc tmpdir="$(mktemp -d)" mkdir $tmpdir/system @@ -185,9 +185,6 @@ then 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 @@ -277,19 +274,19 @@ ynh_replace_string "__VAPID_PRIVATE_KEY__" "$vapid_private_key" "$final_p ynh_replace_string "__VAPID_PUBLIC_KEY__" "$vapid_public_key" "$final_path/live/.env.production" #================================================= -# UPGRADE MASTODON +# UPGRADE Glitch-Soc #================================================= -ynh_script_progression --message="Upgrading Mastodon..." --weight=2640 +ynh_script_progression --message="Upgrading Glitch-Soc..." --weight=2640 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 /opt/rbenv/versions/2.6.6/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 /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:migrate + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:clean + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear popd @@ -323,12 +320,12 @@ 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_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_replace_string --match_string="__PORT_WEB__" --replace_string="$port_web" --target_file="../conf/glitch-web.service" +ynh_replace_string --match_string="__PORT_STREAM__" --replace_string="$port_stream" --target_file="../conf/glitch-streaming.service" +ynh_replace_string --match_string="__NODEJS_PATH__" --replace_string="$nodejs_path" --target_file="../conf/glitch-streaming.service" +ynh_add_systemd_config --service="$app-web" --template="glitch-web.service" +ynh_add_systemd_config --service="$app-sidekiq" --template="glitch-sidekiq.service" +ynh_add_systemd_config --service="$app-streaming" --template="glitch-streaming.service" #================================================= # GENERIC FINALIZATION From d4fc18c9368d97aa028be437c6db85ffd0a9d0b7 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 14:01:30 +0200 Subject: [PATCH 02/15] 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 90509d4..0301bfb 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Glitch-Soc for YunoHost +# [WIP] Glitch-Soc pour YunoHost *[Lire ce readme en français.](./README_fr.md)* diff --git a/README_fr.md b/README_fr.md index c4fcede..f7a2c72 100644 --- a/README_fr.md +++ b/README_fr.md @@ -1,4 +1,4 @@ -# Glitch-Soc pour YunoHost +# [WIP] Glitch-Soc pour YunoHost *[Read this readme in english.](./README.md)* From 0ad65572dbecaf945818394a27de948aedd7a55f Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 14:59:41 +0200 Subject: [PATCH 03/15] Remove hyphen --- manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/manifest.json b/manifest.json index 6be6ec4..804210f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "Glitch-Soc", - "id": "glitch-soc", + "id": "glitchsoc", "packaging_format": 1, "description": { "en": "A libre and federated social network.", From 741ac2c651beed01c6ee0da3ac26ceb476e1369c Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 16:08:51 +0200 Subject: [PATCH 04/15] Fix Ruby version --- 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 f064c08..7df5732 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/v20200401.tar.gz +SOURCE_SUM=c67517e8c6b015134b1ae4b19a5a15728054a642fad7223cd28af3ba4cc1828e" > "../conf/ruby-build.src" # Download and extract ruby-build ynh_setup_source "$rbenv_install_dir/plugins/ruby-build" ruby-build From ec93e6d8adde340ff1e4409b42505eda4326faa1 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 17:20:18 +0200 Subject: [PATCH 05/15] Fix Ruby version for upgrade --- scripts/upgrade | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/upgrade b/scripts/upgrade index b0d4931..a022fec 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -244,9 +244,9 @@ 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=2.6.6 +/opt/rbenv/versions/2.6.6/bin/gem update --system +/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document #================================================= # MODIFY A CONFIG FILE From c5cad1d16e63232f9031fec73bc0c059f558bb37 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 17:22:11 +0200 Subject: [PATCH 06/15] Fix Ruby version for restore --- scripts/restore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/restore b/scripts/restore index c6e4bc8..81c242e 100644 --- a/scripts/restore +++ b/scripts/restore @@ -114,9 +114,9 @@ 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=2.6.6 +/opt/rbenv/versions/2.6.6/bin/gem update --system +/opt/rbenv/versions/2.6.6/bin/gem install bundler:1.17.3 --no-document #================================================= # RESTORE THE POSTGRESQL DATABASE From 7b4ca3c45f23df365490f53fbdd0f02caa6d2db8 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Sun, 17 May 2020 20:00:07 +0200 Subject: [PATCH 07/15] Fixes --- check_process | 2 -- scripts/upgrade | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/check_process b/check_process index f5e4602..66a0890 100644 --- a/check_process +++ b/check_process @@ -12,8 +12,6 @@ setup_private=0 setup_public=1 upgrade=1 - # 3.1.2~ynh2 - upgrade=1 from_commit=7e1f4c2dee5f2c8374686aea62f4648cdf2722c3 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/scripts/upgrade b/scripts/upgrade index a022fec..968d19d 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -284,7 +284,7 @@ pushd "$final_path/live" ynh_use_nodejs sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/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.6/bin/bundle exec rails db:migrate + sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:migrate sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:clean sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails assets:precompile sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl cache clear From 977e0648d9452c3a362093f00ee6bf456d4e653a Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 05:31:23 +0200 Subject: [PATCH 08/15] Package linter --- conf/nginx.conf | 12 +- manifest.json | 26 +-- scripts/install | 1 - scripts/remove | 1 - scripts/restore | 1 - scripts/upgrade | 1 - scripts/ynh_add_extra_apt_repos__3 | 294 ----------------------------- 7 files changed, 19 insertions(+), 317 deletions(-) delete mode 100644 scripts/ynh_add_extra_apt_repos__3 diff --git a/conf/nginx.conf b/conf/nginx.conf index 7fa7b87..b2e24bc 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; } diff --git a/manifest.json b/manifest.json index 804210f..0c4b085 100644 --- a/manifest.json +++ b/manifest.json @@ -30,7 +30,7 @@ "en": "Choose a domain for Mastodon", "fr": "Choisissez un domaine pour Mastodon" }, - "example": "example.com" + "example": "example.com" }, { "name": "admin", @@ -39,7 +39,7 @@ "en": "Choose an admin user", "fr": "Choisissez l'administrateur" }, - "example": "johndoe" + "example": "johndoe" }, { "name": "is_public", @@ -50,16 +50,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" + } + ] + } } diff --git a/scripts/install b/scripts/install index 27ca9ec..1985dfb 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_send_readme_to_admin__2 source ynh_add_swap source ynh_check_ram 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 81c242e..129715f 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 968d19d..8e72f4c 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 5a328e76b9539abba71b5d476989bfa9b0303ee0 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 12:46:36 +0200 Subject: [PATCH 09/15] Fix for Yunohost 3.7 --- scripts/install | 1 + scripts/remove | 1 + scripts/restore | 1 + scripts/upgrade | 1 + scripts/ynh_apt | 564 ++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 568 insertions(+) create mode 100644 scripts/ynh_apt diff --git a/scripts/install b/scripts/install index 1985dfb..3338062 100644 --- a/scripts/install +++ b/scripts/install @@ -11,6 +11,7 @@ source ynh_install_ruby__2 source ynh_send_readme_to_admin__2 source ynh_add_swap source ynh_check_ram +source ynh_apt source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/remove b/scripts/remove index d955a8a..61e6a22 100644 --- a/scripts/remove +++ b/scripts/remove @@ -9,6 +9,7 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap +source ynh_apt source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/restore b/scripts/restore index 129715f..9ea3f50 100644 --- a/scripts/restore +++ b/scripts/restore @@ -11,6 +11,7 @@ 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 ../settings/scripts/ynh_apt source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 8e72f4c..c049b3a 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -10,6 +10,7 @@ source _common.sh source ynh_install_ruby__2 source ynh_add_swap source ynh_check_ram +source ynh_apt source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/ynh_apt b/scripts/ynh_apt new file mode 100644 index 0000000..781e2c2 --- /dev/null +++ b/scripts/ynh_apt @@ -0,0 +1,564 @@ +#!/bin/bash + +# Check if apt is free to use, or wait, until timeout. +# +# [internal] +# +# usage: ynh_wait_dpkg_free +# | exit: Return 1 if dpkg is broken +# +# Requires YunoHost version 3.3.1 or higher. +ynh_wait_dpkg_free() { + local try + set +o xtrace # set +x + # With seq 1 17, timeout will be almost 30 minutes + for try in `seq 1 17` + do + # Check if /var/lib/dpkg/lock is used by another process + if lsof /var/lib/dpkg/lock > /dev/null + then + echo "apt is already in use..." + # Sleep an exponential time at each round + sleep $(( try * try )) + else + # Check if dpkg hasn't been interrupted and is fully available. + # See this for more information: https://sources.debian.org/src/apt/1.4.9/apt-pkg/deb/debsystem.cc/#L141-L174 + local dpkg_dir="/var/lib/dpkg/updates/" + + # For each file in $dpkg_dir + while read dpkg_file <&9 + do + # Check if the name of this file contains only numbers. + if echo "$dpkg_file" | grep --perl-regexp --quiet "^[[:digit:]]+$" + then + # If so, that a remaining of dpkg. + ynh_print_err "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem." + set -o xtrace # set -x + return 1 + fi + done 9<<< "$(ls -1 $dpkg_dir)" + set -o xtrace # set -x + return 0 + fi + done + echo "apt still used, but timeout reached !" + set -o xtrace # set -x +} + +# Check either a package is installed or not +# +# example: ynh_package_is_installed --package=yunohost && echo "ok" +# +# usage: ynh_package_is_installed --package=name +# | arg: -p, --package= - the package name to check +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_is_installed() { + # Declare an array to define the options of this helper. + local legacy_args=p + local -A args_array=( [p]=package= ) + local package + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + ynh_wait_dpkg_free + dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \ + | grep --count "ok installed" &>/dev/null +} + +# Get the version of an installed package +# +# example: version=$(ynh_package_version --package=yunohost) +# +# usage: ynh_package_version --package=name +# | arg: -p, --package= - the package name to get version +# | ret: the version or an empty string +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_version() { + # Declare an array to define the options of this helper. + local legacy_args=p + local -A args_array=( [p]=package= ) + local package + # Manage arguments with getopts + ynh_handle_getopts_args "$@" + + if ynh_package_is_installed "$package" + then + dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null + else + echo '' + fi +} + +# APT wrapper for non-interactive operation +# +# [internal] +# +# usage: ynh_apt update +# +# Requires YunoHost version 2.4.0.3 or higher. +ynh_apt() { + ynh_wait_dpkg_free + LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get --assume-yes --quiet -o=Dpkg::Use-Pty=0 $@ +} + +# Update package index files +# +# usage: ynh_package_update +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_update() { + ynh_apt update +} + +# Install package(s) +# +# usage: ynh_package_install name [name [...]] +# | arg: name - the package name to install +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_install() { + ynh_apt --no-remove --option Dpkg::Options::=--force-confdef \ + --option Dpkg::Options::=--force-confold install $@ +} + +# Remove package(s) +# +# usage: ynh_package_remove name [name [...]] +# | arg: name - the package name to remove +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_remove() { + ynh_apt remove $@ +} + +# Remove package(s) and their uneeded dependencies +# +# usage: ynh_package_autoremove name [name [...]] +# | arg: name - the package name to remove +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_autoremove() { + ynh_apt autoremove $@ +} + +# Purge package(s) and their uneeded dependencies +# +# usage: ynh_package_autopurge name [name [...]] +# | arg: name - the package name to autoremove and purge +# +# Requires YunoHost version 2.7.2 or higher. +ynh_package_autopurge() { + ynh_apt autoremove --purge $@ +} + +# Build and install a package from an equivs control file +# +# [internal] +# +# example: generate an empty control file with `equivs-control`, adjust its +# content and use helper to build and install the package: +# ynh_package_install_from_equivs /path/to/controlfile +# +# usage: ynh_package_install_from_equivs controlfile +# | arg: controlfile - path of the equivs control file +# +# Requires YunoHost version 2.2.4 or higher. +ynh_package_install_from_equivs () { + local controlfile=$1 + + # retrieve package information + local pkgname=$(grep '^Package: ' $controlfile | cut --delimiter=' ' --fields=2) # Retrieve the name of the debian package + local pkgversion=$(grep '^Version: ' $controlfile | cut --delimiter=' ' --fields=2) # And its version number + [[ -z "$pkgname" || -z "$pkgversion" ]] \ + && ynh_die --message="Invalid control file" # Check if this 2 variables aren't empty. + + # Update packages cache + ynh_package_update + + # Build and install the package + local TMPDIR=$(mktemp --directory) + + # Force the compatibility level at 10, levels below are deprecated + echo 10 > /usr/share/equivs/template/debian/compat + + # Note that the cd executes into a sub shell + # Create a fake deb package with equivs-build and the given control file + # Install the fake package without its dependencies with dpkg + # Install missing dependencies with ynh_package_install + ynh_wait_dpkg_free + cp "$controlfile" "${TMPDIR}/control" + (cd "$TMPDIR" + LC_ALL=C equivs-build ./control 1> /dev/null + dpkg --force-depends --install "./${pkgname}_${pkgversion}_all.deb" 2>&1) + + ynh_package_install --fix-broken || \ + { # If the installation failed + # (the following is ran inside { } to not start a subshell otherwise ynh_die wouldnt exit the original process) + # Get the list of dependencies from the deb + local dependencies="$(dpkg --info "$TMPDIR/${pkgname}_${pkgversion}_all.deb" | grep Depends | \ + sed 's/^ Depends: //' | sed 's/,//g')" + # Fake an install of those dependencies to see the errors + # The sed command here is, Print only from '--fix-broken' to the end. + ynh_package_install $dependencies --dry-run | sed --quiet '/--fix-broken/,$p' >&2 + ynh_die --message="Unable to install dependencies"; } + [[ -n "$TMPDIR" ]] && rm --recursive --force $TMPDIR # Remove the temp dir. + + # check if the package is actually installed + ynh_package_is_installed "$pkgname" +} + +# Define and install dependencies with a equivs control file +# +# This helper can/should only be called once per app +# +# example : ynh_install_app_dependencies dep1 dep2 "dep3|dep4|dep5" +# +# usage: ynh_install_app_dependencies dep [dep [...]] +# | arg: dep - the package name to install in dependence. Writing "dep3|dep4|dep5" can be used to specify alternatives. For example : dep1 dep2 "dep3|dep4|dep5" will require to install dep1 and dep 2 and (dep3 or dep4 or dep5). +# +# Requires YunoHost version 2.6.4 or higher. +ynh_install_app_dependencies () { + local dependencies=$@ + # Add a comma for each space between packages. But not add a comma if the space separate a version specification. (See below) + dependencies="$(echo "$dependencies" | sed 's/\([^\<=\>]\)\ \([^(]\)/\1, \2/g')" + local 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 --delimiter='"' --fields=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 + + # + # Epic ugly hack to fix the goddamn dependency nightmare of sury + # Sponsored by the "Djeezusse Fokin Kraiste Why Do Adminsys Has To Be So Fucking Complicated I Should Go Grow Potatoes Instead Of This Shit" collective + # https://github.com/YunoHost/issues/issues/1407 + # + # If we require to install php dependency + if echo $dependencies | grep --quiet 'php' + then + # And we have packages from sury installed (7.0.33-10+weirdshiftafter instead of 7.0.33-0 on debian) + if dpkg --list | grep "php7.0" | grep --quiet --invert-match "7.0.33-0+deb9" + then + # And sury ain't already installed + if ! grep --line-number --recursive --quiet "sury" /etc/apt/sources.list* + then + # Re-add sury + ynh_install_extra_repo --repo="https://packages.sury.org/php/ $(ynh_get_debian_release) main" --key="https://packages.sury.org/php/apt.gpg" --name=extra_php_version + + # Pin this sury repository to prevent sury of doing shit + ynh_pin_repo --package="*" --pin="origin \"packages.sury.org\"" --priority=200 --name=extra_php_version + ynh_pin_repo --package="php${YNH_DEFAULT_PHP_VERSION}*" --pin="origin \"packages.sury.org\"" --priority=600 --name=extra_php_version --append + fi + fi + 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" +} + +# Add dependencies to install with ynh_install_app_dependencies +# +# usage: ynh_add_app_dependencies --package=phpversion [--replace] +# | arg: -p, --package= - Packages to add as dependencies for the app. +# | arg: -r, --replace - Replace dependencies instead of adding to existing ones. +# +# Requires YunoHost version 3.8.1 or higher. +ynh_add_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=pr + local -A 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}" +} + +# Remove fake package and its dependencies +# +# Dependencies will removed only if no other package need them. +# +# usage: ynh_remove_app_dependencies +# +# Requires YunoHost version 2.6.4 or higher. +ynh_remove_app_dependencies () { + local dep_app=${app//_/-} # Replace all '_' by '-' + ynh_package_autopurge ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used. +} + +#================================================= + +# 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. +# +# Requires YunoHost version 3.8.1 or higher. +ynh_install_extra_app_dependencies () { + # Declare an array to define the options of this helper. + local legacy_args=rpkn + local -A 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:-} + + # 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 +} + +# Add an extra repository correctly, pin it and get the key. +# +# [internal] +# +# 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. +# +# Requires YunoHost version 3.8.1 or higher. +ynh_install_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=rkpna + local -A 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:-} + priority=${priority:-} + + if [ $append -eq 1 ] + then + append="--append" + wget_append="tee --append" + 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 --parents "/etc/apt/trusted.gpg.d" + # Timeout option is here to enforce the timeout on dns query and tcp connect (c.f. man wget) + wget --timeout 900 --quiet "$key" --output-document=- | 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. +# +# [internal] +# +# usage: ynh_remove_extra_repo [--name=name] +# | arg: -n, --name= - Name for the files for this repo, $app as default value. +# +# Requires YunoHost version 3.8.1 or higher. +ynh_remove_extra_repo () { + # Declare an array to define the options of this helper. + local legacy_args=n + local -A 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 +} + +# Add a repository. +# +# [internal] +# +# 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 +# +# Requires YunoHost version 3.8.1 or higher. +ynh_add_repo () { + # Declare an array to define the options of this helper. + local legacy_args=uscna + local -A 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 --append" + else + append="tee" + fi + + mkdir --parents "/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" +} + +# Pin a repository. +# +# [internal] +# +# 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#How_APT_Interprets_Priorities for information about pinning. +# +# Requires YunoHost version 3.8.1 or higher. +ynh_pin_repo () { + # Declare an array to define the options of this helper. + local legacy_args=pirna + local -A 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 --append" + else + append="tee" + fi + + mkdir --parents "/etc/apt/preferences.d" + echo "Package: $package +Pin: $pin +Pin-Priority: $priority +" \ + | $append "/etc/apt/preferences.d/$name" +} + From 5992628513d1c58928f24a8d9170ea3d3a3953f9 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 20:09:37 +0200 Subject: [PATCH 10/15] cleanup warnings --- scripts/install | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/install b/scripts/install index 3338062..a231391 100644 --- a/scripts/install +++ b/scripts/install @@ -8,7 +8,6 @@ source _common.sh source ynh_install_ruby__2 -source ynh_send_readme_to_admin__2 source ynh_add_swap source ynh_check_ram source ynh_apt @@ -181,6 +180,8 @@ 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="$final_path/live/.env.production" ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" +ynh_replace_string --match_string="dev.glitch.social" --replace_string="$domain" --target_file="$final_path/live/config/settings.yml" + #================================================= # INSTALLING Glitch-Soc #================================================= @@ -190,7 +191,9 @@ chown -R "$app": "$final_path" pushd "$final_path/live" ynh_use_nodejs - sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) --deployment --without development test + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle config deployment 'true' + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle config without 'development test' + sudo -u "$app" env PATH=$PATH /opt/rbenv/versions/2.6.6/bin/bundle install -j$(getconf _NPROCESSORS_ONLN) sudo -u "$app" env PATH=$PATH yarn install --pure-lockfile sudo -u "$app" echo "SAFETY_ASSURED=1">> .env.production sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.6/bin/bundle exec rails db:setup --quiet From f21c307d28a8c2fb1cea05f38bb0f0fc6549a7da Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 20:09:49 +0200 Subject: [PATCH 11/15] fix multi-instance nginx.conf --- conf/nginx.conf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/conf/nginx.conf b/conf/nginx.conf index b2e24bc..19230c6 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 5738aff5c61df6c9328a5e2f1907791df4508987 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 20:10:06 +0200 Subject: [PATCH 12/15] Fix redis installation --- scripts/_common.sh | 2 +- scripts/install | 7 +++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/scripts/_common.sh b/scripts/_common.sh index 015c1e9..22b8482 100644 --- a/scripts/_common.sh +++ b/scripts/_common.sh @@ -5,7 +5,7 @@ #================================================= # 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" +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 postgresql postgresql-contrib libidn11-dev libicu-dev libjemalloc-dev curl apt-transport-https" #================================================= # PERSONAL HELPERS diff --git a/scripts/install b/scripts/install index a231391..0df19ed 100644 --- a/scripts/install +++ b/scripts/install @@ -84,6 +84,13 @@ ynh_install_nodejs --nodejs_version="10" 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" +# Get Redis >= 4.0 +if [ "$(lsb_release --codename --short)" = "buster" ]; then + ynh_install_app_dependencies "redis-server redis-tools" +else + ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian stretch-backports main" --package="redis-server redis-tools" +end + #================================================= # CREATE A POSTGRESQL DATABASE #================================================= From 1b55c4b8ec62db084fb494c7936551753c5be2df Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 22:22:28 +0200 Subject: [PATCH 13/15] Please package_linter about helpers --- scripts/ynh_apt | 221 ------------------------------------------------ 1 file changed, 221 deletions(-) diff --git a/scripts/ynh_apt b/scripts/ynh_apt index 781e2c2..9b0b4ad 100644 --- a/scripts/ynh_apt +++ b/scripts/ynh_apt @@ -1,214 +1,5 @@ #!/bin/bash -# Check if apt is free to use, or wait, until timeout. -# -# [internal] -# -# usage: ynh_wait_dpkg_free -# | exit: Return 1 if dpkg is broken -# -# Requires YunoHost version 3.3.1 or higher. -ynh_wait_dpkg_free() { - local try - set +o xtrace # set +x - # With seq 1 17, timeout will be almost 30 minutes - for try in `seq 1 17` - do - # Check if /var/lib/dpkg/lock is used by another process - if lsof /var/lib/dpkg/lock > /dev/null - then - echo "apt is already in use..." - # Sleep an exponential time at each round - sleep $(( try * try )) - else - # Check if dpkg hasn't been interrupted and is fully available. - # See this for more information: https://sources.debian.org/src/apt/1.4.9/apt-pkg/deb/debsystem.cc/#L141-L174 - local dpkg_dir="/var/lib/dpkg/updates/" - - # For each file in $dpkg_dir - while read dpkg_file <&9 - do - # Check if the name of this file contains only numbers. - if echo "$dpkg_file" | grep --perl-regexp --quiet "^[[:digit:]]+$" - then - # If so, that a remaining of dpkg. - ynh_print_err "E: dpkg was interrupted, you must manually run 'sudo dpkg --configure -a' to correct the problem." - set -o xtrace # set -x - return 1 - fi - done 9<<< "$(ls -1 $dpkg_dir)" - set -o xtrace # set -x - return 0 - fi - done - echo "apt still used, but timeout reached !" - set -o xtrace # set -x -} - -# Check either a package is installed or not -# -# example: ynh_package_is_installed --package=yunohost && echo "ok" -# -# usage: ynh_package_is_installed --package=name -# | arg: -p, --package= - the package name to check -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_is_installed() { - # Declare an array to define the options of this helper. - local legacy_args=p - local -A args_array=( [p]=package= ) - local package - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - ynh_wait_dpkg_free - dpkg-query --show --showformat='${Status}' "$package" 2>/dev/null \ - | grep --count "ok installed" &>/dev/null -} - -# Get the version of an installed package -# -# example: version=$(ynh_package_version --package=yunohost) -# -# usage: ynh_package_version --package=name -# | arg: -p, --package= - the package name to get version -# | ret: the version or an empty string -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_version() { - # Declare an array to define the options of this helper. - local legacy_args=p - local -A args_array=( [p]=package= ) - local package - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - - if ynh_package_is_installed "$package" - then - dpkg-query --show --showformat='${Version}' "$package" 2>/dev/null - else - echo '' - fi -} - -# APT wrapper for non-interactive operation -# -# [internal] -# -# usage: ynh_apt update -# -# Requires YunoHost version 2.4.0.3 or higher. -ynh_apt() { - ynh_wait_dpkg_free - LC_ALL=C DEBIAN_FRONTEND=noninteractive apt-get --assume-yes --quiet -o=Dpkg::Use-Pty=0 $@ -} - -# Update package index files -# -# usage: ynh_package_update -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_update() { - ynh_apt update -} - -# Install package(s) -# -# usage: ynh_package_install name [name [...]] -# | arg: name - the package name to install -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_install() { - ynh_apt --no-remove --option Dpkg::Options::=--force-confdef \ - --option Dpkg::Options::=--force-confold install $@ -} - -# Remove package(s) -# -# usage: ynh_package_remove name [name [...]] -# | arg: name - the package name to remove -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_remove() { - ynh_apt remove $@ -} - -# Remove package(s) and their uneeded dependencies -# -# usage: ynh_package_autoremove name [name [...]] -# | arg: name - the package name to remove -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_autoremove() { - ynh_apt autoremove $@ -} - -# Purge package(s) and their uneeded dependencies -# -# usage: ynh_package_autopurge name [name [...]] -# | arg: name - the package name to autoremove and purge -# -# Requires YunoHost version 2.7.2 or higher. -ynh_package_autopurge() { - ynh_apt autoremove --purge $@ -} - -# Build and install a package from an equivs control file -# -# [internal] -# -# example: generate an empty control file with `equivs-control`, adjust its -# content and use helper to build and install the package: -# ynh_package_install_from_equivs /path/to/controlfile -# -# usage: ynh_package_install_from_equivs controlfile -# | arg: controlfile - path of the equivs control file -# -# Requires YunoHost version 2.2.4 or higher. -ynh_package_install_from_equivs () { - local controlfile=$1 - - # retrieve package information - local pkgname=$(grep '^Package: ' $controlfile | cut --delimiter=' ' --fields=2) # Retrieve the name of the debian package - local pkgversion=$(grep '^Version: ' $controlfile | cut --delimiter=' ' --fields=2) # And its version number - [[ -z "$pkgname" || -z "$pkgversion" ]] \ - && ynh_die --message="Invalid control file" # Check if this 2 variables aren't empty. - - # Update packages cache - ynh_package_update - - # Build and install the package - local TMPDIR=$(mktemp --directory) - - # Force the compatibility level at 10, levels below are deprecated - echo 10 > /usr/share/equivs/template/debian/compat - - # Note that the cd executes into a sub shell - # Create a fake deb package with equivs-build and the given control file - # Install the fake package without its dependencies with dpkg - # Install missing dependencies with ynh_package_install - ynh_wait_dpkg_free - cp "$controlfile" "${TMPDIR}/control" - (cd "$TMPDIR" - LC_ALL=C equivs-build ./control 1> /dev/null - dpkg --force-depends --install "./${pkgname}_${pkgversion}_all.deb" 2>&1) - - ynh_package_install --fix-broken || \ - { # If the installation failed - # (the following is ran inside { } to not start a subshell otherwise ynh_die wouldnt exit the original process) - # Get the list of dependencies from the deb - local dependencies="$(dpkg --info "$TMPDIR/${pkgname}_${pkgversion}_all.deb" | grep Depends | \ - sed 's/^ Depends: //' | sed 's/,//g')" - # Fake an install of those dependencies to see the errors - # The sed command here is, Print only from '--fix-broken' to the end. - ynh_package_install $dependencies --dry-run | sed --quiet '/--fix-broken/,$p' >&2 - ynh_die --message="Unable to install dependencies"; } - [[ -n "$TMPDIR" ]] && rm --recursive --force $TMPDIR # Remove the temp dir. - - # check if the package is actually installed - ynh_package_is_installed "$pkgname" -} - # Define and install dependencies with a equivs control file # # This helper can/should only be called once per app @@ -321,18 +112,6 @@ ynh_add_app_dependencies () { ynh_install_app_dependencies "${current_dependencies}${package}" } -# Remove fake package and its dependencies -# -# Dependencies will removed only if no other package need them. -# -# usage: ynh_remove_app_dependencies -# -# Requires YunoHost version 2.6.4 or higher. -ynh_remove_app_dependencies () { - local dep_app=${app//_/-} # Replace all '_' by '-' - ynh_package_autopurge ${dep_app}-ynh-deps # Remove the fake package and its dependencies if they not still used. -} - #================================================= # Install packages from an extra repository properly. From 5d0f05cc50f0fcf562126d8a6533bc57a9915301 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 22:23:07 +0200 Subject: [PATCH 14/15] this is freaking wip let me push please --- manifest.json | 124 ++++++++++++++++++++++++------------------------ scripts/install | 8 ++-- scripts/upgrade | 2 +- 3 files changed, 68 insertions(+), 66 deletions(-) diff --git a/manifest.json b/manifest.json index 0c4b085..a8e9d34 100644 --- a/manifest.json +++ b/manifest.json @@ -1,65 +1,65 @@ { - "name": "Glitch-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": "2020-05-14~ynh1", - "url": "https://glitch-soc.github.io/docs/", - "license": "AGPL-3.0-or-later", - "maintainer": [ - { - "name": "Tagada" - } - ], - "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" - }, - "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 - }, - { - "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" - } - ] + "name": "Glitch-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": "2020-05-14~ynh1", + "url": "https://glitch-soc.github.io/docs/", + "license": "AGPL-3.0-or-later", + "maintainer": [ + { + "name": "Tagada" } + ], + "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" + }, + "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 + }, + { + "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" + } + ] + } } diff --git a/scripts/install b/scripts/install index 0df19ed..768bcb6 100644 --- a/scripts/install +++ b/scripts/install @@ -81,15 +81,16 @@ 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_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" # Get Redis >= 4.0 if [ "$(lsb_release --codename --short)" = "buster" ]; then - ynh_install_app_dependencies "redis-server redis-tools" + ynh_add_app_dependencies "redis-server redis-tools" else ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian stretch-backports main" --package="redis-server redis-tools" end + +ynh_install_app_dependencies $pkg_dependencies #================================================= # CREATE A POSTGRESQL DATABASE @@ -188,6 +189,7 @@ ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" ynh_replace_string --match_string="dev.glitch.social" --replace_string="$domain" --target_file="$final_path/live/config/settings.yml" +ynh_replace_string --match_string="registrations_mode: 'open'" --replace_string="registrations_mode: 'none'" --target_file="$final_path/live/config/settings.yml" #================================================= # INSTALLING Glitch-Soc @@ -230,7 +232,7 @@ 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 +cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD diff --git a/scripts/upgrade b/scripts/upgrade index c049b3a..95181af 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -312,7 +312,7 @@ 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 +cp -f ../conf/cron /etc/cron.d/$app #================================================= # SETUP SYSTEMD From ca37006e9b16d6ad799533f54cb83bf8b6435857 Mon Sep 17 00:00:00 2001 From: Tagada <36127788+Tagadda@users.noreply.github.com> Date: Mon, 18 May 2020 22:30:23 +0200 Subject: [PATCH 15/15] I don't do bash... okey ? --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 768bcb6..4a03394 100644 --- a/scripts/install +++ b/scripts/install @@ -88,7 +88,7 @@ if [ "$(lsb_release --codename --short)" = "buster" ]; then ynh_add_app_dependencies "redis-server redis-tools" else ynh_install_extra_app_dependencies --repo="deb http://deb.debian.org/debian stretch-backports main" --package="redis-server redis-tools" -end +fi ynh_install_app_dependencies $pkg_dependencies