You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
Bastian (BaM) 127954b2fb Fix command execution in network.send_wol to handle return values correctly. 3 months ago
..
README.md Add README.md for Auto-Boot Ollama Host project 3 months ago
auto-boot-ollama-host.lua Refactor error handling and service management in auto-boot-ollama-host.lua and ollama_manager.lua. Update functions to return service state alongside power state, improving control over service startup and shutdown based on user session status. 3 months ago
config.lua Refactor to use LuaJIT and improve performance 3 months ago
network.lua Fix command execution in network.send_wol to handle return values correctly. 3 months ago
ollama_manager.lua Refactor error handling and service management in auto-boot-ollama-host.lua and ollama_manager.lua. Update functions to return service state alongside power state, improving control over service startup and shutdown based on user session status. 3 months ago
session_check.lua Add desktop session detection to auto-boot-ollama-host script 3 months ago
ssh.lua Add SSH configuration options to support environment variables for strict host key checking and known hosts file path in ssh.lua and compose.yaml 3 months ago
utils.lua Refactor to use LuaJIT and improve performance 3 months ago

README.md

Auto-Boot Ollama Host

This directory contains the auto-boot-ollama-host script, organized into multiple modules for better maintainability and structure.

File Structure

Main Script

  • auto-boot-ollama-host.lua - Main script that orchestrates all functionality

Modules

config.lua

Handles all environment variable configuration with sensible defaults:

  • Docker configuration (container name, since time)
  • Ollama service configuration (host, port)
  • SSH configuration (port, user, identity file)
  • Pattern configuration (error and finish patterns)
  • Wake-on-LAN configuration

utils.lua

Provides utility functions:

  • log(msg) - Timestamped logging
  • getenv(name, def) - Environment variable with default

network.lua

Network-related functionality:

  • port_is_up(host, port, timeout) - Check if TCP port is accessible
  • send_wol(mac, bcast_ip, port) - Send Wake-on-LAN magic packet

ssh.lua

SSH command execution:

  • execute(command, user, host, port, identity_file) - Execute remote SSH command
  • execute_with_output(command, user, host, port, identity_file) - Execute SSH command and return output

ollama_manager.lua

Ollama service management:

  • start_service(config) - Start Ollama service via SSH
  • stop_service_and_shutdown(config) - Stop service and shutdown host

session_check.lua

Windows desktop session detection:

  • is_user_logged_in_enhanced(config) - Check if user is logged into desktop session

Benefits of Modular Structure

  1. Separation of Concerns: Each module has a single responsibility
  2. Reusability: Modules can be reused in other projects
  3. Testability: Individual modules can be unit tested
  4. Maintainability: Easier to locate and modify specific functionality
  5. Readability: Clear structure and organization
  6. Configuration: Centralized configuration management

New Features

Desktop Session Detection

The script includes Windows desktop session detection:

  • Checks if the SSH_USER is currently logged into a Windows desktop session
  • If user is logged in, skips Ollama startup/shutdown to avoid interruption
  • If user is not logged in, proceeds with normal operation

Usage

To use the script, simply run:

lua auto-boot-ollama-host.lua

The script provides a modular structure for better maintainability while maintaining all functionality.