From c296a35072f3fb630f48aac225e34f35440c1bcb Mon Sep 17 00:00:00 2001 From: John Klug Date: Mon, 2 Dec 2019 19:02:07 -0600 Subject: Allow some time after submit to shut down lighttpd --- www/commission/index.php | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) (limited to 'www') diff --git a/www/commission/index.php b/www/commission/index.php index 5721968..23f86cf 100644 --- a/www/commission/index.php +++ b/www/commission/index.php @@ -137,10 +137,31 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ $result2 = trim(fread($handle, 4192)); $status2 = pclose($handle); syslog(LOG_ALERT, "passwd: status: $status result: $result"); - if ($status === 0) { + if ($status == 0) { $finished = "Commissioning Complete"; $password_err = $result2; $username_err = $result; + // Disable commissioning + $cmd = "ln -sf /var/config/default/commissioning /etc/default/commissioning 2>&1;echo 'ENABLED=\"no\"' >/var/config/default/commissioning 2>&1"; + $handle = popen($cmd, 'r'); + $result = trim(fread($handle, 4192)); + $status = pclose($handle); + if ($status > 0) { + syslog(LOG_ALERT, "configure commissioning off failure: command: $cmd"); + syslog(LOG_ALERT, "passwd: status: $status result: $result"); + } else { + // shut off web server + $cmd = "/usr/sbin/start-stop-daemon -S -p /var/run/commissionoff.pid -b -a /bin/bash -- -c " . + "/usr/share/commissioning/off/off.sh"; + syslog(LOG_ALERT, "turn off web server: command: $cmd"); + $handle = popen($cmd, 'r'); + $result = trim(fread($handle, 4192)); + $status = pclose($handle); + if ($status > 0) { + syslog(LOG_ALERT, "turn off commissioning service: command: $cmd"); + syslog(LOG_ALERT, "stopping service: status: $status result: $result"); + } + } } else { $finished = "Errors: " . $result; $save_password = ""; -- cgit v1.2.3