diff options
author | John Klug <john.klug@multitech.com> | 2019-12-03 11:51:50 -0600 |
---|---|---|
committer | John Klug <john.klug@multitech.com> | 2019-12-03 11:51:50 -0600 |
commit | ab1e64c346f7960ebf7c8ea04eec09de10bef8c7 (patch) | |
tree | 55cfaade7d98586918d9dfe1d4ca1a9e61900fba /www/commission | |
parent | fbb8005f2b3c413bdb51977ddc19abd1a846e363 (diff) | |
download | commissioning-ab1e64c346f7960ebf7c8ea04eec09de10bef8c7.tar.gz commissioning-ab1e64c346f7960ebf7c8ea04eec09de10bef8c7.tar.bz2 commissioning-ab1e64c346f7960ebf7c8ea04eec09de10bef8c7.zip |
Add u-boot password to commissioning
Diffstat (limited to 'www/commission')
-rw-r--r-- | www/commission/index.php | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/www/commission/index.php b/www/commission/index.php index 23f86cf..00546ab 100644 --- a/www/commission/index.php +++ b/www/commission/index.php @@ -127,22 +127,36 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ goto err_exit; } // Must have uid > 999 $tmpfile = tempnam("/var/volatile/tmp","commission"); + $cmd = "/usr/bin/passwd " . $username . " 2>&1 >$tmpfile"; $handle = popen($cmd, 'w'); $pwdtxt = $password . "\n" . $password; fwrite($handle, $pwdtxt); $status = pclose($handle); + syslog(LOG_ALERT, "set passwd: status: $status result: $result"); + $cmd = "/bin/cat $tmpfile"; $handle = popen($cmd, 'r'); $result2 = trim(fread($handle, 4192)); $status2 = pclose($handle); - syslog(LOG_ALERT, "passwd: status: $status result: $result"); + if (($result2 != 0) || (strlen($result2) > 0)) + syslog(LOG_ALERT, "read passwd log: status: $status2 result: $result2"); + + $cmd = "/sbin/mts-ubpasswd -u " . $password; + $handle = popen($cmd, 'r'); + $result3 = trim(fread($handle, 4192)); + $status3 = pclose($handle); + if ($status != 0) + syslog(LOG_ALERT, "mts-ubpasswd: status: $status result: $result"); + else + syslog(LOG_ALERT, "mts-ubpasswd: set u-boot password"); + 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"; + $cmd = "echo 'ENABLED=\"no\"' >/var/config/default/commissioning 2>&1"; $handle = popen($cmd, 'r'); $result = trim(fread($handle, 4192)); $status = pclose($handle); @@ -152,7 +166,7 @@ if($_SERVER["REQUEST_METHOD"] == "POST"){ } 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"; + "/usr/libexec/commissioning/off.sh"; syslog(LOG_ALERT, "turn off web server: command: $cmd"); $handle = popen($cmd, 'r'); $result = trim(fread($handle, 4192)); |