diff --git a/CHANGELOG.md b/CHANGELOG.md index 622528589..6efd4f0e4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. ## 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 * 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. diff --git a/app/Repositories/NodeRepository.php b/app/Repositories/NodeRepository.php index 2d579f274..ace645de4 100644 --- a/app/Repositories/NodeRepository.php +++ b/app/Repositories/NodeRepository.php @@ -106,6 +106,7 @@ class NodeRepository { 'memory_overallocate' => 'numeric|min:-1', 'disk' => 'numeric|min:1', 'disk_overallocate' => 'numeric|min:-1', + 'upload_size' => 'numeric|min:0', 'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/', 'daemonSFTP' => 'numeric|between:1,65535', 'daemonListen' => 'numeric|between:1,65535', @@ -151,8 +152,43 @@ class NodeRepository { unset($data['reset_secret']); } - // Store the Data - return $node->update($data); + $oldDaemonKey = $node->daemonSecret; + $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.'); + } } diff --git a/resources/views/admin/nodes/view.blade.php b/resources/views/admin/nodes/view.blade.php index df81a56ed..734e8e4a2 100644 --- a/resources/views/admin/nodes/view.blade.php +++ b/resources/views/admin/nodes/view.blade.php @@ -255,7 +255,7 @@