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) 149d8b2191 Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
..
README.md Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
auto-boot-ollama-host.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
auto-boot-ollama-host.sh Update WOL_BCAST environment variable to a consistent default value 3 months ago
config.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
network.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
ollama_manager.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
ssh.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago
utils.lua Refactor auto-boot-ollama-host script into modular structure with separate configuration, network, SSH, and service management modules for improved maintainability and readability 3 months ago

README.md

Auto-Boot Ollama Host - Refactored Structure

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

File Structure

Main Script

  • auto-boot-ollama-host.lua - Original monolithic script
  • auto-boot-ollama-host-refactored.lua - New modular main script

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

ollama_manager.lua

Ollama service management:

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

Benefits of Refactoring

  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

Usage

To use the refactored version, simply run:

lua auto-boot-ollama-host-refactored.lua

The refactored version maintains full compatibility with the original script while providing better structure and maintainability.