23 lines
1.1 KiB
PowerShell
23 lines
1.1 KiB
PowerShell
param(
|
|
[string]$NasUser = "y2keui",
|
|
[string]$NasHost = "comtropy.synology.me",
|
|
[int]$NasPort = 50022,
|
|
[string]$RemoteDir = "/volume1/docker/telegram-codex-bot",
|
|
[string]$SshKeyPath = "$env:USERPROFILE\.ssh\nas_codex_ed25519"
|
|
)
|
|
|
|
$ErrorActionPreference = "Stop"
|
|
|
|
$remote = "${NasUser}@${NasHost}"
|
|
$sshAuthArgs = @()
|
|
if ($SshKeyPath -and (Test-Path $SshKeyPath)) {
|
|
$sshAuthArgs = @("-i", $SshKeyPath, "-o", "IdentitiesOnly=yes")
|
|
}
|
|
$remotePath = "/usr/local/bin:/var/packages/ContainerManager/target/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
|
|
$remoteCommand = "export PATH='$remotePath'; cd '$RemoteDir' && " +
|
|
"(sudo /usr/local/bin/docker-compose ps || sudo /var/packages/ContainerManager/target/usr/bin/docker-compose ps || sudo docker compose ps) && " +
|
|
"echo '--- logs ---' && " +
|
|
"(sudo /usr/local/bin/docker-compose logs --tail=160 telegram-codex-bot || sudo /var/packages/ContainerManager/target/usr/bin/docker-compose logs --tail=160 telegram-codex-bot || sudo docker compose logs --tail=160 telegram-codex-bot)"
|
|
|
|
ssh @sshAuthArgs -tt -p $NasPort $remote $remoteCommand
|