From 5947ae80bb4763b852bcd6c3f7b092d9b25c29e3 Mon Sep 17 00:00:00 2001 From: Richard Anderson Date: Thu, 16 Jan 2025 20:03:53 +0000 Subject: [PATCH] Fix Deployment Script on Windows Clients (#433) * resolve issue with EOL * Manual Run * reverse change for manual run of tests * remove logging --- app/Actions/Site/UpdateDeploymentScript.php | 6 +++--- app/Models/DeploymentScript.php | 9 +++++++++ app/SSH/OS/OS.php | 2 +- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/Actions/Site/UpdateDeploymentScript.php b/app/Actions/Site/UpdateDeploymentScript.php index 47de15b..f6c29c9 100755 --- a/app/Actions/Site/UpdateDeploymentScript.php +++ b/app/Actions/Site/UpdateDeploymentScript.php @@ -12,9 +12,9 @@ class UpdateDeploymentScript */ public function update(Site $site, array $input): void { - $site->deploymentScript()->update([ - 'content' => $input['script'], - ]); + $script = $site->deploymentScript; + $script->content = $input['script']; + $script->save(); } /** diff --git a/app/Models/DeploymentScript.php b/app/Models/DeploymentScript.php index 4dd0a02..d47b074 100644 --- a/app/Models/DeploymentScript.php +++ b/app/Models/DeploymentScript.php @@ -15,6 +15,15 @@ class DeploymentScript extends AbstractModel { use HasFactory; + protected static function boot(): void + { + parent::boot(); + + static::saving(function ($deploymentScript) { + $deploymentScript->content = str_replace("\r\n", "\n", $deploymentScript->content); + }); + } + protected $fillable = [ 'site_id', 'name', diff --git a/app/SSH/OS/OS.php b/app/SSH/OS/OS.php index fc65149..3ce5fa0 100644 --- a/app/SSH/OS/OS.php +++ b/app/SSH/OS/OS.php @@ -162,7 +162,7 @@ public function runScript(string $path, string $script, ?ServerLog $serverLog, ? } $command = ''; foreach ($variables as $key => $variable) { - $command .= "$key=$variable".PHP_EOL; + $command .= "$key=$variable\n"; } $command .= $this->getScript('run-script.sh', [ 'path' => $path,