fix install script16

This commit is contained in:
Edmund Tan 2025-07-22 03:18:39 +08:00
parent 69137f818c
commit cddb7d97c1
2 changed files with 10 additions and 3 deletions

View File

@ -405,12 +405,17 @@ EOF;
throw new Exception('Router enrollment failed: ' . $output); throw new Exception('Router enrollment failed: ' . $output);
} }
// Verify certificates were created // Verify certificates were created using sudo (since certs are root-owned with 600 permissions)
$routerName = $this->routerData['routerInfo']['name']; $routerName = $this->routerData['routerInfo']['name'];
$certFile = CERTS_DIR . '/' . $routerName . '.cert'; $certFile = CERTS_DIR . '/' . $routerName . '.cert';
if (!file_exists($certFile)) { // Use sudo to check if certificate file exists (www-data can't read root-owned 600 files)
throw new Exception('Router certificate not found after enrollment'); $checkOutput = '';
if (!executeCommand("test -f '$certFile'", $checkOutput)) {
// List what files actually exist for debugging
$listOutput = '';
executeCommand("ls -la " . CERTS_DIR . "/", $listOutput);
throw new Exception("Router certificate not found after enrollment. Expected: $certFile. Files in certs directory: " . $listOutput);
} }
return true; return true;

View File

@ -363,6 +363,8 @@ www-data ALL=(ALL) NOPASSWD: /usr/bin/ln
www-data ALL=(ALL) NOPASSWD: /usr/bin/whoami www-data ALL=(ALL) NOPASSWD: /usr/bin/whoami
www-data ALL=(ALL) NOPASSWD: /usr/bin/tee www-data ALL=(ALL) NOPASSWD: /usr/bin/tee
www-data ALL=(ALL) NOPASSWD: /usr/bin/cat www-data ALL=(ALL) NOPASSWD: /usr/bin/cat
www-data ALL=(ALL) NOPASSWD: /usr/bin/test
www-data ALL=(ALL) NOPASSWD: /usr/bin/ls
EOF EOF
# Validate sudoers file # Validate sudoers file