Add SSH_USER environment variable to configuration and update SSH command references in the script
This commit is contained in:
@@ -15,6 +15,7 @@ services:
|
|||||||
CONTAINER_NAME: "${CONTAINER_NAME:-paperless-ai}"
|
CONTAINER_NAME: "${CONTAINER_NAME:-paperless-ai}"
|
||||||
OLLAMA_HOST: "${OLLAMA_HOST:-192.168.222.12}"
|
OLLAMA_HOST: "${OLLAMA_HOST:-192.168.222.12}"
|
||||||
OLLAMA_PORT: "${OLLAMA_PORT:-11434}"
|
OLLAMA_PORT: "${OLLAMA_PORT:-11434}"
|
||||||
|
SSH_USER: "${SSH_USER:-user}"
|
||||||
SINCE: "${SINCE:-0s}"
|
SINCE: "${SINCE:-0s}"
|
||||||
WOL_MAC: "${WOL_MAC}"
|
WOL_MAC: "${WOL_MAC}"
|
||||||
WOL_BCAST: "${WOL_BCAST:-192.168.222.255}" # optional
|
WOL_BCAST: "${WOL_BCAST:-192.168.222.255}" # optional
|
||||||
|
|||||||
@@ -38,6 +38,7 @@ local SINCE = getenv("SINCE", "0s")
|
|||||||
local OLLAMA_HOST = getenv("OLLAMA_HOST", "192.168.222.12")
|
local OLLAMA_HOST = getenv("OLLAMA_HOST", "192.168.222.12")
|
||||||
local OLLAMA_PORT = tonumber(getenv("OLLAMA_PORT", "11434"))
|
local OLLAMA_PORT = tonumber(getenv("OLLAMA_PORT", "11434"))
|
||||||
local SSH_PORT = tonumber(getenv("SSH_PORT", "22"))
|
local SSH_PORT = tonumber(getenv("SSH_PORT", "22"))
|
||||||
|
local SSH_USER = getenv("SSH_USER", "user")
|
||||||
local SSH_IDENTITY_FILE = getenv("SSH_IDENTITY_FILE", "/root/.ssh/id_rsa") -- e.g. "/path/to/id_rsa"
|
local SSH_IDENTITY_FILE = getenv("SSH_IDENTITY_FILE", "/root/.ssh/id_rsa") -- e.g. "/path/to/id_rsa"
|
||||||
local ERROR_PATTERN = getenv(
|
local ERROR_PATTERN = getenv(
|
||||||
"ERROR_PATTERN",
|
"ERROR_PATTERN",
|
||||||
@@ -174,9 +175,9 @@ 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(5)
|
socket.sleep(5)
|
||||||
ssh("nssm start ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("nssm start ollama", SSH_USER, OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
--ssh('wsl.exe -d Debian -- sudo systemctl enable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl enable ollama', SSH_USER, OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
--ssh('wsl.exe -d Debian -- sudo systemctl start ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl start ollama', SSH_USER, 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(30)
|
socket.sleep(30)
|
||||||
@@ -190,10 +191,10 @@ local function main()
|
|||||||
if line:find(FINISH_PATTERN, 1, true) ~= nil and powered_on == true then
|
if line:find(FINISH_PATTERN, 1, true) ~= nil and powered_on == true then
|
||||||
log(("Detected finish pattern: %q"):format(FINISH_PATTERN))
|
log(("Detected finish pattern: %q"):format(FINISH_PATTERN))
|
||||||
log("Shutting down Ollama host to save power...")
|
log("Shutting down Ollama host to save power...")
|
||||||
ssh("nssm stop ollama", "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
ssh("nssm stop ollama", SSH_USER, OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
--ssh('wsl.exe -d Debian -- sudo systemctl disable ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl disable ollama', SSH_USER, OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
--ssh('wsl.exe -d Debian -- sudo systemctl stop ollama', "micro", OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
--ssh('wsl.exe -d Debian -- sudo systemctl stop ollama', SSH_USER, 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", SSH_USER, OLLAMA_HOST, SSH_PORT, SSH_IDENTITY_FILE)
|
||||||
socket.sleep(5)
|
socket.sleep(5)
|
||||||
powered_on = false
|
powered_on = false
|
||||||
break
|
break
|
||||||
|
|||||||
Reference in New Issue
Block a user