- name: Patch Friendica local.config.php (DB + system.url) in one pass
  command: >
    docker exec --user {{ friendica_user }} {{ friendica_container }}
    sed -ri
    -e "s/('hostname'\s*=>\s*')[^']*(',)/\1{{ database_host }}:{{ database_port }}\2/"
    -e "s/('database'\s*=>\s*')[^']*(',)/\1{{ database_name }}\2/"
    -e "s/('username'\s*=>\s*')[^']*(',)/\1{{ database_username }}\2/"
    -e "s/('password'\s*=>\s*')[^']*(',)/\1{{ database_password }}\2/"
    -e "s#('url'\s*=>\s*')[^']*(',)#\1{{ domains | get_url(application_id, WEB_PROTOCOL) }}\2#"
    {{ friendica_config_file }}
  notify: docker compose up
