summaryrefslogtreecommitdiff
path: root/roles/hysteria/tasks/install_hysteria.yaml
diff options
context:
space:
mode:
Diffstat (limited to 'roles/hysteria/tasks/install_hysteria.yaml')
-rw-r--r--roles/hysteria/tasks/install_hysteria.yaml64
1 files changed, 64 insertions, 0 deletions
diff --git a/roles/hysteria/tasks/install_hysteria.yaml b/roles/hysteria/tasks/install_hysteria.yaml
new file mode 100644
index 00000000..59dcd7b9
--- /dev/null
+++ b/roles/hysteria/tasks/install_hysteria.yaml
@@ -0,0 +1,64 @@
+---
+- name: "create directory"
+ ansible.builtin.file:
+ path: "{{ item }}"
+ state: directory
+ owner: _vpn
+ group: _vpn
+ mode: 0700
+ loop:
+ - "/var/reactance/hysteria"
+ - "/var/reactance/hysteria/bin"
+ - "/var/reactance/hysteria/etc"
+ - "/var/reactance/hysteria/certs"
+
+- name: "setup log file"
+ ansible.builtin.file:
+ path: /var/log/hysteria.log
+ state: touch
+ mode: "0600"
+ changed_when: false
+
+# this can remain here while hysteria is not being used
+- name: "install necessary utils"
+ community.general.openbsd_pkg:
+ name:
+ - git--
+ - go--
+ - rsync--
+ state: present
+
+- name: "create temporary directory"
+ ansible.builtin.tempfile:
+ state: directory
+ suffix: temp
+ register: hysteria_tempdir
+ notify:
+ - remove_hysteria_tempdir
+
+- name: "clone hysteria"
+ ansible.builtin.shell: "git clone https://github.com/apernet/hysteria.git"
+ args:
+ chdir: "{{ hysteria_tempdir.path }}"
+
+- name: "build hysteria"
+ ansible.builtin.shell: "python3 hyperbole.py build"
+ args:
+ chdir: "{{ hysteria_tempdir.path }}/hysteria"
+
+- name: "install hysteria"
+ ansible.builtin.shell: "{{ item }}"
+ loop:
+ - "install -m 750 -o _vpn -g bin {{ hysteria_tempdir.path }}/hysteria/build/hysteria-openbsd-* /var/reactance/hysteria/bin/hysteria"
+
+# Find the list of dependences through ldd and copy them over
+- name: "copy chroot dependencies"
+ ansible.builtin.shell: "deps=$(ldd /var/reactance/hysteria/bin/hysteria | awk 'FNR > 3 {print $7}'); for dep in $deps; do rsync -av --relative $dep /var/reactance/hysteria; done"
+
+- name: "template out init script"
+ ansible.builtin.template:
+ src: hysteria.rc.j2
+ dest: "{{ hysteria_tempdir.path }}/hysteria.rc"
+
+- name: "install init script"
+ ansible.builtin.shell: "install -m 755 -g bin {{ hysteria_tempdir.path }}/hysteria.rc /etc/rc.d/hysteria"