diff --git a/compose.yaml b/compose.yaml index 414a51c..123172d 100644 --- a/compose.yaml +++ b/compose.yaml @@ -11,6 +11,8 @@ services: WOL_MAC: "${WOL_MAC}" WOL_BCAST: "${WOL_BCAST:-192.168.222.255}" # optional WOL_PORT: "${WOL_PORT:-9}" # optional + SSH_PUBLIC_KEY: "${SSH_PUBLIC_KEY}" + SSH_PRIVATE_KEY: "${SSH_PRIVATE_KEY}" restart: unless-stopped volumes: - /etc/localtime:/etc/localtime:ro diff --git a/scripts/auto-boot-ollama-host.lua b/scripts/auto-boot-ollama-host.lua index fa9e1e2..412356d 100644 --- a/scripts/auto-boot-ollama-host.lua +++ b/scripts/auto-boot-ollama-host.lua @@ -17,6 +17,8 @@ local CONTAINER_NAME = getenv("CONTAINER_NAME", "paperless-ai") local SINCE = getenv("SINCE", "0s") local OLLAMA_HOST = getenv("OLLAMA_HOST", "192.168.222.12") local OLLAMA_PORT = tonumber(getenv("OLLAMA_PORT", "11434")) +local SSH_PORT = tonumber(getenv("SSH_PORT", "22")) +local SSH_IDENTITY_FILE = getenv("SSH_IDENTITY_FILE", "/root/.ssh/id") -- e.g. "/path/to/id_rsa" local ERROR_PATTERN = getenv( "ERROR_PATTERN", ("connect EHOSTUNREACH %s:%d"):format(OLLAMA_HOST, OLLAMA_PORT) @@ -61,9 +63,6 @@ local function send_wol(mac_str, bcast_ip, port) return ok ~= nil, err end - - - -- Kept for reference; not used to keep parity with your minimal bash -- local function port_is_up(host, port, timeout_sec) -- local deadline = socket.gettime() + (timeout_sec or 1) @@ -103,6 +102,10 @@ local function main() -- else -- log("Timeout waiting for Ollama.") -- end + + if port_is_up(OLLAMA_HOST, SSH_PORT, 60) then + log("SSH is reachable. Starting ollama service...") + --ssh("wsl.exe -d Debian -- sudo systemctl enable --now ollama && sudo systemctl start ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE) end end