Fix SSH command quoting and improve ollama service management logic
This commit is contained in:
@@ -119,7 +119,7 @@ local function ssh(command, user, host, port, identity_file)
|
|||||||
table.insert(pieces, dest)
|
table.insert(pieces, dest)
|
||||||
|
|
||||||
-- Quote remote command so the local shell treats it as a single arg
|
-- Quote remote command so the local shell treats it as a single arg
|
||||||
table.insert(pieces, sq(command))
|
table.insert(pieces, command)
|
||||||
|
|
||||||
-- Join with spaces for os.execute
|
-- Join with spaces for os.execute
|
||||||
local function join(args)
|
local function join(args)
|
||||||
@@ -175,12 +175,12 @@ local function main()
|
|||||||
if port_is_up(OLLAMA_HOST, SSH_PORT, 60) then
|
if port_is_up(OLLAMA_HOST, SSH_PORT, 60) then
|
||||||
log("SSH is reachable. Starting ollama service...")
|
log("SSH is reachable. Starting ollama service...")
|
||||||
socket.sleep(2)
|
socket.sleep(2)
|
||||||
ssh("wsl.exe -d Debian -- 'sudo systemctl enable --now ollama && sudo systemctl start ollama'", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("wsl.exe -d Debian -- sudo systemctl enable --now ollama && sudo systemctl start ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
if (port_is_up(OLLAMA_HOST, OLLAMA_PORT, 90)) then
|
if (port_is_up(OLLAMA_HOST, OLLAMA_PORT, 90)) then
|
||||||
log("Ollama service is reachable again.")
|
log("Ollama service is reachable again.")
|
||||||
socket.sleep(120)
|
socket.sleep(120)
|
||||||
log("Shutting down Ollama host to save power...")
|
log("Shutting down Ollama host to save power...")
|
||||||
ssh("wsl.exe -d Debian -- 'sudo systemctl disable ollama && sudo systemctl stop ollama'", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("wsl.exe -d Debian -- sudo systemctl disable ollama && sudo systemctl stop ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
ssh("shutdown.exe /s /t 0", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("shutdown.exe /s /t 0", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
else
|
else
|
||||||
log("Timeout waiting for Ollama service to come up after SSH command.")
|
log("Timeout waiting for Ollama service to come up after SSH command.")
|
||||||
|
|||||||
Reference in New Issue
Block a user