summaryrefslogtreecommitdiff
path: root/roles/fcgiwrap
diff options
context:
space:
mode:
authorJoe Carstairs <me@joeac.net>2026-08-26 09:37:14 +0100
committerJoe Carstairs <me@joeac.net>2026-08-26 09:37:33 +0100
commit29c1c4c8afc41303d00cde10950d42129c7c0f33 (patch)
tree43d209abf8a81b81b63a8b77361c26223558e496 /roles/fcgiwrap
parent7a17fe4dcee235b5973326c6daedebccc2de41d2 (diff)
fcgiwrap is self-updating
Diffstat (limited to 'roles/fcgiwrap')
-rw-r--r--roles/fcgiwrap/files/update_fcgiwrap18
-rw-r--r--roles/fcgiwrap/tasks/main.yml40
-rw-r--r--roles/fcgiwrap/templates/conf.d/fcgiwrap3
3 files changed, 61 insertions, 0 deletions
diff --git a/roles/fcgiwrap/files/update_fcgiwrap b/roles/fcgiwrap/files/update_fcgiwrap
new file mode 100644
index 0000000..f371b5d
--- /dev/null
+++ b/roles/fcgiwrap/files/update_fcgiwrap
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+apk upgrade
+
+fcgiwrap_pid="$(pgrep fcgiwrap | head -n 1)"
+if [ -z "$fcgiwrap_pid" ]
+then
+ rc-service fcgiwrap restart
+ exit 0
+fi
+
+fcgiwrap_proc_start_time="$(stat -Lc %Y /proc/${fcgiwrap_pid})"
+fcgiwrap_file_mtime="$(stat -Lc %Y $(which fcgiwrap))"
+
+if [ "$fcgiwrap_file_mtime" -gt "$fcgiwrap_proc_start_time" ]
+then
+ rc-service fcgiwrap restart
+fi
diff --git a/roles/fcgiwrap/tasks/main.yml b/roles/fcgiwrap/tasks/main.yml
new file mode 100644
index 0000000..7435274
--- /dev/null
+++ b/roles/fcgiwrap/tasks/main.yml
@@ -0,0 +1,40 @@
+- name: Install fcgiwrap
+ community.general.apk:
+ name: fcgiwrap
+
+- name: Configure fcgiwrap daemon
+ register: fcgiwrap_conf
+ vars:
+ fcgiwrap_socket: /run/fcgiwrap.sock
+ fcgiwrap_user: nginx
+ fcgiwrap_group: nginx
+ ansible.builtin.template:
+ src: conf.d/fcgiwrap
+ dest: /etc/conf.d/fcgiwrap
+ mode: "644"
+
+- name: Restart fcgiwrap daemon and configure to start on boot
+ when: fcgiwrap_conf is changed
+ ansible.builtin.service:
+ name: fcgiwrap
+ enabled: true
+ state: restarted
+
+- name: Start fcgiwrap daemon and configure to start on boot
+ when: not ( fcgiwrap_conf is changed )
+ ansible.builtin.service:
+ name: fcgiwrap
+ enabled: true
+ state: started
+
+- name: Install script to update fcgiwrap
+ ansible.builtin.template:
+ src: update_fcgiwrap
+ dest: /usr/bin/update_fcgiwrap
+ mode: "755"
+
+- name: Install daily crontab to update fcgiwrap
+ ansible.builtin.cron:
+ special_time: daily
+ name: Update fcgiwrap
+ job: /usr/bin/update_fcgiwrap
diff --git a/roles/fcgiwrap/templates/conf.d/fcgiwrap b/roles/fcgiwrap/templates/conf.d/fcgiwrap
new file mode 100644
index 0000000..65a40e8
--- /dev/null
+++ b/roles/fcgiwrap/templates/conf.d/fcgiwrap
@@ -0,0 +1,3 @@
+socket=unix:{{ fcgiwrap_socket }}
+user={{ fcgiwrap_user }}
+group={{ fcgiwrap_group }}