diff --git a/scripts/config b/scripts/config index cbe796f..563d13a 100644 --- a/scripts/config +++ b/scripts/config @@ -29,19 +29,20 @@ get__registrations_require_3pid() { } set__registrations_require_3pid() { - + # sed -z do the trick on this king of multline replacement case ${registrations_require_3pid} in email) - sed -i -r -e "s|\#?[^\S\n]*registrations_require_3pid:\s(\#?[^\S\n]*- .*\s){0,2}|registrations_require_3pid:\n - email\n# - msisdn|g" "/etc/matrix-$app/homeserver.yaml" + + sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1\2#\3|" "/etc/matrix-$app/homeserver.yaml" ;; msisdn) - sed -i -r -e "s|\#?[^\S\n]*registrations_require_3pid:\s(\#?[^\S\n]*- .*\s){0,2}|registrations_require_3pid:\n# - email\n - msisdn|g" "/etc/matrix-$app/homeserver.yaml" + sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1#\2\3|" "/etc/matrix-$app/homeserver.yaml" ;; email&msisdn) - sed -i -r -e "s|\#?[^\S\n]*registrations_require_3pid:\s(\#?[^\S\n]*- .*\s){0,2}|registrations_require_3pid:\n - email\n - msisdn|g" "/etc/matrix-$app/homeserver.yaml" + sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|\1\2\3|" "/etc/matrix-$app/homeserver.yaml" ;; *) - sed -i -r -e "s|\#?[^\S\n]*registrations_require_3pid:\s(\#?[^\S\n]*- .*\s){0,2}|#registrations_require_3pid:\n# - email\n# - msisdn|g" "/etc/matrix-$app/homeserver.yaml" + sed -i -z -r "s|#?([^\S\n]*registrations_require_3pid:\n)#?([^\S\n]*-[^\S\n]*email\n)#?([^\S\n]*-[^\S\n]*msisdn)|#\1#\2#\3|" "/etc/matrix-$app/homeserver.yaml" ;; esac @@ -54,13 +55,13 @@ get__allowed_local_3pids_email() { } set__allowed_local_3pids_email() { - - sed -i -r -e "s|(\#?[^\S\n]*allowed_local_3pids:\s(\#?[^\S\n]*- medium:.*\s\#?[^\S\n]*pattern:.*\s)?\#?[^\S\n]*- medium: email\s\#?[^\S\n]*pattern: )(.*)(\s)|$1'${allowed_local_3pids_email}'$3\2|g" "/etc/matrix-$app/homeserver.yaml" + sed -i -z -r "s|(\#?[^\S\n]*allowed_local_3pids:\s(\#?[^\S\n]*- medium:.*\s\#?[^\S\n]*pattern:.*\s)?\#?[^\S\n]*- medium: email\s\#?[^\S\n]*pattern: )(.*)(\s)|$1'${allowed_local_3pids_email}'$3\2|g" "/etc/matrix-$app/homeserver.yaml" ynh_app_setting_set --app=$app --key=fpm_footprint --value="${registrations_require_3pid}" } + #================================================= # GENERIC FINALIZATION #=================================================