Fix user requirement in setup, cleanup.
This commit is contained in:
@@ -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
15
src/Config.php
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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");
|
||||
}
|
||||
Reference in New Issue
Block a user