This commit is contained in:
2025-11-20 17:43:29 +02:00
parent 85281432a9
commit 1388df33ff

View File

@@ -609,51 +609,57 @@
- name: Dev1 | Derive scroll24 schedule summary - name: Dev1 | Derive scroll24 schedule summary
delegate_to: localhost delegate_to: localhost
vars: shell: |
cron_parts: "{{ scroll24_cron_line.split() if scroll24_cron_line|length > 0 else [] }}" line="{{ scroll24_cron_line | default('') }}"
min_field: "{{ cron_parts[0] if cron_parts|length > 0 else '' }}"
hour_field: "{{ cron_parts[1] if cron_parts|length > 1 else '' }}" # No crontab hit or no scroll24.sh line
every_n_minutes: >- if [ -z "$line" ]; then
{{ echo nocron
(min_field is match('^\\*/[0-9]+$')) and (hour_field == '*') exit 0
}} fi
every_n_hours: >-
{{ # Extract first 5 cron fields
hour_field is match('^\\*/[0-9]+$') min="$(echo "$line" | awk '{print $1}')"
}} hour="$(echo "$line" | awk '{print $2}')"
interval_value: >-
{%- if every_n_minutes -%} # Pattern 1: */N * * * * -> every N minutes
{{ min_field.split('/')[1] }} case "$min" in
{%- elif every_n_hours -%} '*/'*)
{{ hour_field.split('/')[1] }} n="${min#*/}"
{%- else -%} if [ -n "$n" ]; then
custom echo "${n}m"
{%- endif -%} exit 0
interval_unit: >- fi
{%- if every_n_minutes -%} ;;
m esac
{%- elif every_n_hours -%}
h # Pattern 2: M */H * * * -> every H hours (we ignore the minute)
{%- else -%} case "$hour" in
'' '*/'*)
{%- endif -%} h="${hour#*/}"
set_fact: if [ -n "$h" ]; then
scroll24_schedule: >- echo "${h}h"
{%- if scroll24_cron_line|length == 0 -%} exit 0
nocron fi
{%- elif interval_value == 'custom' or interval_unit|length == 0 -%} ;;
custom esac
{%- else -%}
{{ interval_value ~ interval_unit }} # Fallback
{%- endif -%} echo custom
args:
executable: /bin/bash
register: scroll24_sched_raw
changed_when: false
failed_when: false
- name: Dev1 | Compute scroll24 value - name: Dev1 | Compute scroll24 value
delegate_to: localhost delegate_to: localhost
set_fact: set_fact:
scroll24_schedule: "{{ scroll24_sched_raw.stdout | default('') | trim }}"
scroll24_value: >- scroll24_value: >-
{%- if not (scroll24_present | default(false)) -%} {%- if not (scroll24_present | default(false)) -%}
missing missing
{%- elif scroll24_schedule == 'nocron' -%} {%- elif scroll24_schedule in ['nocron', ''] -%}
{{ scroll24_ver_clean | default('v1') }}_nocron {{ scroll24_ver_clean | default('v1') }}_nocron
{%- elif scroll24_schedule == 'custom' -%} {%- elif scroll24_schedule == 'custom' -%}
{{ scroll24_ver_clean | default('v1') }}_custom {{ scroll24_ver_clean | default('v1') }}_custom
@@ -693,6 +699,7 @@
} | to_json }}" } | to_json }}"
payload_encoding: "string" payload_encoding: "string"
changed_when: false changed_when: false
# ----------------------- Dev1 wifidebug.sh check & publish ----------------------- # ----------------------- Dev1 wifidebug.sh check & publish -----------------------
- name: Dev1 | Check wifidebug.sh presence - name: Dev1 | Check wifidebug.sh presence