From ef6cfd47c3205756b21eeea3a9321e77ef4d0f6a Mon Sep 17 00:00:00 2001 From: ayntk-ai <122374094+ayntk-ai@users.noreply.github.com> Date: Thu, 15 Aug 2024 00:51:45 +0200 Subject: [PATCH] add check if timezone was actually changed --- app/Livewire/Server/Form.php | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/app/Livewire/Server/Form.php b/app/Livewire/Server/Form.php index 54cdf7a14..daf21614b 100644 --- a/app/Livewire/Server/Form.php +++ b/app/Livewire/Server/Form.php @@ -267,15 +267,32 @@ class Form extends Component "cat /etc/timezone 2>/dev/null || echo 'Unable to read /etc/timezone'", ]; - instant_remote_process($commands, $this->server); - + ray('Commands to be executed:', $commands); + + $result = instant_remote_process($commands, $this->server); + ray('Result of instant_remote_process:', $result); + + // Check if the timezone was actually changed + $newTimezone = trim(instant_remote_process(["date +%Z"], $this->server, false)); + ray('New timezone after update:', $newTimezone); + + if ($newTimezone !== $value) { + ray('Timezone update failed. New timezone does not match requested value.'); + $this->dispatch('error', 'Failed to update server timezone. The server reported a different timezone than requested.'); + return false; + } + + ray('Updating server settings'); $this->server->settings->server_timezone = $value; $this->server->settings->save(); + ray('Server settings updated'); + ray('Timezone update completed successfully'); return true; } catch (\Exception $e) { - $this->dispatch('error', $e->getMessage()); + ray('Exception caught:', $e->getMessage()); + $this->dispatch('error', 'Failed to update server timezone: ' . $e->getMessage()); return false; } } -} +} \ No newline at end of file