From f85f43ee8343f4f06b9ddbd6ea33d20594c3ff72 Mon Sep 17 00:00:00 2001 From: yalh76 Date: Fri, 1 Feb 2019 00:53:29 +0100 Subject: [PATCH] Replace Admin Password generation by user password choosen --- check_process | 1 + manifest.json | 13 ++++++ scripts/install | 19 ++------- scripts/ynh_send_readme_to_admin | 70 -------------------------------- 4 files changed, 17 insertions(+), 86 deletions(-) delete mode 100644 scripts/ynh_send_readme_to_admin diff --git a/check_process b/check_process index 0cb5a4a..be31990 100755 --- a/check_process +++ b/check_process @@ -8,6 +8,7 @@ domain="domain.tld" (DOMAIN) admin="john" (USER) is_public=1 (PUBLIC|public=1|private=0) + password="pass" name="my blog" registration=0 (BOOLEAN) ; Checks diff --git a/manifest.json b/manifest.json index 44220f3..5f0c6c6 100755 --- a/manifest.json +++ b/manifest.json @@ -48,6 +48,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 9d98e60..5ce2cd3 100755 --- a/scripts/install +++ b/scripts/install @@ -29,10 +29,10 @@ domain=$YNH_APP_ARG_DOMAIN path_url="/" admin=$YNH_APP_ARG_ADMIN is_public=$YNH_APP_ARG_IS_PUBLIC +password=$YNH_APP_ARG_PASSWORD instance_name=$YNH_APP_ARG_NAME registration=$YNH_APP_ARG_REGISTRATION admin_email=$(ynh_user_get_info $admin 'mail') -admin_pass=$(ynh_string_random 24) random_key=$(openssl rand -base64 32) ### If it's a multi-instance app, meaning it can be installed several times independently @@ -219,7 +219,7 @@ else fi # Add admin user -( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$admin_pass" ) +( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm users new --admin -n "$admin" -N "$admin" --email "$admin_email" --password "$password" ) # Initialise search index ( cd $final_path/$app && sudo -u "$app" $final_path/.cargo/bin/plm search init -p $final_path/$app ) @@ -356,17 +356,4 @@ systemctl reload nginx # START SERVICE #================================================= -yunohost service start $app - -#================================================= -# SEND A README FOR THE ADMIN -#================================================= - -message=" $app was successfully installed :) -Please open your $app domain: https://$domain$path_url - -The admin username is: $admin -The admin password is: $admin_pass - -If you are facing any problem or want to improve this app, please open a new issue here: https://github.com/Plume-org/Plume" -ynh_send_readme_to_admin "$message" "$admin" +yunohost service start $app \ No newline at end of file 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" -}