aboutsummaryrefslogtreecommitdiffstats
path: root/roles/_workstation/apm
diff options
context:
space:
mode:
authorRomain Gonçalves <me@rgoncalves.se>2022-12-10 21:17:16 +0100
committerRomain Gonçalves <me@rgoncalves.se>2022-12-12 22:04:27 +0100
commit7c1f7039170a25f192d87235476179f7cfe01a85 (patch)
treefc8e77b7176fa730b30b20081e76f2527371e9a3 /roles/_workstation/apm
parent21fc0867dc42128434e5c46ca684d9a966184b8a (diff)
downloadrules-7c1f7039170a25f192d87235476179f7cfe01a85.tar.gz
chore: explode workstation role in subroles
Diffstat (limited to 'roles/_workstation/apm')
-rw-r--r--roles/_workstation/apm/files/hibernate6
-rw-r--r--roles/_workstation/apm/files/resume17
-rw-r--r--roles/_workstation/apm/files/suspend6
-rw-r--r--roles/_workstation/apm/tasks/main.yml21
4 files changed, 50 insertions, 0 deletions
diff --git a/roles/_workstation/apm/files/hibernate b/roles/_workstation/apm/files/hibernate
new file mode 100644
index 0000000..c625aee
--- /dev/null
+++ b/roles/_workstation/apm/files/hibernate
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Managed by Ansible
+
+set -x -e
+
+pkill -USR1 xidle
diff --git a/roles/_workstation/apm/files/resume b/roles/_workstation/apm/files/resume
new file mode 100644
index 0000000..686f7e1
--- /dev/null
+++ b/roles/_workstation/apm/files/resume
@@ -0,0 +1,17 @@
+#!/bin/sh
+# Managed by Ansible
+
+set -x -e
+
+sleep 3
+
+sh /etc/netstart iwn0
+
+wg_interfaces=$(find /etc/wireguard -type f | sed 's/\.conf$//g')
+for wg_interface in ${wg_interfaces}; do
+ wg_interface=$(basename "${wg_interface}")
+ wg-quick down "${wg_interface}"
+ wg-quick up "${wg_interface}"
+done
+
+rcctl -d restart pcscd
diff --git a/roles/_workstation/apm/files/suspend b/roles/_workstation/apm/files/suspend
new file mode 100644
index 0000000..c625aee
--- /dev/null
+++ b/roles/_workstation/apm/files/suspend
@@ -0,0 +1,6 @@
+#!/bin/sh
+# Managed by Ansible
+
+set -x -e
+
+pkill -USR1 xidle
diff --git a/roles/_workstation/apm/tasks/main.yml b/roles/_workstation/apm/tasks/main.yml
new file mode 100644
index 0000000..72c5d2a
--- /dev/null
+++ b/roles/_workstation/apm/tasks/main.yml
@@ -0,0 +1,21 @@
+---
+
+- name: create apm configuration directory
+ ansible.builtin.file:
+ path: "{{ apm_configuration_dir }}"
+ state: directory
+ owner: 0
+ group: 0
+ mode: 0755
+
+- name: copy apm configurations
+ ansible.builtin.copy:
+ src: "{{ item }}"
+ dest: "{{ apm_configuration_dir }}/{{ item }}"
+ mode: 0755
+ owner: 0
+ group: 0
+ loop:
+ - hibernate
+ - suspend
+ - resume
remember that computers suck.