mirror of
https://github.com/vitodeploy/vito.git
synced 2025-04-19 09:51:37 +00:00
fix read file
This commit is contained in:
parent
72b37c56fd
commit
5ab6617b5d
@ -93,7 +93,7 @@ public function write($buf): void
|
||||
public function getContent(): ?string
|
||||
{
|
||||
if ($this->is_remote) {
|
||||
return $this->server->os()->readFile($this->name, 150);
|
||||
return $this->server->os()->tail($this->name, 150);
|
||||
}
|
||||
|
||||
if (Storage::disk($this->disk)->exists($this->name)) {
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
use App\Exceptions\SourceControlIsNotConnected;
|
||||
use App\SiteTypes\SiteType;
|
||||
use App\SSH\Services\Webserver\Webserver;
|
||||
use Illuminate\Database\Eloquent\Factories\HasFactory;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||
@ -185,7 +186,9 @@ public function php(): ?Service
|
||||
|
||||
public function changePHPVersion($version): void
|
||||
{
|
||||
$this->server->webserver()->handler()->changePHPVersion($this, $version);
|
||||
/** @var Webserver $handler */
|
||||
$handler = $this->server->webserver()->handler();
|
||||
$handler->changePHPVersion($this, $version);
|
||||
$this->php_version = $version;
|
||||
$this->save();
|
||||
}
|
||||
|
@ -108,18 +108,22 @@ public function editFile(string $path, ?string $content = null): void
|
||||
);
|
||||
}
|
||||
|
||||
public function readFile(string $path, ?int $lastLines = null): string
|
||||
public function readFile(string $path): string
|
||||
{
|
||||
$params = [
|
||||
'path' => $path,
|
||||
];
|
||||
|
||||
if ($lastLines !== null) {
|
||||
$params['lines'] = $lastLines;
|
||||
}
|
||||
|
||||
return $this->server->ssh()->exec(
|
||||
$this->getScript('read-file.sh', $params)
|
||||
$this->getScript('read-file.sh', [
|
||||
'path' => $path,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
public function tail(string $path, int $lines): string
|
||||
{
|
||||
return $this->server->ssh()->exec(
|
||||
$this->getScript('tail.sh', [
|
||||
'path' => $path,
|
||||
'lines' => $lines,
|
||||
])
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -1,7 +1 @@
|
||||
if [ -f __path__ ]; then
|
||||
if [ -n __lines__ ]; then
|
||||
sudo tail -n __lines__ __path__
|
||||
else
|
||||
sudo cat __path__
|
||||
fi
|
||||
fi
|
||||
[ -f __path__ ] && sudo cat __path__
|
||||
|
1
app/SSH/OS/scripts/tail.sh
Normal file
1
app/SSH/OS/scripts/tail.sh
Normal file
@ -0,0 +1 @@
|
||||
sudo tail -n __lines__ __path__
|
Loading…
x
Reference in New Issue
Block a user