1
0
Fork 0
mirror of https://github.com/YunoHost-Apps/mobilizon_ynh.git synced 2024-09-03 19:46:19 +02:00

(to be validated...) Integrate mail .. which requires a dummy user

This commit is contained in:
Alexandre Aubin 2020-10-26 19:48:54 +01:00
parent b17c8fd862
commit e186da6477
5 changed files with 43 additions and 3 deletions

18
conf/mail.exs Normal file
View file

@ -0,0 +1,18 @@
config :mobilizon, Mobilizon.Web.Email.Mailer,
adapter: Bamboo.SMTPAdapter,
server: "127.0.0.1",
#hostname: "127.0.0.1",
# usually 25, 465 or 587
port: 25,
username: "__YNH_USER__",
password: "__YNH_USER_PASSWORD__",
# can be `:always` or `:never`
tls: :never,
allowed_tls_versions: [:"tlsv1.2"],
retries: 1,
# can be `true`
no_mx_lookups: false,
# can be `:always`. If your smtp relay requires authentication set it to `:always`.
auth: :always

View file

@ -28,9 +28,8 @@ path_url="/"
admin=$YNH_APP_ARG_ADMIN admin=$YNH_APP_ARG_ADMIN
is_public=$YNH_APP_ARG_IS_PUBLIC is_public=$YNH_APP_ARG_IS_PUBLIC
language=$YNH_APP_ARG_LANGUAGE language=$YNH_APP_ARG_LANGUAGE
admin_email=$(ynh_user_get_info $admin 'mail') admin_email=$(ynh_user_get_info $admin 'mail')
ynh_user_password=$(ynh_string_random --length=30)
app=$YNH_APP_INSTANCE_NAME app=$YNH_APP_INSTANCE_NAME
#================================================= #=================================================
@ -57,6 +56,7 @@ ynh_app_setting_set --app=$app --key=admin --value=$admin
ynh_app_setting_set --app=$app --key=is_public --value=$is_public ynh_app_setting_set --app=$app --key=is_public --value=$is_public
ynh_app_setting_set --app=$app --key=language --value=$language ynh_app_setting_set --app=$app --key=language --value=$language
ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email ynh_app_setting_set --app=$app --key=admin_email --value=$admin_email
ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password
#================================================= #=================================================
# STANDARD MODIFICATIONS # STANDARD MODIFICATIONS
@ -130,6 +130,9 @@ ynh_script_progression --message="Configuring system user..."
# Create a system user # Create a system user
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir=$final_path
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#================================================= #=================================================
# SPECIFIC SETUP # SPECIFIC SETUP
#================================================= #=================================================
@ -157,9 +160,12 @@ pushd $final_path/$app
popd popd
cat "../conf/ldap.exs" >> "$config" cat "../conf/ldap.exs" >> "$config"
cat "../conf/mail.exs" >> "$config"
pushd $final_path/$app pushd $final_path/$app
chmod o-rwx $config chmod o-rwx $config
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="$config"
# Compile *again* because we added ldap conf in between... dunno if the first is relevant # Compile *again* because we added ldap conf in between... dunno if the first is relevant
sudo -u "$app" MIX_ENV=prod mix compile sudo -u "$app" MIX_ENV=prod mix compile
ynh_secure_remove --file="/tmp/setup_db.psql" ynh_secure_remove --file="/tmp/setup_db.psql"

View file

@ -107,6 +107,8 @@ ynh_script_progression --message="Removing the dedicated system user..."
# Delete a system user # Delete a system user
ynh_system_user_delete --username=$app ynh_system_user_delete --username=$app
yunohost user delete ${app}_notifs
#================================================= #=================================================
# END OF SCRIPT # END OF SCRIPT
#================================================= #=================================================

View file

@ -34,6 +34,7 @@ db_name=$(ynh_app_setting_get --app=$app --key=db_name)
db_user=$db_name db_user=$db_name
db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd) db_pwd=$(ynh_app_setting_get --app=$app --key=db_pwd)
port=$(ynh_app_setting_get --app=$app --key=port) port=$(ynh_app_setting_get --app=$app --key=port)
ynh_user_password=$(ynh_app_setting_get --app=$app --key=ynh_user_password)
#================================================= #=================================================
# CHECK IF THE APP CAN BE RESTORED # CHECK IF THE APP CAN BE RESTORED
@ -69,6 +70,9 @@ ynh_script_progression --message="Recreating the dedicated system user..."
# Create the dedicated user (if not existing) # Create the dedicated user (if not existing)
ynh_system_user_create --username=$app --home_dir=$final_path ynh_system_user_create --username=$app --home_dir=$final_path
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
#================================================= #=================================================
# RESTORE USER RIGHTS # RESTORE USER RIGHTS
#================================================= #=================================================

View file

@ -102,12 +102,22 @@ ynh_systemd_action --service_name=$app --action="stop" --log_path=systemd --line
if ynh_version_gt "0.1.1" "${previous_version}" ; then if ynh_version_gt "0.1.1" "${previous_version}" ; then
ynh_script_progression --message="Upgrade configuration to 1.0.0..." ynh_script_progression --message="Upgrade configuration to 1.0.0..."
ynh_user_password=$(ynh_string_random --length=30)
ynh_app_setting_set --app=$app --key=ynh_user_password --value=$ynh_user_password
yunohost user create ${app}_notifs --firstname "Mobilizon" --lastname "Notifications" --mail ${app}_notifs@$domain --password "$ynh_user_password" -q 0
yunohost user update ${app}_notifs --add-mailalias $app@$domain --add-mailforward $admin_email
config="$final_path/$app/config/prod.secret.exs" config="$final_path/$app/config/prod.secret.exs"
ynh_backup_if_checksum_is_different --file="$config" ynh_backup_if_checksum_is_different --file="$config"
# Implement ldap # Implement ldap and mail
cat "../conf/ldap.exs" >> "$config" cat "../conf/ldap.exs" >> "$config"
cat "../conf/mail.exs" >> "$config"
ynh_replace_string --match_string="__YNH_USER__" --replace_string="${app}_notifs" --target_file="$config"
ynh_replace_string --match_string="__YNH_USER_PASSWORD__" --replace_string="${ynh_user_password}" --target_file="$config"
# Recalculate and store the checksum of the file for the next upgrade. # Recalculate and store the checksum of the file for the next upgrade.
ynh_store_file_checksum --file="$config" ynh_store_file_checksum --file="$config"
fi fi