summaryrefslogtreecommitdiffstats
path: root/roles/upload/tasks/main.yml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/upload/tasks/main.yml')
-rw-r--r--roles/upload/tasks/main.yml107
1 files changed, 107 insertions, 0 deletions
diff --git a/roles/upload/tasks/main.yml b/roles/upload/tasks/main.yml
new file mode 100644
index 0000000..843b4be
--- /dev/null
+++ b/roles/upload/tasks/main.yml
@@ -0,0 +1,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