From a5889707ae62e9b2f6e1f7fc6e6d4cbec039bc68 Mon Sep 17 00:00:00 2001 From: Astro Date: Wed, 3 Feb 2021 00:59:13 +0100 Subject: [PATCH] cpe: refactor error-led --- salt/cpe/ap.sh | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/salt/cpe/ap.sh b/salt/cpe/ap.sh index 5d65054..472ec51 100644 --- a/salt/cpe/ap.sh +++ b/salt/cpe/ap.sh @@ -462,18 +462,14 @@ else UP=n fi -if [ \\\$REACHABLE = y ] && [ \\\$UP = n ]; then {%- if conf.get("error-led") %} - echo 0 > /sys/class/leds/{{ conf["error-led"] }}/brightness +ERROR_LED=/sys/class/leds/{{ conf["error-led"] }}/brightness +[ \\\$REACHABLE = y ] && echo 0 > $ERROR_LED +[ \\\$REACHABLE = n ] && echo 1 > $ERROR_LED {%- endif %} - wifi up -fi -if [ \\\$REACHABLE = n ] && [ \\\$UP = y ]; then -{%- if conf.get("error-led") %} - echo 1 > /sys/class/leds/{{ conf["error-led"] }}/brightness -{%- endif %} - wifi down -fi + +[ \\\$REACHABLE = y ] && [ \\\$UP = n ] && wifi up +[ \\\$REACHABLE = n ] && [ \\\$UP = y ] && wifi down exit 0 __SH__