diff options
author | John Klug <john.klug@multitech.com> | 2019-12-03 17:57:46 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2019-12-03 17:57:46 -0600 |
commit | 3422816ad067fa6156d56332c98ceeb2c3ec1996 (patch) | |
tree | 8c24d9d7b92ad257363906e7847176c4ab25b45c | |
parent | 507a781f13032524594023284779cd93cab259e5 (diff) | |
download | commissioning-3422816ad067fa6156d56332c98ceeb2c3ec1996.tar.gz commissioning-3422816ad067fa6156d56332c98ceeb2c3ec1996.tar.bz2 commissioning-3422816ad067fa6156d56332c98ceeb2c3ec1996.zip |
Commissioning is only after root file system is new and no passwords
-rwxr-xr-x | etc/init.d/commissioning | 30 | ||||
-rwxr-xr-x | etc/init.d/php-fpm-commission | 7 |
2 files changed, 17 insertions, 20 deletions
diff --git a/etc/init.d/commissioning b/etc/init.d/commissioning index 4fc7366..82bda67 100755 --- a/etc/init.d/commissioning +++ b/etc/init.d/commissioning @@ -7,26 +7,28 @@ NAME=commissioning DESC="Lighttpd Web Server" OPTS="-f /etc/lighttpd-commission.conf" PIDFILE=/var/run/lighttpd-commission.pid - +CONF_DIR=/var/config 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 (php-fpm-commision will see this) - rm /etc/default/$NAME - ENABLED="yes" - fi -fi +[ -f "/etc/default/${NAME}" ] && . "/etc/default/${NAME}" -# To disable commissioning across a factory reset (and image install): -# echo 'ENABLED="no"' >/var/config/.no-commissioning -# ln -sf /var/config/.no-commissioning /etc/default/no-commissioning +PASSWORDS=$(passwd -Sa | egrep '^[^[:space:]]+[[:space:]]P[[:space:]]' | wc -l) +if (($PASSWORDS == 0)) ; then + # No password, so indicate commissioning mode + # php-fpm-commision will be turned on as well + rm -f /etc/default/$NAME + ENABLED="yes" +fi [ -f "/etc/default/no-${NAME}" ] && . "/etc/default/no-${NAME}" +if [ ! -f $CONF_DIR/server.pem ]; then + echo "Generating server cert" + openssl req \ + -x509 -nodes -days 3650 \ + -subj '/C=US/ST=Minnesota/L=Minneapolis/CN=mlinux.example.com' \ + -newkey rsa:2048 -keyout $CONF_DIR/server.pem -out $CONF_DIR/server.pem +fi case "$1" in start) diff --git a/etc/init.d/php-fpm-commission b/etc/init.d/php-fpm-commission index 7ac0925..cd86ab5 100755 --- a/etc/init.d/php-fpm-commission +++ b/etc/init.d/php-fpm-commission @@ -22,12 +22,7 @@ php_fpm_PID="/var/run/${NAME}.pid" php_opts="-R --fpm-config $php_fpm_CONF --pid $php_fpm_PID" ENABLED=yes -[ -f "/etc/default/commissioning" ] && . "/etc/config/commisioning" - -# To disable commissioning across a factory reset (and image install): -# echo 'ENABLED="no"' >/var/config/.no-commissioning -# ln -sf /var/config/.no-commissioning /etc/default/no-commissioning -[ -f "/etc/default/no-commissioning" ] && . "/etc/default/no-commissioning" +[ -f "/etc/default/commissioning" ] && . "/etc/default/commissioning" wait_for_pid () { try=0 |