diff --git a/roles/wap/tasks/main.yaml b/roles/wap/tasks/main.yaml index 6ea54f25227603bda7cc7769ac14ec5b240e4ba8..5125fd4c6f396116b9bd7c69a8aa18ef81b8b97a 100644 --- a/roles/wap/tasks/main.yaml +++ b/roles/wap/tasks/main.yaml @@ -5,6 +5,30 @@ - ansible_distribution == "OpenWrt" - ansible_distribution_major_version == "19" +- name: Install packages + loop: + - curl + community.general.opkg: + name: '{{ item }}' + state: present + update_cache: true + +- name: Copy the daily updates script + ansible.builtin.template: + dest: &daily /usr/sbin/daily + group: root + mode: 0o0755 + owner: root + src: daily.j2 + +- name: Set the daily updates script Cron job + ansible.builtin.cron: + hour: "3" + job: *daily + minute: "1" + name: Daily updates + state: present + - name: Create the www directory ansible.builtin.file: path: /var/www diff --git a/roles/wap/templates/daily.j2 b/roles/wap/templates/daily.j2 new file mode 100644 index 0000000000000000000000000000000000000000..a0e3cfb4dde9356a6bb320b75160b32a777a832f --- /dev/null +++ b/roles/wap/templates/daily.j2 @@ -0,0 +1,7 @@ +#!/bin/sh +set -eu + +opkg update +opkg list-upgradable | awk '{print $1}' | sort | xargs -rn1 opkg upgrade --download-only + +[ -z "$(opkg list-upgradable)" ] || curl https://notify.shore.co.il/send?message={{ (ansible_facts["hostname"] + " has pending updates.") | urlencode }}