Remove password and send it by email to admin
This commit is contained in:
parent
a4df2d28c5
commit
22da9d4b4c
|
@ -36,15 +36,6 @@
|
||||||
},
|
},
|
||||||
"example": "johndoe@example.com"
|
"example": "johndoe@example.com"
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "pass",
|
|
||||||
"type": "password",
|
|
||||||
"ask": {
|
|
||||||
"en": "Enter password of this administrator(username:root).Should be greater then 6 character",
|
|
||||||
"fr": "Ajouter le mot de passe pour cette administrateur ≥ 6 charactères"
|
|
||||||
},
|
|
||||||
"example": "battery horse staple nenuphar"
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "port",
|
"name": "port",
|
||||||
"ask": {
|
"ask": {
|
||||||
|
|
|
@ -11,3 +11,52 @@ ynh_delete_file_checksum () {
|
||||||
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
local checksum_setting_name=checksum_${1//[\/ ]/_} # Replace all '/' and ' ' by '_'
|
||||||
ynh_app_setting_delete $app $checksum_setting_name
|
ynh_app_setting_delete $app $checksum_setting_name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Send an email to inform the administrator
|
||||||
|
#
|
||||||
|
# usage: ynh_send_readme_to_admin app_message [recipients]
|
||||||
|
# | arg: app_message - The message to send to the administrator.
|
||||||
|
# | arg: 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() {
|
||||||
|
local app_message="${1:-...No specific information...}"
|
||||||
|
local recipients="${2:-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')"
|
||||||
|
|
||||||
|
# Send the email to the recipients
|
||||||
|
echo "$mail_message" | mail -a "Content-Type: text/plain; charset=UTF-8" -s "$mail_subject" "$recipients"
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ ynh_abort_if_errors
|
||||||
domain=$YNH_APP_ARG_DOMAIN
|
domain=$YNH_APP_ARG_DOMAIN
|
||||||
path_url="/"
|
path_url="/"
|
||||||
admin_email=$YNH_APP_ARG_EMAIL
|
admin_email=$YNH_APP_ARG_EMAIL
|
||||||
admin_pass=$YNH_APP_ARG_PASS
|
admin_pass=$(ynh_string_random 24)
|
||||||
port=$YNH_APP_ARG_PORT
|
port=$YNH_APP_ARG_PORT
|
||||||
is_public=$YNH_APP_ARG_IS_PUBLIC
|
is_public=$YNH_APP_ARG_IS_PUBLIC
|
||||||
|
|
||||||
|
@ -59,11 +59,6 @@ ynh_webpath_available $domain $path_url
|
||||||
# Register (book) web path
|
# Register (book) web path
|
||||||
ynh_webpath_register $app $domain $path_url
|
ynh_webpath_register $app $domain $path_url
|
||||||
|
|
||||||
# Check password strength
|
|
||||||
[[ ${#admin_pass} -gt 6 ]] || ynh_die \
|
|
||||||
"The password is too weak, it must be longer than 6 characters"
|
|
||||||
|
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# STORE SETTINGS FROM MANIFEST
|
# STORE SETTINGS FROM MANIFEST
|
||||||
#=================================================
|
#=================================================
|
||||||
|
@ -226,3 +221,17 @@ sudo systemctl start $app
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
||||||
systemctl reload nginx
|
systemctl reload nginx
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# SEND A README FOR THE ADMIN
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
message="PeerTube was successfully installed :)
|
||||||
|
|
||||||
|
Please open "https://$domain$path_url"
|
||||||
|
|
||||||
|
Here is the admin password: "$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/peertube_ynh"
|
||||||
|
|
||||||
|
ynh_send_readme_to_admin "$message"
|
||||||
|
|
|
@ -40,6 +40,19 @@ elif [ "$is_public" = "No" ]; then
|
||||||
is_public=0
|
is_public=0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
#=================================================
|
||||||
|
# BACKUP BEFORE UPGRADE THEN ACTIVE TRAP
|
||||||
|
#=================================================
|
||||||
|
|
||||||
|
# Backup the current version of the app
|
||||||
|
ynh_backup_before_upgrade
|
||||||
|
ynh_clean_setup () {
|
||||||
|
# restore it if the upgrade fails
|
||||||
|
ynh_restore_upgradebackup
|
||||||
|
}
|
||||||
|
# Exit if an error occurs during the execution of the script
|
||||||
|
ynh_abort_if_errors
|
||||||
|
|
||||||
#=================================================
|
#=================================================
|
||||||
# REMOVE APP MAIN DIR
|
# REMOVE APP MAIN DIR
|
||||||
#=================================================
|
#=================================================
|
||||||
|
|
Loading…
Reference in a new issue