mirror of
https://github.com/YunoHost-Apps/flarum_ynh.git
synced 2024-09-03 18:36:24 +02:00
Merge pull request #58 from YunoHost-Apps/patch-email
Email admin with their credentials
This commit is contained in:
commit
8c5b136fa5
3 changed files with 137 additions and 82 deletions
|
@ -50,9 +50,9 @@
|
|||
"name": "admin",
|
||||
"type": "user",
|
||||
"ask": {
|
||||
"en": "Choose the admin user",
|
||||
"fr": "Choisissez l’administrateur",
|
||||
"de": "Wählen einen Administrator"
|
||||
"en": "Choose the admin user (required for automatic post-installation)",
|
||||
"fr": "Choisissez l’administrateur (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Administrator (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "johndoe",
|
||||
"optional": true
|
||||
|
@ -60,9 +60,9 @@
|
|||
{
|
||||
"name": "title",
|
||||
"ask": {
|
||||
"en": "Choose a title for your forum",
|
||||
"fr": "Choisissez un titre pour votre forum",
|
||||
"de": "Wählen einen Titel für eure Internetforum"
|
||||
"en": "Choose a title for your forum (required for automatic post-installation)",
|
||||
"fr": "Choisissez un titre pour votre forum (nécessaire pour la post-installation automatique)",
|
||||
"de": "Wählen einen Titel für eure Internetforum (erforderlich für die automatische Nachinstallation)"
|
||||
},
|
||||
"example": "My forum",
|
||||
"default": "",
|
||||
|
|
|
@ -10,3 +10,52 @@ exec_as() {
|
|||
sudo -u "$USER" "$@"
|
||||
fi
|
||||
}
|
||||
|
||||
# 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"
|
||||
}
|
||||
|
|
|
@ -249,7 +249,13 @@ for username in $(ynh_user_list); do
|
|||
fi
|
||||
fi
|
||||
done
|
||||
>&2 echo "Installation successfull. Admin : $admin, password : $admin_pwd. Change it!"
|
||||
app_message="User : $admin, password : $admin_pwd
|
||||
Change your password!
|
||||
Your forum is accessible at https://$domain/$path_url"
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
else
|
||||
>&2 echo "Installation successfull. Post-installation required, visit your Flarum instance!"
|
||||
app_message="Post-installation required, visit your Flarum instance."
|
||||
>&2 echo $app_message
|
||||
ynh_send_readme_to_admin "$app_message" "$admin"
|
||||
fi
|
||||
|
|
Loading…
Add table
Reference in a new issue