Skip to content

Commit 1eb1f96

Browse files
committed
Add support for updating the daemon's configuration file automatically.
1 parent 72ad6d5 commit 1eb1f96

File tree

3 files changed

+42
-3
lines changed

3 files changed

+42
-3
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@ This file is a running track of new features and fixes to each version of the pa
44
This project follows [Semantic Versioning](http://semver.org) guidelines.
55

66
## v0.5.4 (Bodacious Boreopterus)
7+
### Added
8+
* 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.
9+
710
### Changed
811
* File uploads now account for a maximum file size that is assigned for the daemon, and gives cleaner errors when that limit is reached.
912
* File upload limit can now be controlled from the panel.

app/Repositories/NodeRepository.php

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,7 @@ public function update($id, array $data)
106106
'memory_overallocate' => 'numeric|min:-1',
107107
'disk' => 'numeric|min:1',
108108
'disk_overallocate' => 'numeric|min:-1',
109+
'upload_size' => 'numeric|min:0',
109110
'daemonBase' => 'regex:/^([\/][\d\w.\-\/]+)$/',
110111
'daemonSFTP' => 'numeric|between:1,65535',
111112
'daemonListen' => 'numeric|between:1,65535',
@@ -151,8 +152,43 @@ public function update($id, array $data)
151152
unset($data['reset_secret']);
152153
}
153154

154-
// Store the Data
155-
return $node->update($data);
155+
$oldDaemonKey = $node->daemonSecret;
156+
$node->update($data);
157+
try {
158+
$client = Models\Node::guzzleRequest($node->id);
159+
$client->request('PATCH', '/config', [
160+
'headers' => [
161+
'X-Access-Token' => $oldDaemonKey,
162+
],
163+
'json' => [
164+
'web' => [
165+
'listen' => $node->daemonListen,
166+
'ssl' => [
167+
'enabled' => ($node->scheme === 'https'),
168+
'certificate' => '/etc/letsencrypt/live/' . $node->fqdn .'/fullchain.pem',
169+
'key' => '/etc/letsencrypt/live/' . $node->fqdn . '/privkey.pem',
170+
],
171+
],
172+
'sftp' => [
173+
'path' => $node->daemonBase,
174+
'port' => $node->daemonSFTP,
175+
],
176+
'remote' => [
177+
'base' => config('app.url'),
178+
'download' => route('remote.download'),
179+
'installed' => route('remote.install'),
180+
],
181+
'uploads' => [
182+
'size_limit' => $node->upload_size,
183+
],
184+
'keys' => [
185+
$node->daemonSecret,
186+
]
187+
],
188+
]);
189+
} catch (\Exception $ex) {
190+
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.');
191+
}
156192

157193
}
158194

resources/views/admin/nodes/view.blade.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -255,7 +255,7 @@
255255
<div class="col-xs-6">
256256
<div class="row">
257257
<div class="form-group col-md-12">
258-
<label for="reset_secret" class="control-label"><span class="label label-warning"><i class="fa fa-power-off"></i></span> Reset Daemon Key</label>
258+
<label for="reset_secret" class="control-label">Reset Daemon Key</label>
259259
<div style="padding: 7px 0;">
260260
<input type="checkbox" name="reset_secret" id="reset_secret" /> Reset Daemon Master Key
261261
</div>

0 commit comments

Comments
 (0)