summaryrefslogblamecommitdiffstats
path: root/roles/upload/tasks/main.yml
blob: 3e7e615f677a91f8b0a2591b5accf3ce0ffd2511 (plain) (tree)
1
2
3
4
5
6
7
8
9
10





                               
               
              

                                                




                                                               
                                                                  



















                                      
                                                                                                    



                                   
                                                     


                                               



                                                                    













                                                 





                                               













                                                                                                       








                                                                        



















                                                                          




                    
- name: Set up packages as root
  block:
  - name: Add GPG
    apt:
      update_cache: yes
      name:
        - gnupg
        - sudo
      state: present
  - name: Import the NodeSource GPG key into apt
    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_20.x nodistro 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.2/psitransfer-v2.1.2.tar.gz
    dest: "/home/{{ upload_user }}"
    remote_src: yes
- name: Create link
  file:
    src: "/home/{{ upload_user }}/psitransfer-v2.1.2"
    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: Copy the SSL key
  become: true
  copy:
    remote_src: yes
    src: "{{ upload_ssl_key }}"
    dest: "/home/{{ upload_user }}/privkey.pem"
- name: Copy the SSL cert
  become: true
  copy:
    remote_src: yes
    src: "{{ upload_ssl_cert }}"
    dest: "/home/{{ upload_user }}/fullchain.pem"
    owner: "{{ upload_user }}"
    group: "{{ upload_group }}"
- 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