Shellmin::ConfigManager
Configuration and connection management for Shellmin
This class handles all configuration operations and provides thread-safe access to configuration data and connection management.
Thread Safety
All operations are thread-safe using mutex synchronization to prevent race conditions when accessing shared configuration state.
Configuration File
Configuration is stored in YAML format at ~/.shellmin/config.yaml:
hosts:
- name: web-host
host: 192.168.1.100
user: admin
Modern configuration manager with advanced caching
Constructors
Modern constructor with dependency injection
Instance methods
Set new configuration (thread-safe)
Replaces the entire configuration with a new one.
Load configuration from file with multiple format support
Attempts to load configuration from the default path or SHELLMIN_CONFIG. Supports YAML, JSON, and TOML formats with automatic detection. Returns true on success, false on failure.
Error Handling
- YAML::ParseException: Invalid YAML syntax
- JSON::ParseException: Invalid JSON syntax
- File::Error: File access issues
Save current configuration to file
Writes the current configuration to the default path. Creates parent directories if they don't exist.
Update configuration atomically
Provides a thread-safe way to modify configuration using a block. The block receives the current config and should return the new config.
config_manager.update_config do |config|
config["new_key"] = YAML.parse("new_value")
config
end