From 78a578a86f7d8ca1a2cc267f88600f5f9a4d9543 Mon Sep 17 00:00:00 2001 From: Joe Carstairs Date: Wed, 26 Aug 2026 14:30:09 +0100 Subject: mox is self-updating --- roles/mox/tasks/main.yml | 14 +++++++++++++- roles/mox/templates/update_mox | 13 +++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 roles/mox/templates/update_mox (limited to 'roles') diff --git a/roles/mox/tasks/main.yml b/roles/mox/tasks/main.yml index 2e41a4c..ac4a43c 100644 --- a/roles/mox/tasks/main.yml +++ b/roles/mox/tasks/main.yml @@ -105,7 +105,7 @@ ansible.builtin.get_url: dest: /usr/bin/mox mode: "755" - url: "{{ mox_url }}" + url: https://beta.gobuilds.org/github.com/mjl-/mox@latest/linux-{{ mox_platform }}-latest/dl - name: Install mox service register: mox_service @@ -153,3 +153,15 @@ cmd: mox setaccountpassword {{ item.name }} stdin: "{{ item.password }}" chdir: ~mox + +- name: Install script to update mox + ansible.builtin.template: + src: update_mox + dest: /usr/bin/update_mox + mode: "755" + +- name: Install daily crontab to update mox + ansible.builtin.cron: + special_time: daily + name: Update mox + job: /usr/bin/update_mox diff --git a/roles/mox/templates/update_mox b/roles/mox/templates/update_mox new file mode 100644 index 0000000..9300b68 --- /dev/null +++ b/roles/mox/templates/update_mox @@ -0,0 +1,13 @@ +#!/bin/sh + +mox_url="https://beta.gobuilds.org/github.com/mjl-/mox@latest/linux-{{ mox_platform }}-latest" +current_version="$(mox version | grep -Eo ^v[0-9.]\+)" +latest_version="$(curl ${mox_url}/ --show-headers --silent | grep ^location: | grep -Eo /mox@v[0-9.]\+/ | grep -Eo v[0-9.]\+)" +if [ -z "$current_version" ] || [ "$current_version" != "$latest_version" ] +then + wget -O ~/mox ${mox_url}/dl + chmod 755 ~/mox + rc-service mox stop + mv ~/mox /usr/bin/mox + rc-service mox restart +fi -- cgit v1.2.3