diff options
| -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 | 
