Fix user requirement in setup, cleanup.

This commit is contained in:
Niklas Keller
2015-12-21 00:01:25 +01:00
parent 5a4ab4a410
commit 37d054975c
6 changed files with 58 additions and 86 deletions

View File

@@ -61,13 +61,6 @@ class Setup implements Command {
$this->logger->info("New private key successfully saved.");
}
$user = $args->get("user") ?: "www-data";
$userInfo = posix_getpwnam($user);
if (!$userInfo) {
throw new RuntimeException("User doesn't exist: '{$user}'");
}
$acme = new AcmeService(new AcmeClient($server, $keyPair), $keyPair);
$this->logger->info("Registering with ACME server " . substr($server, 8) . " ...");

15
src/Config.php Normal file
View File

@@ -0,0 +1,15 @@
<?php
namespace Kelunik\AcmeClient;
class Config {
private $config;
public function __construct(array $config) {
$this->config = $config;
}
public function get($key) {
return isset($this->config[$key]) ? $this->config[$key] : null;
}
}

View File

@@ -1,27 +0,0 @@
<?php
namespace Kelunik\AcmeClient;
use RuntimeException;
class Configuration {
private $config;
public function __construct($file) {
$json = file_get_contents($file);
if (!$json) {
throw new RuntimeException("Couldn't read config file: '{$file}'");
}
$this->config = json_decode($json);
if (!$this->config) {
throw new RuntimeException("Couldn't read JSON: '{$json}'");
}
}
public function get($key) {
return isset($this->config->{$key}) ? $this->config->{$key} : null;
}
}

View File

@@ -1,16 +0,0 @@
<?php
namespace Kelunik\AcmeClient;
function commandToClass($command) {
return __NAMESPACE__ . "\\Commands\\" . ucfirst($command);
}
function getServer(Configuration $config = null) {
if ($config === null) {
$path = dirname(__DIR__) . "/data";
$config = new Configuration($path . "/account/config.json");
}
return $config->get("server");
}