diff options
author | John Klug <john.klug@multitech.com> | 2025-05-14 22:03:34 +0000 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2025-05-14 22:03:34 +0000 |
commit | f2a2b7f00937a6653e24990f6e301b5ddaa6619d (patch) | |
tree | 746b7ce4160531524480f42418449d7b869893da /usr/libexec | |
parent | 0b251b53e0a8a3b62411b4761b4fbed637d1eb26 (diff) | |
download | commissioning-f2a2b7f00937a6653e24990f6e301b5ddaa6619d.tar.gz commissioning-f2a2b7f00937a6653e24990f6e301b5ddaa6619d.tar.bz2 commissioning-f2a2b7f00937a6653e24990f6e301b5ddaa6619d.zip |
Invert LEDs during commissioning mode
Diffstat (limited to 'usr/libexec')
-rwxr-xr-x | usr/libexec/commission/commission | 31 | ||||
-rwxr-xr-x | usr/libexec/commission/off.sh | 3 |
2 files changed, 31 insertions, 3 deletions
diff --git a/usr/libexec/commission/commission b/usr/libexec/commission/commission index 52d88ba..b2120ea 100755 --- a/usr/libexec/commission/commission +++ b/usr/libexec/commission/commission @@ -9,6 +9,12 @@ OPTS="-f /etc/lighttpd-commission.conf" PIDFILE=/var/run/lighttpd-commission.pid CONF_DIR=/var/config ENABLED=yes +STINV="/sys/class/leds/led-status/invert" + +INIT=$(ps --no-header -o comm -p 1) +if [[ $INIT == systemd ]] ; then + OPTS="-D ${OPTS}" +fi PASSWORDS=$(passwd -Sa | egrep '^[^[:space:]]+[[:space:]]P[[:space:]]' | wc -l) @@ -17,9 +23,28 @@ if (($PASSWORDS == 0)) ; then # php-fpm-commision will be turned on as well rm -f "/run/mt-commission" echo 'ENABLED="yes"' >"/run/mt-commission" + # Invert the blink to show commissioning mode + echo "Invert the blink, I am $(id)" + t1=(1 1 1 1 1 1 1 1 1 1 1 1 4 16 64) + i=0 + while ! echo "1" >"$STINV" ; do + if ((i < 15)) ; then + t0=${t1[$i]} + else + t0=60 + fi + echo "LED is not ready, so sleep for $t0" + sleep $t0 + ((t0=(t0+1)*(t0+1))) + if((t0 > 64)) ; then + t0=64 + fi + done 2>/dev/null else ENABLED="no" echo 'ENABLED="no"' >"/run/mt-commission" + echo "Clear the blink" + echo "0" >"$STINV" fi [ -f "/etc/default/no-${NAME}" ] && . "/etc/default/no-${NAME}" @@ -33,7 +58,7 @@ if [ ! -f $CONF_DIR/server.pem ]; then fi if [ "$ENABLED" != "yes" ]; then - echo "Some user has a password" + echo "Some user has a password" if [ "$VERBOSE" = very ] ; then passwd -Sa | egrep '^[^[:space:]]+[[:space:]]P[[:space:]]' | logger -s -p daemon.notice echo "user count with passwords: $PASSWORDS" @@ -41,5 +66,5 @@ if [ "$ENABLED" != "yes" ]; then exit fi echo -n "Starting $DESC: " -"$DAEMON" $OPTS -echo "$NAME." +echo -n "Starting $DESC: " >/dev/console +exec "$DAEMON" $OPTS diff --git a/usr/libexec/commission/off.sh b/usr/libexec/commission/off.sh index afd3c1f..ae86c55 100755 --- a/usr/libexec/commission/off.sh +++ b/usr/libexec/commission/off.sh @@ -1,4 +1,7 @@ #!/bin/bash +STINV="/sys/class/leds/led-status/invert" +echo "Clear the blink" +echo "0" > "$STINV" INIT=$(ps --no-headers -o comm -p1) sleep 30 if [[ ${INIT} == systemd ]] ; then |