Commit 297501d3 authored by nimrod's avatar nimrod
Browse files

OpenWRT WAP daily updates script.

Download package updates and notify if there are pending updates.
parent 5c7d2aab
Loading
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -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
+7 −0
Original line number Diff line number Diff line
#!/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 }}