---
- name: Ensure update script continues to be executable
  file:
    path: "{{ azuracast_setup_update_script }}"
    state: touch
    mode: "a+x"
  loop:
    - "{{ www_base }}/update.sh"
    - "{{ www_base }}/bin/console"
  loop_control:
    loop_var: azuracast_setup_update_script

- name: Run AzuraCast Setup (Install Mode)
  become: true
  become_user: azuracast
  shell: >-
    php {{ www_base }}/bin/console azuracast:setup
  when: update_mode|bool

- name: Migrate Legacy Configuration (Update Mode)
  become: true
  become_user: azuracast
  shell: >-
    php {{ www_base }}/bin/console azuracast:config:migrate
  when: update_mode|bool

- name: Run AzuraCast Setup (Update Mode)
  become: true
  become_user: azuracast
  shell: php {{ www_base }}/bin/console azuracast:setup --update
  when: update_mode|bool
