diff options
| author | Joe Carstairs <me@joeac.net> | 2026-08-26 10:37:32 +0100 |
|---|---|---|
| committer | Joe Carstairs <me@joeac.net> | 2026-08-26 10:37:32 +0100 |
| commit | c4029e0ca955b7b6b64db7784573414576e52da7 (patch) | |
| tree | 5970b4633e7311dcd6615d0e2be08e89e0b049a1 /roles | |
| parent | 13c14b6cb9576489c99775e8ff19934378d1e760 (diff) | |
git-daemon is self-updating
Diffstat (limited to 'roles')
| -rw-r--r-- | roles/git-daemon/files/update_git-daemon | 18 | ||||
| -rw-r--r-- | roles/git-daemon/tasks/main.yml | 12 |
2 files changed, 30 insertions, 0 deletions
diff --git a/roles/git-daemon/files/update_git-daemon b/roles/git-daemon/files/update_git-daemon new file mode 100644 index 0000000..ecb7e47 --- /dev/null +++ b/roles/git-daemon/files/update_git-daemon @@ -0,0 +1,18 @@ +#!/bin/sh + +apk -U upgrade + +gitd_pid="$(pgrep gitd)" +if [ -z "$gitd_pid" ] +then + rc-service git-daemon restart + exit 0 +fi + +gitd_proc_start_time="$(stat -Lc %Y /proc/${gitd_pid})" +gitd_file_mtime="$(stat -Lc %Y $(which git))" + +if [ "$gitd_file_mtime" -gt "$gitd_proc_start_time" ] +then + rc-service git-daemon restart +fi diff --git a/roles/git-daemon/tasks/main.yml b/roles/git-daemon/tasks/main.yml index 5508b1e..6b0724c 100644 --- a/roles/git-daemon/tasks/main.yml +++ b/roles/git-daemon/tasks/main.yml @@ -33,3 +33,15 @@ name: safe.directory add_mode: add value: "{{ git_directory }}/*" + +- name: Install script to update git-daemon + ansible.builtin.copy: + src: update_git-daemon + dest: /usr/bin/update_git-daemon + mode: "755" + +- name: Install daily crontab to update git-daemon + ansible.builtin.cron: + special_time: daily + name: Update git-daemon + job: /usr/bin/update_git-daemon |
