diff --git a/scripts/upgrade b/scripts/upgrade index 8c7ad84..daf84b6 100644 --- a/scripts/upgrade +++ b/scripts/upgrade @@ -186,19 +186,16 @@ if [ -z $e2e_enabled_by_default_in_element ] ; then ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element fi -if [ "$e2e_enabled_by_default" = "invite" ] ; then - e2e_enabled_by_default_in_element="true" - ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element -fi - -if [ "$e2e_enabled_by_default" = "all" ] ; then - e2e_enabled_by_default_in_element="true" - ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element -fi - -if [ "$e2e_enabled_by_default" = "off" ] ; then - e2e_enabled_by_default_in_element="false" - ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element +if [ "$e2e_enabled_by_default" = "all" ] || [ "$e2e_enabled_by_default" = "invite" ] ; then + e2e_enabled_by_default_in_element="true" + ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element + server_name=$(ynh_app_setting_get --app $app --key server_name) + sed -i -r "s|\"im\.vector\.riot\.e2ee\": \{\"default\": [A-Za-z]+ \}|\"im.vector.riot.e2ee\": {\"default\": ${e2e_enabled_by_default_in_element} }|g" "/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" +elif [ "$e2e_enabled_by_default" = "off" ] ; then + e2e_enabled_by_default_in_element="false" + ynh_app_setting_set --app=$app --key=e2e_enabled_by_default_in_element --value=$e2e_enabled_by_default_in_element + server_name=$(ynh_app_setting_get --app $app --key server_name) + sed -i -r "s|\"im\.vector\.riot\.e2ee\": \{\"default\": [A-Za-z]+ \}|\"im.vector.riot.e2ee\": {\"default\": ${e2e_enabled_by_default_in_element} }|g" "/etc/nginx/conf.d/${server_name}.d/${app}_server_name.conf" fi if [ -z $report_stats ]; then @@ -237,7 +234,7 @@ if [ -e "/var/lib/matrix-$app" ]; then fi if ! grep -q "$final_path" /etc/passwd; then # matrix-synapse:x:994:994::/var/lib/matrix-synapse:/usr/sbin/nologin - sed --in-place -r "s@matrix-$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/matrix-$app\:/usr/sbin/nologin@matrix-$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd + --in-place -r "s@matrix-$app\:x\:([[:digit:]]+\:[[:digit:]]+)\:\:/.*/matrix-$app\:/usr/sbin/nologin@matrix-$app\:x\:\1\:\:$final_path\:/usr/sbin/nologin@g" /etc/passwd fi #================================================= @@ -394,7 +391,7 @@ fi #================================================= ynh_script_progression --message="Upgrading dependencies..." --weight=6 -# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE +# WARNING : theses command are u in INSTALL, UPGRADE, RESTORE # For any update do it in all files ynh_exec_warn_less ynh_install_app_dependencies $dependances @@ -411,7 +408,7 @@ fi #================================================= # CREATE SMALL CAS SERVER #================================================= -# WARNING : theses command are used in INSTALL, UPGRADE +# WARNING : theses command are u in INSTALL, UPGRADE # For any update do it in all files mkdir -p $final_www_path @@ -454,7 +451,7 @@ fi #================================================= ynh_script_progression --message="Updating synapse config..." --weight=2 -# WARNING : theses command are used in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) +# WARNING : theses command are u in INSTALL, UPGRADE, CONFIG, CHANGE-URL (4 times) # For any update do it in all files if [ -z $macaroon_secret_key ]; then @@ -518,7 +515,7 @@ fi # MIGRATION 4 : CREATE A DH FILE #================================================= -# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE +# WARNING : theses command are u in INSTALL, UPGRADE, RESTORE # For any update do it in all files # Make dh cert for synapse if it doesn't exist @@ -559,11 +556,11 @@ ynh_add_nginx_config app #================================================= ynh_script_progression --message="Updating Coturn config..." --weight=1 -# WARNING : theses command are used in INSTALL, UPGRADE +# WARNING : theses command are u in INSTALL, UPGRADE # For any update do it in all files # Get public IP and set as external IP for coturn -# note : '|| true' is used to ignore the errors if we can't get the public ipv4 or ipv6 +# note : '|| true' is u to ignore the errors if we can't get the public ipv4 or ipv6 public_ip4="$(curl -s ip.yunohost.org)" || true public_ip6="$(curl -s ipv6.yunohost.org)" || true @@ -584,7 +581,7 @@ ynh_add_config --template="turnserver.conf" --destination="/etc/matrix-$app/cotu # ADD SCRIPT FOR COTURN CRON AND APP SERVICE #================================================= -# WARNING : theses command are used in INSTALL, UPGRADE +# WARNING : theses command are u in INSTALL, UPGRADE # For any update do it in all files ynh_add_config --template="../sources/Coturn_config_rotate.sh" --destination="$final_path/Coturn_config_rotate.sh" @@ -605,8 +602,8 @@ fi # ADVERTISE SERVICE IN ADMIN PANEL #================================================= -yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_exposed_ports $synapse_tls_port -yunohost service add coturn-$app --needs_exposed_ports $turnserver_tls_port +yunohost service add matrix-$app --log "/var/log/matrix-$app/homeserver.log" --needs_expo_ports $synapse_tls_port +yunohost service add coturn-$app --needs_expo_ports $turnserver_tls_port #================================================= # UPDATE SYSTEMD @@ -625,7 +622,7 @@ ynh_add_systemd_config --service=coturn-$app --template=coturn-synapse.service #================================================= ynh_script_progression --message="Reconfiguring Fail2Ban..." --weight=8 -# WARNING : theses command are used in INSTALL, UPGRADE +# WARNING : theses command are u in INSTALL, UPGRADE # For any update do it in all files ynh_add_fail2ban_config --use_template @@ -675,7 +672,7 @@ fi # SECURE FILES AND DIRECTORIES #================================================= -# WARNING : theses command are used in INSTALL, UPGRADE, RESTORE +# WARNING : theses command are u in INSTALL, UPGRADE, RESTORE # For any update do it in all files chown $synapse_user:root -R $final_path chmod 770 $final_path/Coturn_config_rotate.sh @@ -692,7 +689,7 @@ setfacl -R -m user:turnserver:rwX /var/log/matrix-$app # UPDATE HOOKS #================================================= -# WARNING : theses command are used in INSTALL, UPGRADE +# WARNING : theses command are u in INSTALL, UPGRADE # For any update do it in all files ynh_replace_string __APP__ $app ../hooks/post_cert_update ynh_replace_string __DOMAIN__ $domain ../hooks/post_cert_update