From fcbfa12c29c694e65d01031539ebfe61cf8a3fa0 Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 01:38:35 +0100 Subject: [PATCH 01/13] Adding pushd popd during installation --- scripts/install | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/install b/scripts/install index 59ba02c..e36f100 100755 --- a/scripts/install +++ b/scripts/install @@ -248,27 +248,31 @@ fi #================================================= # Give permission to the final_path chown -R "$app":"$app" "$final_path" + +pushd $final_path/$app # App setup and db migration -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.hex --force ) -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.rebar --force ) -( cd $final_path/$app && sudo -u "$app" mix deps.get ) +sudo -u "$app" MIX_ENV=prod mix local.hex --force +sudo -u "$app" MIX_ENV=prod mix local.rebar --force +sudo -u "$app" mix deps.get ynh_psql_execute_as_root \ "ALTER USER $app WITH SUPERUSER;" -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix ecto.migrate --force ) +sudo -u "$app" MIX_ENV=prod mix ecto.migrate --force ynh_psql_execute_as_root \ "ALTER USER $app WITH NOSUPERUSER;" # Add user and retrieve a password reset link that you can then send to the user -admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) +admin_pass_reset_url=$( sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) # Make user moderator -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator ) +sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator # Make user admin -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --admin ) +sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --admin + +popd #================================================= # SETUP SYSTEMD From 1951417bf14d220a39b97ab99eb4d791f380618e Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 02:00:41 +0100 Subject: [PATCH 02/13] replacing sudo by su --- scripts/install | 34 +++++++++++++++++++++------------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/scripts/install b/scripts/install index e36f100..7cc5a03 100755 --- a/scripts/install +++ b/scripts/install @@ -250,27 +250,35 @@ fi chown -R "$app":"$app" "$final_path" pushd $final_path/$app -# App setup and db migration -sudo -u "$app" MIX_ENV=prod mix local.hex --force -sudo -u "$app" MIX_ENV=prod mix local.rebar --force -sudo -u "$app" mix deps.get +# Install dependecies +su "$app" < Date: Mon, 28 Jan 2019 02:05:14 +0100 Subject: [PATCH 03/13] Fix SU pleroma --- scripts/install | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index 7cc5a03..3ee44fc 100755 --- a/scripts/install +++ b/scripts/install @@ -249,27 +249,32 @@ fi # Give permission to the final_path chown -R "$app":"$app" "$final_path" -pushd $final_path/$app + # Install dependecies -su "$app" < Date: Mon, 28 Jan 2019 02:08:04 +0100 Subject: [PATCH 04/13] Fix dependencies --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index 3ee44fc..3e02a0d 100755 --- a/scripts/install +++ b/scripts/install @@ -255,7 +255,7 @@ su -l "$app" -s /bin/bash < Date: Mon, 28 Jan 2019 02:14:41 +0100 Subject: [PATCH 05/13] Fix MIX Dependencies installation --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 3e02a0d..7e40626 100755 --- a/scripts/install +++ b/scripts/install @@ -253,9 +253,9 @@ chown -R "$app":"$app" "$final_path" # Install dependecies su -l "$app" -s /bin/bash < Date: Mon, 28 Jan 2019 02:22:02 +0100 Subject: [PATCH 06/13] Fix PATH --- scripts/install | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/scripts/install b/scripts/install index 7e40626..4208c87 100755 --- a/scripts/install +++ b/scripts/install @@ -252,7 +252,7 @@ chown -R "$app":"$app" "$final_path" # Install dependecies su -l "$app" -s /bin/bash < Date: Mon, 28 Jan 2019 02:28:00 +0100 Subject: [PATCH 07/13] Back to original --- scripts/install | 41 +++++++++++++---------------------------- 1 file changed, 13 insertions(+), 28 deletions(-) diff --git a/scripts/install b/scripts/install index 4208c87..e229dbb 100755 --- a/scripts/install +++ b/scripts/install @@ -248,44 +248,29 @@ fi #================================================= # Give permission to the final_path chown -R "$app":"$app" "$final_path" +# App setup and db migration +( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.hex --force ) +( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.rebar --force ) +( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix deps.get ) +read -rsp $'Press enter to continue...\n' -# Install dependecies -su -l "$app" -s /bin/bash < Date: Mon, 28 Jan 2019 02:36:54 +0100 Subject: [PATCH 08/13] change way of the admin url is handle --- scripts/install | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index e229dbb..ff4bac0 100755 --- a/scripts/install +++ b/scripts/install @@ -264,7 +264,9 @@ ynh_psql_execute_as_root \ "ALTER USER $app WITH NOSUPERUSER;" # Add user and retrieve a password reset link that you can then send to the user -admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) +#admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) +response=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" ) +admin_pass_reset_url=$( tail -1 $response) # Make user moderator ( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator ) From 2774abd4b640686512d379e4dc20b9f949e60d8e Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 02:47:28 +0100 Subject: [PATCH 09/13] Fix Install step --- scripts/install | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/scripts/install b/scripts/install index ff4bac0..5307dad 100755 --- a/scripts/install +++ b/scripts/install @@ -253,8 +253,6 @@ chown -R "$app":"$app" "$final_path" ( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix local.rebar --force ) ( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix deps.get ) -read -rsp $'Press enter to continue...\n' - ynh_psql_execute_as_root \ "ALTER USER $app WITH SUPERUSER;" @@ -263,10 +261,10 @@ ynh_psql_execute_as_root \ ynh_psql_execute_as_root \ "ALTER USER $app WITH NOSUPERUSER;" +read -rsp $'Press enter to continue...\n' + # Add user and retrieve a password reset link that you can then send to the user -#admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) -response=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" ) -admin_pass_reset_url=$( tail -1 $response) +admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) # Make user moderator ( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator ) From d6c1b09b39227a9e9d906a4569d89c18ee2b620f Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 03:05:46 +0100 Subject: [PATCH 10/13] Adding password instead of mail+reset password url --- README.md | 6 +++--- check_process | 3 ++- manifest.json | 13 +++++++++++++ scripts/install | 28 +++------------------------- 4 files changed, 21 insertions(+), 29 deletions(-) diff --git a/README.md b/README.md index 95c6201..da58bfc 100644 --- a/README.md +++ b/README.md @@ -56,13 +56,13 @@ Go to **cd /var/www/pleroma/pleroma**. **Run:** - $ sudo -u pleroma MIX_ENV=prod mix pleroma.user new + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod mix pleroma.user new ) ### Password reset **Run:** - $ sudo -u pleroma MIX_ENV=prod mix pleroma.user reset_password + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod mix pleroma.user reset_password ) This will generate a **password reset link** that you can then send to the user. @@ -73,7 +73,7 @@ You can make users **moderators**. They will then be able to **delete any post** **Run:** - $ sudo -u pleroma MIX_ENV=prod mix pleroma.user set --[no-]admin + $ ( cd /var/www/pleroma/pleroma && sudo -u pleroma MIX_ENV=prod mix pleroma.user set --[no-]admin ) **--admin** option will **make the user moderator** and **--no-admin** will **take away the moderator privileges** from the user. diff --git a/check_process b/check_process index a616d55..93ba9b7 100755 --- a/check_process +++ b/check_process @@ -8,7 +8,8 @@ domain="domain.tld" (DOMAIN) admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) - name="pleroma" + password="pass" + name="My Pleroma" registration=0 (BOOLEAN) cache=1 (BOOLEAN) size="5g" diff --git a/manifest.json b/manifest.json index 077e58f..58b971a 100755 --- a/manifest.json +++ b/manifest.json @@ -49,6 +49,19 @@ }, "default": true }, + { + "name": "password", + "type": "password", + "ask": { + "en": "Set the administrator password", + "fr": "Définissez le mot de passe administrateur" + }, + "help": { + "en": "Use the help field to add an information for the admin about this question.", + "fr": "Utilisez le champ aide pour ajouter une information à l'intention de l'administrateur à propos de cette question." + }, + "example": "Choose a password" + }, { "name": "name", "ask": { diff --git a/scripts/install b/scripts/install index 5307dad..cd9ea14 100755 --- a/scripts/install +++ b/scripts/install @@ -29,6 +29,7 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +password=$YNH_APP_ARG_PASSWORD name=$YNH_APP_ARG_NAME registration=$YNH_APP_ARG_REGISTRATION cache=$YNH_APP_ARG_CACHE @@ -261,16 +262,8 @@ ynh_psql_execute_as_root \ ynh_psql_execute_as_root \ "ALTER USER $app WITH NOSUPERUSER;" -read -rsp $'Press enter to continue...\n' - -# Add user and retrieve a password reset link that you can then send to the user -admin_pass_reset_url=$( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" | tail -1 ) - -# Make user moderator -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --moderator ) - -# Make user admin -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user set "$admin" --admin ) +# Add user +( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" --moderator --admin -y ) #================================================= # SETUP SYSTEMD @@ -406,18 +399,3 @@ systemctl reload nginx yunohost service start $app sleep 10 - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message=" $app was successfully installed :) -Please open your $app domain: https://$domain$path_url - -The moderator username is: $admin -To reset your password: $admin_pass_reset_url - -If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/YunoHost-Apps/pleroma_ynh/ -If you are not afraid of the terminal, check out https://git.pleroma.social/pleroma/pleroma/wikis/home to see what more you can do with your awesome instance!" - -ynh_send_readme_to_admin "$message" "$admin" From 6c6b39678eb105dfb69d2ec8a470e71d52f2a15c Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 03:11:44 +0100 Subject: [PATCH 11/13] Fix password --- scripts/install | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/install b/scripts/install index cd9ea14..fe1ab42 100755 --- a/scripts/install +++ b/scripts/install @@ -263,7 +263,7 @@ ynh_psql_execute_as_root \ "ALTER USER $app WITH NOSUPERUSER;" # Add user -( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" --moderator --admin -y ) +( cd $final_path/$app && sudo -u "$app" MIX_ENV=prod mix pleroma.user new "$admin" "$admin_email" --password "$password" --moderator --admin -y ) #================================================= # SETUP SYSTEMD From bca30cfd33d1ab2e1a85ccb2984327f00c42f714 Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 03:20:30 +0100 Subject: [PATCH 12/13] Adding password and remove send_readme_to_admin --- scripts/install | 1 - scripts/upgrade | 46 --------------------- scripts/ynh_send_readme_to_admin | 70 -------------------------------- 3 files changed, 117 deletions(-) delete mode 100644 scripts/ynh_send_readme_to_admin diff --git a/scripts/install b/scripts/install index fe1ab42..45d068b 100755 --- a/scripts/install +++ b/scripts/install @@ -7,7 +7,6 @@ #================================================= source _common.sh -source ynh_send_readme_to_admin source /usr/share/yunohost/helpers #================================================= diff --git a/scripts/upgrade b/scripts/upgrade index e02689b..38533da 100755 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -148,52 +148,6 @@ ynh_system_user_create $app # ... #================================================= -#=================================================== -# Add PostgreSQL extension pg_trgm and citext -#=================================================== - -#ynh_psql_execute_as_root "\connect $db_name -#CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS pg_trgm;" -#ynh_psql_execute_as_root "\connect $db_name -#CREATE EXTENSION IF NOT EXISTS unaccent;CREATE EXTENSION IF NOT EXISTS citext;" - -# Open this port -#yunohost firewall allow Both "$port" 2>&1 - -#================================================= -# MODIFY A CONFIG FILE -#================================================= -#cp -f ../conf/prod.secret.exs "$final_path/$app/config/prod.secret.exs" -#cp -f ../conf/setup_db.psql "$final_path/$app/config/setup_db.psql" - -#ynh_replace_string "__DOMAIN__" "$domain" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__KEY__" "$random_key" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__INSTANCE_NAME__" "$name" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__ADMIN_EMAIL__" "$admin_email" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__PORT__" "$port" "$final_path/$app/config/prod.secret.exs" -#ynh_replace_string "__DB_NAME__" "$app" "$final_path/$app/config/setup_db.psql" -#ynh_replace_string "__DB_PWD__" "$db_pwd" "$final_path/$app/config/setup_db.psql" -#if [ $cache -eq 1 ] -#then -# ynh_replace_string "__MEDIA_CACHE__" "true" "$final_path/$app/config/prod.secret.exs" -#else -# ynh_replace_string "__MEDIA_CACHE__" "false" "$final_path/$app/config/prod.secret.exs" -#fi - -# Set registrations open/closed -#if [ $registration -eq 1 ] -#then -# ynh_replace_string "__REG__" "true" "$final_path/$app/config/prod.secret.exs" -#else -# ynh_replace_string "__REG__" "false" "$final_path/$app/config/prod.secret.exs" -#fi - -# Recalculate and store the config file checksum into the app settings -#ynh_store_file_checksum "$final_path/$app/config/prod.secret.exs" - - #================================================= # MAKE UPGRADE diff --git a/scripts/ynh_send_readme_to_admin b/scripts/ynh_send_readme_to_admin deleted file mode 100644 index b164f0e..0000000 --- a/scripts/ynh_send_readme_to_admin +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -# Need also the helper https://github.com/YunoHost-Apps/Experimental_helpers/blob/master/ynh_handle_getopts_args/ynh_handle_getopts_args - -# Send an email to inform the administrator -# -# usage: ynh_send_readme_to_admin app_message [recipients] -# | arg: -m --app_message= - The message 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" -ynh_send_readme_to_admin() { - # Declare an array to define the options of this helper. - declare -Ar args_array=( [m]=app_message= [r]=recipients= ) - local app_message - local recipients - # Manage arguments with getopts - ynh_handle_getopts_args "$@" - local app_message="${app_message:-...No specific information...}" - local recipients="${recipients:-root}" - - # 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") - - local mail_subject="☁️🆈🅽🅷☁️: \`$app\` was just installed!" - - local mail_message="This is an automated message from your beloved YunoHost server. - -Specific information for the application $app. - -$app_message - ---- -Automatic diagnosis data from YunoHost - -$(yunohost tools diagnosis | grep -B 100 "services:" | sed '/services:/d')" - - # 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 - - # Send the email to the recipients - echo "$mail_message" | $mail_bin -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients" -} From 994f13009d886d10c7b9f4b50b42336f83520f61 Mon Sep 17 00:00:00 2001 From: Yalh Date: Mon, 28 Jan 2019 03:21:08 +0100 Subject: [PATCH 13/13] Remove send_readme_to_admin reference --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index da58bfc..a47f194 100644 --- a/README.md +++ b/README.md @@ -33,7 +33,6 @@ For user friendly details about Pleroma: [see here](https://blog.soykaf.com/post 1. **Pleroma** require a valid **certificate** installed on the domain. Yunohost can **install Letsencrypt certificate** on the domain from **admin web-interface** or through **command-line**. 1. This package is **multi-instance** that means you can run **multiple Pleroma instances** on a **single server**. 1. There is **No LDAP** support for Pleroma yet. -1. At the end of the installation, you will receive a mail to activate and reset your password for Pleroma. ## License