YunoHost-Apps / peertube_ynh

Federated (ActivityPub) video streaming platform using P2P for YunoHost
https://joinpeertube.org/fr/
GNU Affero General Public License v3.0
88 stars 28 forks source link

Overwriting production.yaml on upgrade necessary? #274

Closed fflorent closed 2 years ago

fflorent commented 3 years ago

I use peertube with the need to use an external smtp server. To do so, I have to edit the production.yaml config file.

production.yaml is meant to be edited by the user when they want to customize the settings, at the contrary of default.yaml which is meant to keep the default settings (source).

As we maintain the package, shouldn't default.yaml be the file with the configuration generated by the Yunohost package and let production.yaml be the file where the user can override these settings in some ways? What do you think?

Thanks in advance!

Florent

yalh76 commented 3 years ago

As far, as i've seen, changes made through the interface are written by local-production.json, and that file is not rewrittent during upgrade.

I haven't seen a default.yaml

fflorent commented 3 years ago

local-production.yaml is meant to be overwritten by peertube UI. The mail configuration is done by editing production.yaml and default.yaml is the one deployed by the PeerTube project: https://github.com/Chocobozzz/PeerTube/blob/4d3e611dd2764d1d5d0a7e777312631e1e7005d4/config/default.yaml

That being said, I may have a solution: as PeerTube seem to use node-config, as said by the documentation about the configuration load order, I should be able to create and use the local.yaml file to overwrite the smtp configuration.

fflorent commented 3 years ago

I made this script so the local.yaml file can be set again in the config directory (to be placed as a hook like /etc/yunohost/hooks.d/post_app_upgrade/50-smtp_peertube):

#!/bin/bash
instance_name=$YNH_APP_INSTANCE_NAME

if [ "$instance_name" == "peertube" ]
then

  local_yaml_file="/var/www/$instance_name/config/local.yaml"
  cat << EOF >> $local_yaml_file

# Overridden by /etc/yunohost/hooks.d/post_app_upgrade/50-smtp_peertube
# SMTP server to send emails
smtp:                                        
  hostname: mail.gandi.net
  port: 465
  username: <user>
  password: <password>
  tls: true/false
  from_address: mail@domain.tld
EOF

  chown peertube:www-data $local_yaml_file
  sudo systemctl restart "$instance_name"
fi

That seems to work

fflorent commented 3 years ago

@yalh76 I don't know what to do with this issue, I would understand that it would be an edge case, and with the above hook that we can close the issue.

BDouze commented 2 years ago

Another solution to this edge case could be to configure a smtp relay host in /etc/postfix/main.cf This has the advantages of not having to modify peertube config and to enable all yunohost server emails to be sent though the external smtp server

In /etc/postfix/main.cf :

#Relay mail sending through Gandi's SMTP 
relayhost = mail.gandi.net:587
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_use_tls = yes

Then add user and password in /etc/postfix/sasl/sasl_passwd :

mail.gandi.net:587 <user>:<password>

And run postmap /etc/postfix/sasl/sasl_passwd to generate the hash db

fflorent commented 2 years ago

@BDouze Good point. Also I realized yesterday that there are configuration keys for that in Yunohost: https://github.com/YunoHost/yunohost/blob/9a3a2088093d6d9252ab5eb2a8c3e473f2789226/hooks/conf_regen/19-postfix#L27-L35

BDouze commented 2 years ago

Oh, nice! I did not knew about these YNH configs :) Can these be set through the web admin?

fflorent commented 2 years ago

Didn't see anything on the webadmin, though I may haven't look correctly?

BDouze commented 2 years ago

I also haven't found. But there is a documentation on how to set this up through the command line : https://yunohost.org/fr/email_configure_relay