diff --git a/omr-tracker/files/usr/share/omr/proxy-post-tracking.d/030-leds b/omr-tracker/files/usr/share/omr/proxy-post-tracking.d/030-leds new file mode 100755 index 0000000000..3f41f9fd44 --- /dev/null +++ b/omr-tracker/files/usr/share/omr/proxy-post-tracking.d/030-leds @@ -0,0 +1,27 @@ +#!/bin/sh + +[ "$OMR_TRACKER_PREV_STATUS" = "$OMR_TRACKER_STATUS" ] && exit 0 + +set_leds() { + local cfg=$1 + config_get trigger $cfg trigger + [ "$trigger" != "proxy" ] && return + config_get sysfs $cfg sysfs + config_get proxy_status $cfg proxy_status + if [ "$proxy_status" = "off" ]; then + if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then + echo 'default-on' > /sys/class/leds/${sysfs}/trigger + else + echo 'none' > /sys/class/leds/${sysfs}/trigger + fi + elif [ "$proxy_status" = "on" ]; then + if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then + echo 'none' > /sys/class/leds/${sysfs}/trigger + else + echo 'default-on' > /sys/class/leds/${sysfs}/trigger + fi + fi +} + +config_load system +config_foreach set_leds led \ No newline at end of file diff --git a/omr-tracker/files/usr/share/omr/server-post-tracking.d/030-leds b/omr-tracker/files/usr/share/omr/server-post-tracking.d/030-leds new file mode 100755 index 0000000000..1ae577918d --- /dev/null +++ b/omr-tracker/files/usr/share/omr/server-post-tracking.d/030-leds @@ -0,0 +1,27 @@ +#!/bin/sh + +[ "$OMR_TRACKER_PREV_STATUS" = "$OMR_TRACKER_STATUS" ] && exit 0 + +set_leds() { + local cfg=$1 + config_get trigger $cfg trigger + [ "$trigger" != "server" ] && return + config_get sysfs $cfg sysfs + config_get server_status $cfg server_status + if [ "$server_status" = "off" ]; then + if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then + echo 'default-on' > /sys/class/leds/${sysfs}/trigger + else + echo 'none' > /sys/class/leds/${sysfs}/trigger + fi + elif [ "$server_status" = "on" ]; then + if [ "$OMR_TRACKER_STATUS" = "ERROR" ]; then + echo 'none' > /sys/class/leds/${sysfs}/trigger + else + echo 'default-on' > /sys/class/leds/${sysfs}/trigger + fi + fi +} + +config_load system +config_foreach set_leds led \ No newline at end of file