Add support for updating the daemon's configuration file automatically.

This commit is contained in:
Dane Everitt 2016-12-01 18:33:32 -05:00
parent 72ad6d5c87
commit 1eb1f96e71
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
3 changed files with 42 additions and 3 deletions

View File

@ -4,6 +4,9 @@ This file is a running track of new features and fixes to each version of the pa
This project follows [Semantic Versioning](http://semver.org) guidelines. This project follows [Semantic Versioning](http://semver.org) guidelines.
## v0.5.4 (Bodacious Boreopterus) ## v0.5.4 (Bodacious Boreopterus)
### Added
* Changing node configuration values now automatically makes a call to the daemon and updates the configuration there. Changing daemon tokens now does not require any intervention, and takes effect immediately. SSL & Port configurations will still require a daemon reboot.
### Changed ### Changed
* File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached. * File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached.
* File upload limit can now be controlled from the panel. * File upload limit can now be controlled from the panel.

View File

@ -106,6 +106,7 @@ class NodeRepository {
'memory_overallocate' => 'numeric|min:-1', 'memory_overallocate' => 'numeric|min:-1',
'disk' => 'numeric|min:1', 'disk' => 'numeric|min:1',
'disk_overallocate' => 'numeric|min:-1', 'disk_overallocate' => 'numeric|min:-1',
'upload_size' => 'numeric|min:0',
'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/', 'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/',
'daemonSFTP' => 'numeric|between:1,65535', 'daemonSFTP' => 'numeric|between:1,65535',
'daemonListen' => 'numeric|between:1,65535', 'daemonListen' => 'numeric|between:1,65535',
@ -151,8 +152,43 @@ class NodeRepository {
unset($data['reset_secret']); unset($data['reset_secret']);
} }
// Store the Data $oldDaemonKey = $node->daemonSecret;
return $node->update($data); $node->update($data);
try {
$client = Models\Node::guzzleRequest($node->id);
$client->request('PATCH', '/config', [
'headers' => [
'X-Access-Token' => $oldDaemonKey,
],
'json' => [
'web' => [
'listen' => $node->daemonListen,
'ssl' => [
'enabled' => ($node->scheme === 'https'),
'certificate' => '/etc/letsencrypt/live/' . $node->fqdn .'/fullchain.pem',
'key' => '/etc/letsencrypt/live/' . $node->fqdn . '/privkey.pem',
],
],
'sftp' => [
'path' => $node->daemonBase,
'port' => $node->daemonSFTP,
],
'remote' => [
'base' => config('app.url'),
'download' => route('remote.download'),
'installed' => route('remote.install'),
],
'uploads' => [
'size_limit' => $node->upload_size,
],
'keys' => [
$node->daemonSecret,
]
],
]);
} catch (\Exception $ex) {
throw new DisplayException('Failed to update the node configuration, however your changes have been saved to the database. You will need to manually update the configuration file for the node to apply these changes.');
}
} }

View File

@ -255,7 +255,7 @@
<div class="col-xs-6"> <div class="col-xs-6">
<div class="row"> <div class="row">
<div class="form-group col-md-12"> <div class="form-group col-md-12">
<label for="reset_secret" class="control-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Reset Daemon Key</label> <label for="reset_secret" class="control-label">Reset Daemon Key</label>
<div style="padding: 7px 0;"> <div style="padding: 7px 0;">
<input type="checkbox" name="reset_secret" id="reset_secret" /> Reset Daemon Master Key <input type="checkbox" name="reset_secret" id="reset_secret" /> Reset Daemon Master Key
</div> </div>