summaryrefslogtreecommitdiff
path: root/etc/init.d/commissioning
diff options
context:
space:
mode:
Diffstat (limited to 'etc/init.d/commissioning')
-rwxr-xr-xetc/init.d/commissioning13
1 files changed, 13 insertions, 0 deletions
diff --git a/etc/init.d/commissioning b/etc/init.d/commissioning
index 11b0eb3..4f54267 100755
--- a/etc/init.d/commissioning
+++ b/etc/init.d/commissioning
@@ -10,10 +10,23 @@ PIDFILE=/var/run/lighttpd-commission.pid
ENABLED=yes
[ -f /etc/default/$NAME ] && . /etc/default/$NAME
+
+# If we are not enabled, see if anybody has a password
+if [[ ENABLED == no ]] ; then
+ PASSWORDS=$(passwd -Sa | egrep '^[^[:space:]]+[[:space:]]P[[:space:]]' | wc -l)
+ if (($PASSWORDS == 0)) ; then
+ # No password, so turn on commissioning
+ rm /etc/default/$NAME
+ ENABLED="yes"
+ fi
+fi
+
# /etc/default/no-${NAME} should point at /etc/default/.no-${NAME}
# and contain ENABLED="no".
# This will prevent commissioning on a factory reset
# but not on an image update for tighter security.
+# If the device is to have no password at all, this file and
+# link must be created, and ENABLED must be set to "no"
[ -f "/etc/default/no-${NAME}" ] && . "/etc/config/no-${NAME}"