From feab0450d821b21cdc8a8fc0ee9ae9b1e9913d33 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Wed, 10 Jul 2019 01:07:32 +0200 Subject: [PATCH 01/10] Implement LDAP --- conf/.env.production.sample | 18 +++++++++--------- scripts/install | 15 +++++++++++++++ scripts/remove | 8 ++++++++ scripts/restore | 9 +++++++++ scripts/upgrade | 16 ++++++++++++++++ 5 files changed, 57 insertions(+), 9 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 203b74b..a444ae2 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -155,15 +155,15 @@ STREAMING_CLUSTER_NUM=1 # GID=1000 # LDAP authentication (optional) -# LDAP_ENABLED=true -# LDAP_HOST=localhost -# LDAP_PORT=389 -# LDAP_METHOD=simple_tls -# LDAP_BASE=ou=users,dc=yunohost,dc=org -# LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org -# LDAP_PASSWORD=__LDAP_PASSWORD__ -# LDAP_UID=uid -# LDAP_SEARCH_FILTER="%{uid}=%{email}" +LDAP_ENABLED=true +LDAP_HOST=localhost +LDAP_PORT=389 +LDAP_METHOD=simple_tls +LDAP_BASE=ou=users,dc=yunohost,dc=org +LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org +LDAP_PASSWORD=__LDAP_PASSWORD__ +LDAP_UID=uid +LDAP_SEARCH_FILTER="%{uid}=%{email}" # PAM authentication (optional) # PAM authentication uses for the email generation the "email" pam variable diff --git a/scripts/install b/scripts/install index 0991cbc..97bbc0b 100644 --- a/scripts/install +++ b/scripts/install @@ -36,6 +36,9 @@ admin_mail=$(ynh_user_get_info $admin 'mail') app=$YNH_APP_INSTANCE_NAME +ldap_user="svc_${app}_ldap" +ldap_password=$(ynh_string_random --length=8) + #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -68,6 +71,8 @@ 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 +ynh_app_setting_set --app=$app --key=ldap_user --value=$ldap_user +ynh_app_setting_set --app=$app --key=ldap_password --value=$ldap_password #================================================= # STANDARD MODIFICATIONS @@ -134,6 +139,13 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP +#================================================= +# CREATING LDAP USER +#================================================= +ynh_script_progression --message="Creating LDAP user..." --weight=424 + +yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 + #================================================= # INSTALLING RUBY AND BUNDLER #================================================= @@ -170,6 +182,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="$final_path/live/.env.production" ynh_app_setting_set --app="$app" --key=otp_secret --value="$otp_secret" +ynh_replace_string --match_string="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production" + #================================================= # INSTALLING MASTODON #================================================= diff --git a/scripts/remove b/scripts/remove index 19cbf29..cbbae0b 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,6 +22,7 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$app final_path=$(ynh_app_setting_get --app=$app --key=final_path) +ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) #================================================= # STANDARD REMOVE @@ -95,6 +96,13 @@ ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE +#================================================= +# REMOVE LDAP USER +#================================================= +ynh_script_progression --message="Removing ldap user..." --weight=2 + +yunohost user delete $ldap_user --purge + #================================================= # REMOVE THE CRON FILE #================================================= diff --git a/scripts/restore b/scripts/restore index 59e71fc..89e2430 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,6 +35,8 @@ 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_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) +ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) +ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -89,6 +91,13 @@ ynh_install_nodejs --nodejs_version="8" 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" +#================================================= +# CREATING LDAP USER +#================================================= +ynh_script_progression --message="Creating LDAP user..." --weight=424 + +yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 + #================================================= # INSTALLING RUBY AND BUNDLER #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index 46e7229..fe6f331 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,6 +37,9 @@ 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) +ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) +ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password) + #================================================= # CHECK VERSION #================================================= @@ -122,6 +125,16 @@ if [[ -z "$vapid_private_key" ]]; then ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" fi +# If ldap_user doesn't exist, retrieve it or create it +if [[ -z "$ldap_user" ]]; then + ldap_user="svc_${app}_ldap" + ldap_password==$(ynh_string_random --length=8) + ynh_app_setting_set "$app" ldap_user "$ldap_user" + ynh_app_setting_set "$app" ldap_password "$ldap_password" + + yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 +fi + #Remove previous added repository ynh_remove_extra_repo @@ -239,6 +252,9 @@ ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret 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="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production" +ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production" + #================================================= # UPGRADE MASTODON #================================================= From 0cfabd36526029d3e2ec2d9ed4c33e603b341884 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Jul 2019 10:51:01 +0200 Subject: [PATCH 02/10] Update .env.production.sample --- conf/.env.production.sample | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index a444ae2..610425c 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -158,12 +158,13 @@ STREAMING_CLUSTER_NUM=1 LDAP_ENABLED=true LDAP_HOST=localhost LDAP_PORT=389 -LDAP_METHOD=simple_tls +LDAP_METHOD=start_tls LDAP_BASE=ou=users,dc=yunohost,dc=org LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org LDAP_PASSWORD=__LDAP_PASSWORD__ LDAP_UID=uid LDAP_SEARCH_FILTER="%{uid}=%{email}" +LDAP_TLS_NO_VERIFY=true # PAM authentication (optional) # PAM authentication uses for the email generation the "email" pam variable From 6c7a10d5c3e97751d105b30de3d7c0f5ff5d4e88 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sat, 13 Jul 2019 15:27:08 +0200 Subject: [PATCH 03/10] Update README --- README.md | 1 - README_fr.md | 1 - 2 files changed, 2 deletions(-) diff --git a/README.md b/README.md index 27dac5f..01c6a8f 100644 --- a/README.md +++ b/README.md @@ -86,7 +86,6 @@ It seems important to close the inscriptions for your Mastodon, so that it remai Developers info ---------------- -**Only if you want to use a testing branch for coding, instead of merging directly into master.** Please do 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 8dfda3d..ad2280e 100644 --- a/README_fr.md +++ b/README_fr.md @@ -85,7 +85,6 @@ Il semble important de fermer les inscriptions pour votre Mastodon, pour que à Informations pour les développeurs ---------------- -**Seulement si vous voulez utiliser une branche de test pour le codage, au lieu de fusionner directement dans la banche principale.** Merci de faire vos pull request sur la [branche testing](https://github.com/YunoHost-Apps/mastodon_ynh/tree/testing). Pour essayer la branche testing, procédez comme suit. From 6f5fec437c9874e289cbd0f68b0e109e02cbccdf Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 00:31:07 +0200 Subject: [PATCH 04/10] removing dedicated ldap user creation --- conf/.env.production.sample | 4 ++-- scripts/install | 15 --------------- scripts/remove | 8 -------- scripts/restore | 9 --------- scripts/upgrade | 16 ---------------- 5 files changed, 2 insertions(+), 50 deletions(-) diff --git a/conf/.env.production.sample b/conf/.env.production.sample index 610425c..33f7d93 100644 --- a/conf/.env.production.sample +++ b/conf/.env.production.sample @@ -160,8 +160,8 @@ LDAP_HOST=localhost LDAP_PORT=389 LDAP_METHOD=start_tls LDAP_BASE=ou=users,dc=yunohost,dc=org -LDAP_BIND_DN=uid=__LDAP_USER__,ou=users,dc=yunohost,dc=org -LDAP_PASSWORD=__LDAP_PASSWORD__ +LDAP_BIND_DN=uid=uid=local,ou=users,dc=yunohost,dc=org +LDAP_PASSWORD= LDAP_UID=uid LDAP_SEARCH_FILTER="%{uid}=%{email}" LDAP_TLS_NO_VERIFY=true diff --git a/scripts/install b/scripts/install index 97bbc0b..0991cbc 100644 --- a/scripts/install +++ b/scripts/install @@ -36,9 +36,6 @@ admin_mail=$(ynh_user_get_info $admin 'mail') app=$YNH_APP_INSTANCE_NAME -ldap_user="svc_${app}_ldap" -ldap_password=$(ynh_string_random --length=8) - #================================================= # CHECK IF THE APP CAN BE INSTALLED WITH THESE ARGS #================================================= @@ -71,8 +68,6 @@ 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 -ynh_app_setting_set --app=$app --key=ldap_user --value=$ldap_user -ynh_app_setting_set --app=$app --key=ldap_password --value=$ldap_password #================================================= # STANDARD MODIFICATIONS @@ -139,13 +134,6 @@ ynh_system_user_create --username=$app --home_dir=$final_path #================================================= # SPECIFIC SETUP -#================================================= -# CREATING LDAP USER -#================================================= -ynh_script_progression --message="Creating LDAP user..." --weight=424 - -yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 - #================================================= # INSTALLING RUBY AND BUNDLER #================================================= @@ -182,9 +170,6 @@ 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="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production" - #================================================= # INSTALLING MASTODON #================================================= diff --git a/scripts/remove b/scripts/remove index cbbae0b..19cbf29 100644 --- a/scripts/remove +++ b/scripts/remove @@ -22,7 +22,6 @@ domain=$(ynh_app_setting_get --app=$app --key=domain) db_name=$(ynh_app_setting_get --app=$app --key=db_name) db_user=$app final_path=$(ynh_app_setting_get --app=$app --key=final_path) -ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) #================================================= # STANDARD REMOVE @@ -96,13 +95,6 @@ ynh_remove_nginx_config #================================================= # SPECIFIC REMOVE -#================================================= -# REMOVE LDAP USER -#================================================= -ynh_script_progression --message="Removing ldap user..." --weight=2 - -yunohost user delete $ldap_user --purge - #================================================= # REMOVE THE CRON FILE #================================================= diff --git a/scripts/restore b/scripts/restore index 89e2430..59e71fc 100644 --- a/scripts/restore +++ b/scripts/restore @@ -35,8 +35,6 @@ 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_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) -ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) -ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password) #================================================= # CHECK IF THE APP CAN BE RESTORED @@ -91,13 +89,6 @@ ynh_install_nodejs --nodejs_version="8" 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" -#================================================= -# CREATING LDAP USER -#================================================= -ynh_script_progression --message="Creating LDAP user..." --weight=424 - -yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 - #================================================= # INSTALLING RUBY AND BUNDLER #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index fe6f331..46e7229 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -37,9 +37,6 @@ 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) -ldap_user=$(ynh_app_setting_get --app=$app --key=ldap_user) -ldap_password=$(ynh_app_setting_get --app=$app --key=ldap_password) - #================================================= # CHECK VERSION #================================================= @@ -125,16 +122,6 @@ if [[ -z "$vapid_private_key" ]]; then ynh_app_setting_set "$app" vapid_public_key "$vapid_public_key" fi -# If ldap_user doesn't exist, retrieve it or create it -if [[ -z "$ldap_user" ]]; then - ldap_user="svc_${app}_ldap" - ldap_password==$(ynh_string_random --length=8) - ynh_app_setting_set "$app" ldap_user "$ldap_user" - ynh_app_setting_set "$app" ldap_password "$ldap_password" - - yunohost user create $ldap_user --firstname "SvcMastodonLdap" --lastname "SvcMastodonLdap" --mail ${ldap_user}@$domain --password $ldap_password -q 0 -fi - #Remove previous added repository ynh_remove_extra_repo @@ -252,9 +239,6 @@ ynh_replace_string --match_string="__OTP_SECRET__" --replace_string="$otp_secret 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="__LDAP_USER__" --replace_string="$ldap_user" --target_file="$final_path/live/.env.production" -ynh_replace_string --match_string="__LDAP_PASSWORD__" --replace_string="$ldap_password" --target_file="$final_path/live/.env.production" - #================================================= # UPGRADE MASTODON #================================================= From f265a66e5231d298f8a2dffd91e1f2a51da52429 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Sun, 4 Aug 2019 00:50:29 +0200 Subject: [PATCH 05/10] Remove sending mail --- README.md | 11 +-- README_fr.md | 10 +- conf/message | 5 - scripts/install | 18 +--- scripts/ynh_send_readme_to_admin__2 | 140 ---------------------------- 5 files changed, 12 insertions(+), 172 deletions(-) delete mode 100644 conf/message delete mode 100644 scripts/ynh_send_readme_to_admin__2 diff --git a/README.md b/README.md index 01c6a8f..1f48b9b 100644 --- a/README.md +++ b/README.md @@ -8,9 +8,7 @@ > *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.* -:warning: UPDATE 05/06/17 :This app can work now on ARM, but installation takes several hours and you must add a swapfile of 1GB. - -:warning: This application uses the Debian backports packages, do not install this application directly in production +:warning: This app can work now on ARM, but installation takes several hours and you must add a swapfile of 1GB. ## 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. @@ -21,8 +19,6 @@ Mastodon is a free, open-source social network. A decentralized alternative to c ![](https://framalibre.org/sites/default/files/mastodon.png) -[Source code](https://github.com/tootsuite/mastodon) - ## Configuration #### Adding "swapfile" If you have less than 2Go of RAM @@ -49,7 +45,6 @@ Recover after disconnect: $ screen -d $ screen -r ``` -The admin user is automatically created as: user@domain.tld ### Update #### Using __screen__ highly recommended @@ -68,6 +63,10 @@ It seems important to close the inscriptions for your Mastodon, so that it remai ## YunoHost specific features +#### Multi-users support + +LDAP authentication is activated. + #### 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/) diff --git a/README_fr.md b/README_fr.md index ad2280e..5024185 100644 --- a/README_fr.md +++ b/README_fr.md @@ -8,9 +8,7 @@ > *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.* -:warning: MAJ 05/06/17 :Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. - -:warning: Cette application utilise les packages backports de Debian, nous vous recommendons de ne pas installer cette application directement en production +:warning: Cette application peut maintenant fonctionner sur ARM, mais l'installation prend plusieurs heures et il faut ajouter un swapfile de 1Go. ## 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. @@ -67,7 +65,11 @@ Il semble important de fermer les inscriptions pour votre Mastodon, pour que à ## Caractéristiques spécifiques YunoHost -#### Supported architectures +#### Support multi-utilisateurs + +L'authentification LDAP est activée + +#### 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/) diff --git a/conf/message b/conf/message deleted file mode 100644 index 488d86d..0000000 --- a/conf/message +++ /dev/null @@ -1,5 +0,0 @@ -Mastodon was successfully installed :) -Please open 'https://__DOMAIN____PATH_URL__' -The admin email is: __ADMIN_MAIL__ -The admin password is: __ADMIN_PASS__ -If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh \ No newline at end of file diff --git a/scripts/install b/scripts/install index 0991cbc..3a4b517 100644 --- a/scripts/install +++ b/scripts/install @@ -9,7 +9,6 @@ source _common.sh source ynh_install_ruby source ynh_add_extra_apt_repos__3 -source ynh_send_readme_to_admin__2 source /usr/share/yunohost/helpers #================================================= @@ -185,12 +184,9 @@ pushd "$final_path/live" sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails db:migrate --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/bin/bundle exec rails assets:precompile --quiet sudo -u "$app" env PATH=$PATH RAILS_ENV=production /opt/rbenv/versions/2.6.1/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 + sudo -u "$app" env PATH=$PATH RAILS_ENV=production bin/tootctl accounts create "$admin" --email="$admin_mail" --confirmed --role=admin > /dev/null 2>&1 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\w+" "$final_path/live/key.txt") vapid_public_key=$(grep -oP "VAPID_PUBLIC_KEY=\K\w+" "$final_path/live/key.txt") @@ -279,18 +275,6 @@ ynh_script_progression --message="Reloading nginx web server..." --weight=2 ynh_systemd_action --service_name=nginx --action=reload -#================================================= -# SEND A README FOR THE ADMIN -#================================================= -ynh_script_progression --message="Sending a readme for the admin..." --weight=17 - -ynh_replace_string --match_string="__ADMIN_MAIL__" --replace_string="$admin_mail" --target_file="../conf/message" -ynh_replace_string --match_string="__ADMIN_PASS__" --replace_string="$admin_pass" --target_file="../conf/message" -ynh_replace_string --match_string="__DOMAIN__" --replace_string="$domain" --target_file="../conf/message" -ynh_replace_string --match_string="__PATH_URL__" --replace_string="$path_url" --target_file="../conf/message" - -ynh_send_readme_to_admin --app_message="../conf/message" --recipients=$admin_mail --type='install' - #================================================= # END OF SCRIPT #================================================= diff --git a/scripts/ynh_send_readme_to_admin__2 b/scripts/ynh_send_readme_to_admin__2 deleted file mode 100644 index 06cff8c..0000000 --- a/scripts/ynh_send_readme_to_admin__2 +++ /dev/null @@ -1,140 +0,0 @@ -#!/bin/bash - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin --app_message=app_message [--recipients=recipients] [--type=type] -# | arg: -m --app_message= - The file with the content to send to the administrator. -# | arg: -r, --recipients= - The recipients of this email. Use spaces to separate multiples recipients. - default: root -# example: "root admin@domain" -# If you give the name of a YunoHost user, ynh_send_readme_to_admin will find its email adress for you -# example: "root admin@domain user1 user2" -# | arg: -t, --type= - Type of mail, could be 'backup', 'change_url', 'install', 'remove', 'restore', 'upgrade' -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= [t]=type= ) - local app_message - local recipients - local type - # Manage arguments with getopts - - ynh_handle_getopts_args "$@" - app_message="${app_message:-}" - recipients="${recipients:-root}" - type="${type:-install}" - - # Get the value of admin_mail_html - admin_mail_html=$(ynh_app_setting_get $app admin_mail_html) - admin_mail_html="${admin_mail_html:-0}" - - # Retrieve the email of users - find_mails () { - local list_mails="$1" - local mail - local recipients=" " - # Read each mail in argument - for mail in $list_mails - do - # Keep root or a real email address as it is - if [ "$mail" = "root" ] || echo "$mail" | grep --quiet "@" - then - recipients="$recipients $mail" - else - # But replace an user name without a domain after by its email - if mail=$(ynh_user_get_info "$mail" "mail" 2> /dev/null) - then - recipients="$recipients $mail" - fi - fi - done - echo "$recipients" - } - recipients=$(find_mails "$recipients") - - # Subject base - local mail_subject="☁️🆈🅽🅷☁️: \`$app\`" - - # Adapt the subject according to the type of mail required. - if [ "$type" = "backup" ]; then - mail_subject="$mail_subject has just been backup." - elif [ "$type" = "change_url" ]; then - mail_subject="$mail_subject has just been moved to a new URL!" - elif [ "$type" = "remove" ]; then - mail_subject="$mail_subject has just been removed!" - elif [ "$type" = "restore" ]; then - mail_subject="$mail_subject has just been restored!" - elif [ "$type" = "upgrade" ]; then - mail_subject="$mail_subject has just been upgraded!" - else # install - mail_subject="$mail_subject has just been installed!" - fi - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$(if [ -n "$app_message" ] -then - cat "$app_message" -else - echo "...No specific information..." -fi) - ---- -Automatic diagnosis data from YunoHost - -__PRE_TAG1__$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')__PRE_TAG2__" - - # Store the message into a file for further modifications. - echo "$mail_message" > mail_to_send - - # If a html email is required. Apply html tags to the message. - if [ "$admin_mail_html" -eq 1 ] - then - # Insert 'br' tags at each ending of lines. - ynh_replace_string "$" "
" mail_to_send - - # Insert starting HTML tags - sed --in-place '1s@^@\n\n\n\n@' mail_to_send - - # Keep tabulations - ynh_replace_string " " "\ \ " mail_to_send - ynh_replace_string "\t" "\ \ " mail_to_send - - # Insert url links tags - ynh_replace_string "__URL_TAG1__\(.*\)__URL_TAG2__\(.*\)__URL_TAG3__" "\1" mail_to_send - - # Insert pre tags - ynh_replace_string "__PRE_TAG1__" "
" mail_to_send
-		ynh_replace_string "__PRE_TAG2__" "<\pre>" mail_to_send
-
-		# Insert finishing HTML tags
-		echo -e "\n\n" >> mail_to_send
-
-	# Otherwise, remove tags to keep a plain text.
-	else
-		# Remove URL tags
-		ynh_replace_string "__URL_TAG[1,3]__" "" mail_to_send
-		ynh_replace_string "__URL_TAG2__" ": " mail_to_send
-
-		# Remove PRE tags
-		ynh_replace_string "__PRE_TAG[1-2]__" "" mail_to_send
-	fi
-
-	# Define binary to use for mail command
-	if [ -e /usr/bin/bsd-mailx ]
-	then
-		local mail_bin=/usr/bin/bsd-mailx
-	else
-		local mail_bin=/usr/bin/mail.mailutils
-	fi
-
-	if [ "$admin_mail_html" -eq 1 ]
-	then
-		content_type="text/html"
-	else
-		content_type="text/plain"
-	fi
-
-	# Send the email to the recipients
-	cat mail_to_send | $mail_bin -a "Content-Type: $content_type; charset=UTF-8" -s "$mail_subject" "$recipients"
-}

From b20b088e8719544d473ef71f5d5f45f62f39d109 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Sun, 4 Aug 2019 19:32:22 +0200
Subject: [PATCH 06/10] increase yunohost version requirement

---
 manifest.json | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/manifest.json b/manifest.json
index 8086969..d21d9c5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -23,7 +23,7 @@
 	    }
 	],
     "requirements": {
-        "yunohost": ">= 3.5"
+        "yunohost": ">= 3.7"
     },
     "multi_instance": true,
 	"services": [

From 25a20b1d17f0b8752a39259c3b73a451e203255d Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Fri, 18 Oct 2019 23:29:38 +0200
Subject: [PATCH 07/10] Update .env.production.sample

---
 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 33f7d93..c55d99b 100644
--- a/conf/.env.production.sample
+++ b/conf/.env.production.sample
@@ -160,7 +160,7 @@ LDAP_HOST=localhost
 LDAP_PORT=389
 LDAP_METHOD=start_tls
 LDAP_BASE=ou=users,dc=yunohost,dc=org
-LDAP_BIND_DN=uid=uid=local,ou=users,dc=yunohost,dc=org
+LDAP_BIND_DN=uid=local,ou=users,dc=yunohost,dc=org
 LDAP_PASSWORD=
 LDAP_UID=uid
 LDAP_SEARCH_FILTER="%{uid}=%{email}"

From 84ddd5f934ec999d7819a82200c9332b5b16f8d3 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Sun, 29 Mar 2020 21:59:56 +0200
Subject: [PATCH 08/10] Create message

---
 conf/message | 5 +++++
 1 file changed, 5 insertions(+)
 create mode 100644 conf/message

diff --git a/conf/message b/conf/message
new file mode 100644
index 0000000..403c4e0
--- /dev/null
+++ b/conf/message
@@ -0,0 +1,5 @@
+Mastodon was successfully installed :)
+Please open : https://__DOMAIN____PATH_URL__
+The admin email is: __ADMIN_MAIL__
+The admin password is: __ADMIN_PASS__
+If you facing an issue or want to improve this app, please open a new issue in this project: https://github.com/YunoHost-Apps/mastodon_ynh
\ No newline at end of file

From 243666e212923f1cc7fa7be86a7900b719505473 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Tue, 7 Apr 2020 03:16:50 +0200
Subject: [PATCH 09/10] Update .env.production.sample

---
 conf/.env.production.sample | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/conf/.env.production.sample b/conf/.env.production.sample
index d2f4b91..d27bf87 100644
--- a/conf/.env.production.sample
+++ b/conf/.env.production.sample
@@ -178,7 +178,11 @@ LDAP_BASE=ou=users,dc=yunohost,dc=org
 LDAP_BIND_DN=uid=local,ou=users,dc=yunohost,dc=org
 LDAP_PASSWORD=
 LDAP_UID=uid
-LDAP_SEARCH_FILTER="%{uid}=%{email}"
+LDAP_MAIL=mail
+LDAP_SEARCH_FILTER=(|(%{uid}=%{email})(%{mail}=%{email}))
+LDAP_UID_CONVERSION_ENABLED=true
+LDAP_UID_CONVERSION_SEARCH=., -
+LDAP_UID_CONVERSION_REPLACE=_
 LDAP_TLS_NO_VERIFY=true
 
 # PAM authentication (optional)

From 437cde4033be799bf562ce0fcb4b8c4b97b76b65 Mon Sep 17 00:00:00 2001
From: yalh76 
Date: Wed, 8 Apr 2020 19:54:53 +0200
Subject: [PATCH 10/10] Add readme informations

---
 README.md    | 2 +-
 README_fr.md | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index d242c48..bd421eb 100644
--- a/README.md
+++ b/README.md
@@ -54,7 +54,7 @@ $ screen -r
 
 #### Multi-users support
 
-LDAP authentication is activated.
+LDAP authentication is activated. All YunoHost users can authenticate.
 
 #### Supported architectures
 
diff --git a/README_fr.md b/README_fr.md
index e1bd115..ea8fc4f 100644
--- a/README_fr.md
+++ b/README_fr.md
@@ -55,7 +55,7 @@ L'utilisateur admin est crée automatiquement comme: user@domain.tld
 
 #### Support multi-utilisateurs
 
-L'authentification LDAP est activée
+L'authentification LDAP est activée. Tous les utilisateurs YunoHost peuvent s'authentifier.
 
 #### Architectures supportées