summaryrefslogblamecommitdiffstats
path: root/roles/upload/tasks/main.yml
blob: 57d21a2d8d4b7c2bf14971f43a1cace1bc073ed7 (plain) (tree)











































                                                                                                    









                                                                    













                                                                                                       








                                                                        



















                                                                          




                    
- name: Set up packages as root
  block:
  - name: Add GPG
    apt:
      update_cache: yes
      name:
        - gpg
        - sudo
  - name: Add nodesource key
    apt_key:
      url: https://deb.nodesource.com/gpgkey/nodesource.gpg.key
      state: present
  - name: Add nodesource repository
    ansible.builtin.apt_repository:
      repo: deb https://deb.nodesource.com/node_13.x buster main
      update_cache: yes
  - name: Install packages
    apt:
      update_cache: yes
      name:
        - nodejs
      state: present
- name: Create upload user
  become: true
  user:
    name: "{{ upload_user }}"
    shell: /bin/bash
    state: present
- name: Ensure upload directory exists
  file:
    path: "{{ upload_dir }}"
    owner: "{{ upload_user }}"
    state: directory
- name: Install precompiled version  
  unarchive:
    src: https://github.com/psi-4ward/psitransfer/releases/download/v2.1.1/psitransfer-v2.1.1.tar.gz
    dest: "/home/{{ upload_user }}"
    remote_src: yes
- name: Create link
  file:
    src: "/home/{{ upload_user }}/psitransfer-v2.1.1"
    dest: "/home/{{ upload_user }}/psitransfer"
    state: link
- name: Upload production config
  become: true
  template:
    src: config.production.js
    dest: "/home/{{ upload_user }}/psitransfer/config.production.js"
- name: Install dependencies
  npm:
    path: "/home/{{ upload_user }}/psitransfer"
    production: yes
    ci: yes
- name: Add LibreJS tag start
  lineinfile:
    path: /home/{{ upload_user }}/psitransfer/public/app/{{ item.path }}
    line: // @license {{ item.license }}
    insertbefore: BOF
  loop:
    - path: common.js
      license: magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
    - path: upload.js
      license: magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt Expat
    - path: admin.js
      license: magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt BSD-2-Clause
    - path: download.js
      license: magnet:?xt=urn:btih:87f119ba0b429ba17a44b4bffcab33165ebdacc0&dn=freebsd.txt BSD-2-Clause
- name: Add license tag end
  lineinfile:
    path: /home/{{ upload_user }}/psitransfer/public/app/{{ item.path }}
    line: // @license-end
  loop:
    - path: common.js
    - path: upload.js
    - path: admin.js
    - path: download.js
- name: Update head template
  template:
    src: head.pug
    dest: /home/{{ upload_user }}/psitransfer/public/pug/partials/head.pug
- name: Change ownership
  file:
    path: "/home/{{ upload_user }}"
    owner: "{{ upload_user }}"
    group: "{{ upload_group }}"
    recurse: true
- name: Install systemd configuration
  tags: system
  become: true
  template:
    src: upload.service
    dest: /etc/systemd/system/upload.service
    owner: root
    group: root
    mode: 0755
  when: not use_initd
- name: Restart Upload
  become: true
  service:
    name: upload
    state: restarted
    enabled: yes