1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/plume_ynh.git synced 2024-09-03 20:15:54 +02:00

Merge pull request #14 from YunoHost-Apps/testing

Replace Admin Password generation by user password choosen
This commit is contained in:
yalh76 2019-02-01 04:43:23 +01:00 committed by GitHub
commit 6435f9fdc4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 21 additions and 89 deletions

View file

@ -51,7 +51,7 @@ But the app can be used by multiple users
* ARMv8-A - [![Build Status](https://ci-apps-arm.yunohost.org/ci/logs/plume%20%28Community%29.svg)](https://ci-apps-arm.yunohost.org/ci/apps/plume/)
* Jessie x86-64b - [![Build Status](https://ci-stretch.nohost.me/ci/logs/plume%20%28Community%29.svg)](https://ci-stretch.nohost.me/ci/apps/plume/)
* Testing x86-64b - [![Build Status](https://ci-apps-unstable.yunohost.org/ci/logs/plume%20%28Community%29%20%28testing%29.svg)](https://ci-apps-unstable.yunohost.org/ci/apps/plume/)
* Unstable x86-64b - [![Build Status](https://ci-apps-unstable.yunohost.org/ci/logs/plume%20%28Community%2920%28unstable%29.svg)](https://ci-apps-unstable.yunohost.org/ci/apps/plume/)
* Unstable x86-64b - [![Build Status](https://ci-apps-unstable.yunohost.org/ci/logs/plume%20%28Community%29%20%28unstable%29.svg)](https://ci-apps-unstable.yunohost.org/ci/apps/plume/)
## Limitations

View file

@ -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

View file

@ -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": {

View file

@ -115,3 +115,4 @@ ynh_store_file_checksum "$final_path/$app/.env"
#=================================================
systemctl reload nginx
sleep 30

View file

@ -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 )
@ -357,16 +357,4 @@ systemctl reload nginx
#=================================================
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"
sleep 30

View file

@ -140,5 +140,4 @@ systemctl reload nginx
#=================================================
yunohost service start $app
sleep 30

View file

@ -191,4 +191,4 @@ systemctl reload nginx
#=================================================
yunohost service start $app
sleep 30

View file

@ -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"
}