summaryrefslogtreecommitdiffstats
path: root/roles/upload/tasks/main.yml
blob: 843b4be683634c03c24e6d8bd69220c3e91e4418 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
- 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
  tags: wip
  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
  tags: wip
  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
  tags: wip
  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
  tags: wip
  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
  tags: wip
  become: true
  service:
    name: upload
    state: restarted
    enabled: yes