fix: always show SSH access dialog in advanced settings

- SSH access dialog is now always displayed regardless of password or SSH keys
- Added step indicator to SSH settings dialogs for consistency
- configure_ssh_settings() now accepts optional step_info parameter
- Updated documentation for SSH configuration functions

Fixes #9753
This commit is contained in:
MickLesk
2025-12-07 22:15:20 +01:00
parent 1cae72bdec
commit 38ea7dbba2
3 changed files with 234 additions and 126 deletions

View File

@ -8,103 +8,103 @@ This document provides a comprehensive reference of all environment variables us
### Core Container Variables ### Core Container Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | --------- | -------------------------------------------- | --------- | ----------- | ------------------ |
| `APP` | Application name (e.g., "plex", "nextcloud") | - | Environment | Throughout | | `APP` | Application name (e.g., "plex", "nextcloud") | - | Environment | Throughout |
| `NSAPP` | Namespace application name | `$APP` | Environment | Throughout | | `NSAPP` | Namespace application name | `$APP` | Environment | Throughout |
| `CTID` | Container ID | - | Environment | Container creation | | `CTID` | Container ID | - | Environment | Container creation |
| `CT_TYPE` | Container type ("install" or "update") | "install" | Environment | Entry point | | `CT_TYPE` | Container type ("install" or "update") | "install" | Environment | Entry point |
| `CT_NAME` | Container name | `$APP` | Environment | Container creation | | `CT_NAME` | Container name | `$APP` | Environment | Container creation |
### Operating System Variables ### Operating System Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | -------------- | -------------------------- | -------------- | --------------- | ------------------ |
| `var_os` | Operating system selection | "debian" | base_settings() | OS selection | | `var_os` | Operating system selection | "debian" | base_settings() | OS selection |
| `var_version` | OS version | "12" | base_settings() | Template selection | | `var_version` | OS version | "12" | base_settings() | Template selection |
| `var_template` | Template name | Auto-generated | base_settings() | Template download | | `var_template` | Template name | Auto-generated | base_settings() | Template download |
### Resource Configuration Variables ### Resource Configuration Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ------------ | ----------------------- | ----------- | --------------- | ------------------ |
| `var_cpu` | CPU cores | "2" | base_settings() | Container creation | | `var_cpu` | CPU cores | "2" | base_settings() | Container creation |
| `var_ram` | RAM in MB | "2048" | base_settings() | Container creation | | `var_ram` | RAM in MB | "2048" | base_settings() | Container creation |
| `var_disk` | Disk size in GB | "8" | base_settings() | Container creation | | `var_disk` | Disk size in GB | "8" | base_settings() | Container creation |
| `DISK_SIZE` | Disk size (alternative) | `$var_disk` | Environment | Container creation | | `DISK_SIZE` | Disk size (alternative) | `$var_disk` | Environment | Container creation |
| `CORE_COUNT` | CPU cores (alternative) | `$var_cpu` | Environment | Container creation | | `CORE_COUNT` | CPU cores (alternative) | `$var_cpu` | Environment | Container creation |
| `RAM_SIZE` | RAM size (alternative) | `$var_ram` | Environment | Container creation | | `RAM_SIZE` | RAM size (alternative) | `$var_ram` | Environment | Container creation |
### Network Configuration Variables ### Network Configuration Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ------------- | ------------------------------- | -------------- | --------------- | -------------- |
| `var_net` | Network interface | "vmbr0" | base_settings() | Network config | | `var_net` | Network interface | "vmbr0" | base_settings() | Network config |
| `var_bridge` | Bridge interface | "vmbr0" | base_settings() | Network config | | `var_bridge` | Bridge interface | "vmbr0" | base_settings() | Network config |
| `var_gateway` | Gateway IP | "192.168.1.1" | base_settings() | Network config | | `var_gateway` | Gateway IP | "192.168.1.1" | base_settings() | Network config |
| `var_ip` | Container IP address | - | User input | Network config | | `var_ip` | Container IP address | - | User input | Network config |
| `var_ipv6` | IPv6 address | - | User input | Network config | | `var_ipv6` | IPv6 address | - | User input | Network config |
| `var_vlan` | VLAN ID | - | User input | Network config | | `var_vlan` | VLAN ID | - | User input | Network config |
| `var_mtu` | MTU size | "1500" | base_settings() | Network config | | `var_mtu` | MTU size | "1500" | base_settings() | Network config |
| `var_mac` | MAC address | Auto-generated | base_settings() | Network config | | `var_mac` | MAC address | Auto-generated | base_settings() | Network config |
| `NET` | Network interface (alternative) | `$var_net` | Environment | Network config | | `NET` | Network interface (alternative) | `$var_net` | Environment | Network config |
| `BRG` | Bridge interface (alternative) | `$var_bridge` | Environment | Network config | | `BRG` | Bridge interface (alternative) | `$var_bridge` | Environment | Network config |
| `GATE` | Gateway IP (alternative) | `$var_gateway` | Environment | Network config | | `GATE` | Gateway IP (alternative) | `$var_gateway` | Environment | Network config |
| `IPV6_METHOD` | IPv6 configuration method | "none" | Environment | Network config | | `IPV6_METHOD` | IPv6 configuration method | "none" | Environment | Network config |
| `VLAN` | VLAN ID (alternative) | `$var_vlan` | Environment | Network config | | `VLAN` | VLAN ID (alternative) | `$var_vlan` | Environment | Network config |
| `MTU` | MTU size (alternative) | `$var_mtu` | Environment | Network config | | `MTU` | MTU size (alternative) | `$var_mtu` | Environment | Network config |
| `MAC` | MAC address (alternative) | `$var_mac` | Environment | Network config | | `MAC` | MAC address (alternative) | `$var_mac` | Environment | Network config |
### Storage Configuration Variables ### Storage Configuration Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ----------------------- | ------------------------------- | ------------------------ | ---------------- | ----------------- |
| `var_template_storage` | Storage for templates | - | select_storage() | Template storage | | `var_template_storage` | Storage for templates | - | select_storage() | Template storage |
| `var_container_storage` | Storage for container disks | - | select_storage() | Container storage | | `var_container_storage` | Storage for container disks | - | select_storage() | Container storage |
| `TEMPLATE_STORAGE` | Template storage (alternative) | `$var_template_storage` | Environment | Template storage | | `TEMPLATE_STORAGE` | Template storage (alternative) | `$var_template_storage` | Environment | Template storage |
| `CONTAINER_STORAGE` | Container storage (alternative) | `$var_container_storage` | Environment | Container storage | | `CONTAINER_STORAGE` | Container storage (alternative) | `$var_container_storage` | Environment | Container storage |
### Feature Flags ### Feature Flags
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | --------------------- | --------------------------- | ------- | --------------- | ------------------ |
| `ENABLE_FUSE` | Enable FUSE support | "true" | base_settings() | Container features | | `ENABLE_FUSE` | Enable FUSE support | "true" | base_settings() | Container features |
| `ENABLE_TUN` | Enable TUN/TAP support | "true" | base_settings() | Container features | | `ENABLE_TUN` | Enable TUN/TAP support | "true" | base_settings() | Container features |
| `ENABLE_KEYCTL` | Enable keyctl support | "true" | base_settings() | Container features | | `ENABLE_KEYCTL` | Enable keyctl support | "true" | base_settings() | Container features |
| `ENABLE_MOUNT` | Enable mount support | "true" | base_settings() | Container features | | `ENABLE_MOUNT` | Enable mount support | "true" | base_settings() | Container features |
| `ENABLE_NESTING` | Enable nesting support | "false" | base_settings() | Container features | | `ENABLE_NESTING` | Enable nesting support | "false" | base_settings() | Container features |
| `ENABLE_PRIVILEGED` | Enable privileged mode | "false" | base_settings() | Container features | | `ENABLE_PRIVILEGED` | Enable privileged mode | "false" | base_settings() | Container features |
| `ENABLE_UNPRIVILEGED` | Enable unprivileged mode | "true" | base_settings() | Container features | | `ENABLE_UNPRIVILEGED` | Enable unprivileged mode | "true" | base_settings() | Container features |
| `VERBOSE` | Enable verbose output | "false" | Environment | Logging | | `VERBOSE` | Enable verbose output | "false" | Environment | Logging |
| `SSH` | Enable SSH key provisioning | "true" | base_settings() | SSH setup | | `SSH` | Enable SSH key provisioning | "true" | base_settings() | SSH setup |
### GPU Passthrough Variables ### GPU Passthrough Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ----------------- | ----------------------------- | ------- | -------------------- | --------------- |
| `GPU_APPS` | List of apps that support GPU | - | Environment | GPU detection | | `GPU_APPS` | List of apps that support GPU | - | Environment | GPU detection |
| `var_gpu` | GPU selection | - | User input | GPU passthrough | | `var_gpu` | GPU selection | - | User input | GPU passthrough |
| `var_gpu_type` | GPU type (intel/amd/nvidia) | - | detect_gpu_devices() | GPU passthrough | | `var_gpu_type` | GPU type (intel/amd/nvidia) | - | detect_gpu_devices() | GPU passthrough |
| `var_gpu_devices` | GPU device list | - | detect_gpu_devices() | GPU passthrough | | `var_gpu_devices` | GPU device list | - | detect_gpu_devices() | GPU passthrough |
### API and Diagnostics Variables ### API and Diagnostics Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ------------- | ------------------------ | --------- | ----------- | ----------------- |
| `DIAGNOSTICS` | Enable diagnostics mode | "false" | Environment | Diagnostics | | `DIAGNOSTICS` | Enable diagnostics mode | "false" | Environment | Diagnostics |
| `METHOD` | Installation method | "install" | Environment | Installation flow | | `METHOD` | Installation method | "install" | Environment | Installation flow |
| `RANDOM_UUID` | Random UUID for tracking | - | Environment | Logging | | `RANDOM_UUID` | Random UUID for tracking | - | Environment | Logging |
| `API_TOKEN` | Proxmox API token | - | Environment | API calls | | `API_TOKEN` | Proxmox API token | - | Environment | API calls |
| `API_USER` | Proxmox API user | - | Environment | API calls | | `API_USER` | Proxmox API user | - | Environment | API calls |
### Settings Persistence Variables ### Settings Persistence Variables
| Variable | Description | Default | Set In | Used In | | Variable | Description | Default | Set In | Used In |
|----------|-------------|---------|---------|---------| | ------------------- | -------------------------- | ------------------------------------------------- | ----------- | -------------------- |
| `SAVE_DEFAULTS` | Save settings as defaults | "false" | User input | Settings persistence | | `SAVE_DEFAULTS` | Save settings as defaults | "false" | User input | Settings persistence |
| `SAVE_APP_DEFAULTS` | Save app-specific defaults | "false" | User input | Settings persistence | | `SAVE_APP_DEFAULTS` | Save app-specific defaults | "false" | User input | Settings persistence |
| `DEFAULT_VARS_FILE` | Path to default.vars | "/usr/local/community-scripts/default.vars" | Environment | Settings persistence | | `DEFAULT_VARS_FILE` | Path to default.vars | "/usr/local/community-scripts/default.vars" | Environment | Settings persistence |
| `APP_DEFAULTS_FILE` | Path to app.vars | "/usr/local/community-scripts/defaults/$APP.vars" | Environment | Settings persistence | | `APP_DEFAULTS_FILE` | Path to app.vars | "/usr/local/community-scripts/defaults/$APP.vars" | Environment | Settings persistence |
## Variable Precedence Chain ## Variable Precedence Chain
@ -152,6 +152,7 @@ export SSH="true"
## Environment Variable Usage Patterns ## Environment Variable Usage Patterns
### 1. Container Creation ### 1. Container Creation
```bash ```bash
# Basic container creation # Basic container creation
export APP="nextcloud" export APP="nextcloud"
@ -170,6 +171,7 @@ export var_container_storage="local"
``` ```
### 2. GPU Passthrough ### 2. GPU Passthrough
```bash ```bash
# Enable GPU passthrough # Enable GPU passthrough
export GPU_APPS="plex,jellyfin,emby" export GPU_APPS="plex,jellyfin,emby"
@ -178,6 +180,7 @@ export ENABLE_PRIVILEGED="true"
``` ```
### 3. Advanced Network Configuration ### 3. Advanced Network Configuration
```bash ```bash
# VLAN and IPv6 configuration # VLAN and IPv6 configuration
export var_vlan="100" export var_vlan="100"
@ -187,6 +190,7 @@ export var_mtu="9000"
``` ```
### 4. Storage Configuration ### 4. Storage Configuration
```bash ```bash
# Custom storage locations # Custom storage locations
export var_template_storage="nfs-storage" export var_template_storage="nfs-storage"
@ -206,6 +210,7 @@ The script validates variables at several points:
## Common Variable Combinations ## Common Variable Combinations
### Development Container ### Development Container
```bash ```bash
export APP="dev-container" export APP="dev-container"
export CTID="200" export CTID="200"
@ -220,6 +225,7 @@ export ENABLE_PRIVILEGED="true"
``` ```
### Media Server with GPU ### Media Server with GPU
```bash ```bash
export APP="plex" export APP="plex"
export CTID="300" export CTID="300"
@ -235,6 +241,7 @@ export ENABLE_PRIVILEGED="true"
``` ```
### Lightweight Service ### Lightweight Service
```bash ```bash
export APP="nginx" export APP="nginx"
export CTID="400" export CTID="400"

View File

@ -9,30 +9,35 @@ This document provides a comprehensive reference of all functions in `build.func
### Initialization Functions ### Initialization Functions
#### `start()` #### `start()`
**Purpose**: Main entry point when build.func is sourced or executed **Purpose**: Main entry point when build.func is sourced or executed
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Detects execution context (Proxmox host vs container) - Detects execution context (Proxmox host vs container)
- Captures hard environment variables - Captures hard environment variables
- Sets CT_TYPE based on context - Sets CT_TYPE based on context
- Routes to appropriate workflow (install_script or update_script) - Routes to appropriate workflow (install_script or update_script)
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `CT_TYPE`, `APP`, `CTID` **Environment Variables Used**: `CT_TYPE`, `APP`, `CTID`
#### `variables()` #### `variables()`
**Purpose**: Load and resolve all configuration variables using precedence chain **Purpose**: Load and resolve all configuration variables using precedence chain
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Loads app-specific .vars file - Loads app-specific .vars file
- Loads global default.vars file - Loads global default.vars file
- Applies variable precedence chain - Applies variable precedence chain
- Sets all configuration variables - Sets all configuration variables
**Dependencies**: `base_settings()` **Dependencies**: `base_settings()`
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `base_settings()` #### `base_settings()`
**Purpose**: Set built-in default values for all configuration variables **Purpose**: Set built-in default values for all configuration variables
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
@ -43,28 +48,33 @@ This document provides a comprehensive reference of all functions in `build.func
### UI and Menu Functions ### UI and Menu Functions
#### `install_script()` #### `install_script()`
**Purpose**: Main installation workflow coordinator **Purpose**: Main installation workflow coordinator
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Displays installation mode selection menu - Displays installation mode selection menu
- Coordinates the entire installation process - Coordinates the entire installation process
- Handles user interaction and validation - Handles user interaction and validation
**Dependencies**: `variables()`, `build_container()`, `default_var_settings()` **Dependencies**: `variables()`, `build_container()`, `default_var_settings()`
**Environment Variables Used**: `APP`, `CTID`, `var_hostname` **Environment Variables Used**: `APP`, `CTID`, `var_hostname`
#### `advanced_settings()` #### `advanced_settings()`
**Purpose**: Provide advanced configuration options via whiptail menus **Purpose**: Provide advanced configuration options via whiptail menus
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Displays whiptail menus for configuration - Displays whiptail menus for configuration
- Updates configuration variables based on user input - Updates configuration variables based on user input
- Validates user selections - Validates user selections
**Dependencies**: `select_storage()`, `detect_gpu_devices()` **Dependencies**: `select_storage()`, `detect_gpu_devices()`
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `settings_menu()` #### `settings_menu()`
**Purpose**: Display and handle settings configuration menu **Purpose**: Display and handle settings configuration menu
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
@ -75,58 +85,68 @@ This document provides a comprehensive reference of all functions in `build.func
### Storage Functions ### Storage Functions
#### `select_storage()` #### `select_storage()`
**Purpose**: Handle storage selection for templates and containers **Purpose**: Handle storage selection for templates and containers
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Resolves storage preselection - Resolves storage preselection
- Prompts user for storage selection if needed - Prompts user for storage selection if needed
- Validates storage availability - Validates storage availability
- Sets var_template_storage and var_container_storage - Sets var_template_storage and var_container_storage
**Dependencies**: `resolve_storage_preselect()`, `choose_and_set_storage_for_file()` **Dependencies**: `resolve_storage_preselect()`, `choose_and_set_storage_for_file()`
**Environment Variables Used**: `var_template_storage`, `var_container_storage`, `TEMPLATE_STORAGE`, `CONTAINER_STORAGE` **Environment Variables Used**: `var_template_storage`, `var_container_storage`, `TEMPLATE_STORAGE`, `CONTAINER_STORAGE`
#### `resolve_storage_preselect()` #### `resolve_storage_preselect()`
**Purpose**: Resolve preselected storage options **Purpose**: Resolve preselected storage options
**Parameters**: **Parameters**:
- `storage_type`: Type of storage (template or container) - `storage_type`: Type of storage (template or container)
**Returns**: Storage name if valid, empty if invalid **Returns**: Storage name if valid, empty if invalid
**Side Effects**: Validates storage availability **Side Effects**: Validates storage availability
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `var_template_storage`, `var_container_storage` **Environment Variables Used**: `var_template_storage`, `var_container_storage`
#### `choose_and_set_storage_for_file()` #### `choose_and_set_storage_for_file()`
**Purpose**: Interactive storage selection via whiptail **Purpose**: Interactive storage selection via whiptail
**Parameters**: **Parameters**:
- `storage_type`: Type of storage (template or container) - `storage_type`: Type of storage (template or container)
- `content_type`: Content type (vztmpl or rootdir) - `content_type`: Content type (vztmpl or rootdir)
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Displays whiptail menu - Displays whiptail menu
- Updates storage variables - Updates storage variables
- Validates selection - Validates selection
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `var_template_storage`, `var_container_storage` **Environment Variables Used**: `var_template_storage`, `var_container_storage`
### Container Creation Functions ### Container Creation Functions
#### `build_container()` #### `build_container()`
**Purpose**: Validate settings and prepare container creation **Purpose**: Validate settings and prepare container creation
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Validates all configuration - Validates all configuration
- Checks for conflicts - Checks for conflicts
- Prepares container configuration - Prepares container configuration
- Calls create_lxc_container() - Calls create_lxc_container()
**Dependencies**: `create_lxc_container()` **Dependencies**: `create_lxc_container()`
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `create_lxc_container()` #### `create_lxc_container()`
**Purpose**: Create the actual LXC container **Purpose**: Create the actual LXC container
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Creates LXC container with basic configuration - Creates LXC container with basic configuration
- Configures network settings - Configures network settings
- Sets up storage and mount points - Sets up storage and mount points
@ -134,108 +154,176 @@ This document provides a comprehensive reference of all functions in `build.func
- Sets resource limits - Sets resource limits
- Configures startup options - Configures startup options
- Starts container - Starts container
**Dependencies**: `configure_gpu_passthrough()`, `fix_gpu_gids()` **Dependencies**: `configure_gpu_passthrough()`, `fix_gpu_gids()`
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
### GPU and Hardware Functions ### GPU and Hardware Functions
#### `detect_gpu_devices()` #### `detect_gpu_devices()`
**Purpose**: Detect available GPU hardware on the system **Purpose**: Detect available GPU hardware on the system
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Scans for Intel, AMD, and NVIDIA GPUs - Scans for Intel, AMD, and NVIDIA GPUs
- Updates var_gpu_type and var_gpu_devices - Updates var_gpu_type and var_gpu_devices
- Determines GPU capabilities - Determines GPU capabilities
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `var_gpu_type`, `var_gpu_devices`, `GPU_APPS` **Environment Variables Used**: `var_gpu_type`, `var_gpu_devices`, `GPU_APPS`
#### `configure_gpu_passthrough()` #### `configure_gpu_passthrough()`
**Purpose**: Configure GPU passthrough for the container **Purpose**: Configure GPU passthrough for the container
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Adds GPU device entries to container config - Adds GPU device entries to container config
- Configures proper device permissions - Configures proper device permissions
- Sets up device mapping - Sets up device mapping
- Updates /etc/pve/lxc/<ctid>.conf - Updates /etc/pve/lxc/<ctid>.conf
**Dependencies**: `detect_gpu_devices()` **Dependencies**: `detect_gpu_devices()`
**Environment Variables Used**: `var_gpu`, `var_gpu_type`, `var_gpu_devices`, `CTID` **Environment Variables Used**: `var_gpu`, `var_gpu_type`, `var_gpu_devices`, `CTID`
#### `fix_gpu_gids()` #### `fix_gpu_gids()`
**Purpose**: Fix GPU group IDs after container creation **Purpose**: Fix GPU group IDs after container creation
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Updates GPU group IDs in container - Updates GPU group IDs in container
- Ensures proper GPU access permissions - Ensures proper GPU access permissions
- Configures video and render groups - Configures video and render groups
**Dependencies**: `configure_gpu_passthrough()` **Dependencies**: `configure_gpu_passthrough()`
**Environment Variables Used**: `CTID`, `var_gpu_type` **Environment Variables Used**: `CTID`, `var_gpu_type`
### SSH Configuration Functions
#### `configure_ssh_settings()`
**Purpose**: Interactive SSH key and access configuration wizard
**Parameters**:
- `step_info` (optional): Step indicator string (e.g., "Step 17/19") for consistent dialog headers
**Returns**: None
**Side Effects**:
- Creates temporary file for SSH keys
- Discovers and presents available SSH keys from host
- Allows manual key entry or folder/glob scanning
- Sets `SSH` variable to "yes" or "no" based on user selection
- Sets `SSH_AUTHORIZED_KEY` if manual key provided
- Populates `SSH_KEYS_FILE` with selected keys
**Dependencies**: `ssh_discover_default_files()`, `ssh_build_choices_from_files()`
**Environment Variables Used**: `SSH`, `SSH_AUTHORIZED_KEY`, `SSH_KEYS_FILE`
**SSH Key Source Options**:
1. `found` - Select from auto-detected host keys
2. `manual` - Paste a single public key
3. `folder` - Scan custom folder or glob pattern
4. `none` - No SSH keys
**Note**: The "Enable root SSH access?" dialog is always shown, regardless of whether SSH keys or password are configured. This ensures users can always enable SSH access even with automatic login.
#### `ssh_discover_default_files()`
**Purpose**: Discover SSH public key files on the host system
**Parameters**: None
**Returns**: Array of discovered key file paths
**Side Effects**: Scans common SSH key locations
**Dependencies**: None
**Environment Variables Used**: `var_ssh_import_glob`
#### `ssh_build_choices_from_files()`
**Purpose**: Build whiptail checklist choices from SSH key files
**Parameters**:
- Array of file paths to process
**Returns**: None
**Side Effects**:
- Sets `CHOICES` array for whiptail checklist
- Sets `COUNT` variable with number of keys found
- Creates `MAPFILE` for key tag to content mapping
**Dependencies**: None
**Environment Variables Used**: `CHOICES`, `COUNT`, `MAPFILE`
### Settings Persistence Functions ### Settings Persistence Functions
#### `default_var_settings()` #### `default_var_settings()`
**Purpose**: Offer to save current settings as defaults **Purpose**: Offer to save current settings as defaults
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Prompts user to save settings - Prompts user to save settings
- Saves to default.vars file - Saves to default.vars file
- Saves to app-specific .vars file - Saves to app-specific .vars file
**Dependencies**: `maybe_offer_save_app_defaults()` **Dependencies**: `maybe_offer_save_app_defaults()`
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `maybe_offer_save_app_defaults()` #### `maybe_offer_save_app_defaults()`
**Purpose**: Offer to save app-specific defaults **Purpose**: Offer to save app-specific defaults
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Prompts user to save app-specific settings - Prompts user to save app-specific settings
- Saves to app.vars file - Saves to app.vars file
- Updates app-specific configuration - Updates app-specific configuration
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `APP`, `SAVE_APP_DEFAULTS` **Environment Variables Used**: `APP`, `SAVE_APP_DEFAULTS`
### Utility Functions ### Utility Functions
#### `validate_settings()` #### `validate_settings()`
**Purpose**: Validate all configuration settings **Purpose**: Validate all configuration settings
**Parameters**: None **Parameters**: None
**Returns**: 0 if valid, 1 if invalid **Returns**: 0 if valid, 1 if invalid
**Side Effects**: **Side Effects**:
- Checks for configuration conflicts - Checks for configuration conflicts
- Validates resource limits - Validates resource limits
- Validates network configuration - Validates network configuration
- Validates storage configuration - Validates storage configuration
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `check_conflicts()` #### `check_conflicts()`
**Purpose**: Check for configuration conflicts **Purpose**: Check for configuration conflicts
**Parameters**: None **Parameters**: None
**Returns**: 0 if no conflicts, 1 if conflicts found **Returns**: 0 if no conflicts, 1 if conflicts found
**Side Effects**: **Side Effects**:
- Checks for conflicting settings - Checks for conflicting settings
- Validates resource allocation - Validates resource allocation
- Checks network configuration - Checks network configuration
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: All configuration variables **Environment Variables Used**: All configuration variables
#### `cleanup_on_error()` #### `cleanup_on_error()`
**Purpose**: Clean up resources on error **Purpose**: Clean up resources on error
**Parameters**: None **Parameters**: None
**Returns**: None **Returns**: None
**Side Effects**: **Side Effects**:
- Removes partially created containers - Removes partially created containers
- Cleans up temporary files - Cleans up temporary files
- Resets configuration - Resets configuration
**Dependencies**: None **Dependencies**: None
**Environment Variables Used**: `CTID` **Environment Variables Used**: `CTID`
## Function Call Flow ## Function Call Flow
### Main Installation Flow ### Main Installation Flow
``` ```
start() start()
├── variables() ├── variables()
@ -259,6 +347,7 @@ start()
``` ```
### Error Handling Flow ### Error Handling Flow
``` ```
Error Detection Error Detection
├── validate_settings() ├── validate_settings()
@ -271,24 +360,29 @@ Error Detection
## Function Dependencies ## Function Dependencies
### Core Dependencies ### Core Dependencies
- `start()``install_script()``build_container()``create_lxc_container()` - `start()``install_script()``build_container()``create_lxc_container()`
- `variables()``base_settings()` - `variables()``base_settings()`
- `advanced_settings()``select_storage()``detect_gpu_devices()` - `advanced_settings()``select_storage()``detect_gpu_devices()`
### Storage Dependencies ### Storage Dependencies
- `select_storage()``resolve_storage_preselect()` - `select_storage()``resolve_storage_preselect()`
- `select_storage()``choose_and_set_storage_for_file()` - `select_storage()``choose_and_set_storage_for_file()`
### GPU Dependencies ### GPU Dependencies
- `configure_gpu_passthrough()``detect_gpu_devices()` - `configure_gpu_passthrough()``detect_gpu_devices()`
- `fix_gpu_gids()``configure_gpu_passthrough()` - `fix_gpu_gids()``configure_gpu_passthrough()`
### Settings Dependencies ### Settings Dependencies
- `default_var_settings()``maybe_offer_save_app_defaults()` - `default_var_settings()``maybe_offer_save_app_defaults()`
## Function Usage Examples ## Function Usage Examples
### Basic Container Creation ### Basic Container Creation
```bash ```bash
# Set required variables # Set required variables
export APP="plex" export APP="plex"
@ -304,6 +398,7 @@ start() # Entry point
``` ```
### Advanced Configuration ### Advanced Configuration
```bash ```bash
# Set advanced variables # Set advanced variables
export var_os="debian" export var_os="debian"
@ -319,6 +414,7 @@ advanced_settings() # Interactive configuration
``` ```
### GPU Passthrough ### GPU Passthrough
```bash ```bash
# Enable GPU passthrough # Enable GPU passthrough
export GPU_APPS="plex" export GPU_APPS="plex"
@ -331,6 +427,7 @@ fix_gpu_gids() # Fix permissions
``` ```
### Settings Persistence ### Settings Persistence
```bash ```bash
# Save settings as defaults # Save settings as defaults
export SAVE_DEFAULTS="true" export SAVE_DEFAULTS="true"
@ -344,15 +441,18 @@ maybe_offer_save_app_defaults() # Save app defaults
## Function Error Handling ## Function Error Handling
### Validation Functions ### Validation Functions
- `validate_settings()`: Returns 0 for valid, 1 for invalid - `validate_settings()`: Returns 0 for valid, 1 for invalid
- `check_conflicts()`: Returns 0 for no conflicts, 1 for conflicts - `check_conflicts()`: Returns 0 for no conflicts, 1 for conflicts
### Error Recovery ### Error Recovery
- `cleanup_on_error()`: Cleans up on any error - `cleanup_on_error()`: Cleans up on any error
- Error codes are propagated up the call stack - Error codes are propagated up the call stack
- Critical errors cause script termination - Critical errors cause script termination
### Error Types ### Error Types
1. **Configuration Errors**: Invalid settings or conflicts 1. **Configuration Errors**: Invalid settings or conflicts
2. **Resource Errors**: Insufficient resources or conflicts 2. **Resource Errors**: Insufficient resources or conflicts
3. **Network Errors**: Invalid network configuration 3. **Network Errors**: Invalid network configuration

View File

@ -1491,7 +1491,7 @@ advanced_settings() {
# STEP 17: SSH Settings # STEP 17: SSH Settings
# ═══════════════════════════════════════════════════════════════════════════ # ═══════════════════════════════════════════════════════════════════════════
17) 17)
configure_ssh_settings configure_ssh_settings "Step $STEP/$MAX_STEP"
# configure_ssh_settings handles its own flow, always advance # configure_ssh_settings handles its own flow, always advance
((STEP++)) ((STEP++))
;; ;;
@ -2076,6 +2076,10 @@ ssh_discover_default_files() {
} }
configure_ssh_settings() { configure_ssh_settings() {
local step_info="${1:-}"
local backtitle="Proxmox VE Helper Scripts"
[[ -n "$step_info" ]] && backtitle="Proxmox VE Helper Scripts [${step_info}]"
SSH_KEYS_FILE="$(mktemp)" SSH_KEYS_FILE="$(mktemp)"
: >"$SSH_KEYS_FILE" : >"$SSH_KEYS_FILE"
@ -2085,14 +2089,14 @@ configure_ssh_settings() {
local ssh_key_mode local ssh_key_mode
if [[ "$default_key_count" -gt 0 ]]; then if [[ "$default_key_count" -gt 0 ]]; then
ssh_key_mode=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SSH KEY SOURCE" --menu \ ssh_key_mode=$(whiptail --backtitle "$backtitle" --title "SSH KEY SOURCE" --menu \
"Provision SSH keys for root:" 14 72 4 \ "Provision SSH keys for root:" 14 72 4 \
"found" "Select from detected keys (${default_key_count})" \ "found" "Select from detected keys (${default_key_count})" \
"manual" "Paste a single public key" \ "manual" "Paste a single public key" \
"folder" "Scan another folder (path or glob)" \ "folder" "Scan another folder (path or glob)" \
"none" "No keys" 3>&1 1>&2 2>&3) || exit_script "none" "No keys" 3>&1 1>&2 2>&3) || exit_script
else else
ssh_key_mode=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SSH KEY SOURCE" --menu \ ssh_key_mode=$(whiptail --backtitle "$backtitle" --title "SSH KEY SOURCE" --menu \
"No host keys detected; choose manual/none:" 12 72 2 \ "No host keys detected; choose manual/none:" 12 72 2 \
"manual" "Paste a single public key" \ "manual" "Paste a single public key" \
"none" "No keys" 3>&1 1>&2 2>&3) || exit_script "none" "No keys" 3>&1 1>&2 2>&3) || exit_script
@ -2101,7 +2105,7 @@ configure_ssh_settings() {
case "$ssh_key_mode" in case "$ssh_key_mode" in
found) found)
local selection local selection
selection=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SELECT HOST KEYS" \ selection=$(whiptail --backtitle "$backtitle" --title "SELECT HOST KEYS" \
--checklist "Select one or more keys to import:" 20 140 10 "${CHOICES[@]}" 3>&1 1>&2 2>&3) || exit_script --checklist "Select one or more keys to import:" 20 140 10 "${CHOICES[@]}" 3>&1 1>&2 2>&3) || exit_script
for tag in $selection; do for tag in $selection; do
tag="${tag%\"}" tag="${tag%\"}"
@ -2112,13 +2116,13 @@ configure_ssh_settings() {
done done
;; ;;
manual) manual)
SSH_AUTHORIZED_KEY="$(whiptail --backtitle "Proxmox VE Helper Scripts" \ SSH_AUTHORIZED_KEY="$(whiptail --backtitle "$backtitle" \
--inputbox "Paste one SSH public key line (ssh-ed25519/ssh-rsa/...)" 10 72 --title "SSH Public Key" 3>&1 1>&2 2>&3)" --inputbox "Paste one SSH public key line (ssh-ed25519/ssh-rsa/...)" 10 72 --title "SSH Public Key" 3>&1 1>&2 2>&3)"
[[ -n "$SSH_AUTHORIZED_KEY" ]] && printf '%s\n' "$SSH_AUTHORIZED_KEY" >>"$SSH_KEYS_FILE" [[ -n "$SSH_AUTHORIZED_KEY" ]] && printf '%s\n' "$SSH_AUTHORIZED_KEY" >>"$SSH_KEYS_FILE"
;; ;;
folder) folder)
local glob_path local glob_path
glob_path=$(whiptail --backtitle "Proxmox VE Helper Scripts" \ glob_path=$(whiptail --backtitle "$backtitle" \
--inputbox "Enter a folder or glob to scan (e.g. /root/.ssh/*.pub)" 10 72 --title "Scan Folder/Glob" 3>&1 1>&2 2>&3) --inputbox "Enter a folder or glob to scan (e.g. /root/.ssh/*.pub)" 10 72 --title "Scan Folder/Glob" 3>&1 1>&2 2>&3)
if [[ -n "$glob_path" ]]; then if [[ -n "$glob_path" ]]; then
shopt -s nullglob shopt -s nullglob
@ -2128,7 +2132,7 @@ configure_ssh_settings() {
ssh_build_choices_from_files "${_scan_files[@]}" ssh_build_choices_from_files "${_scan_files[@]}"
if [[ "$COUNT" -gt 0 ]]; then if [[ "$COUNT" -gt 0 ]]; then
local folder_selection local folder_selection
folder_selection=$(whiptail --backtitle "Proxmox VE Helper Scripts" --title "SELECT FOLDER KEYS" \ folder_selection=$(whiptail --backtitle "$backtitle" --title "SELECT FOLDER KEYS" \
--checklist "Select key(s) to import:" 20 78 10 "${CHOICES[@]}" 3>&1 1>&2 2>&3) || exit_script --checklist "Select key(s) to import:" 20 78 10 "${CHOICES[@]}" 3>&1 1>&2 2>&3) || exit_script
for tag in $folder_selection; do for tag in $folder_selection; do
tag="${tag%\"}" tag="${tag%\"}"
@ -2138,10 +2142,10 @@ configure_ssh_settings() {
[[ -n "$line" ]] && printf '%s\n' "$line" >>"$SSH_KEYS_FILE" [[ -n "$line" ]] && printf '%s\n' "$line" >>"$SSH_KEYS_FILE"
done done
else else
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "No keys found in: $glob_path" 8 60 whiptail --backtitle "$backtitle" --msgbox "No keys found in: $glob_path" 8 60
fi fi
else else
whiptail --backtitle "Proxmox VE Helper Scripts" --msgbox "Path/glob returned no files." 8 60 whiptail --backtitle "$backtitle" --msgbox "Path/glob returned no files." 8 60
fi fi
fi fi
;; ;;
@ -2155,12 +2159,9 @@ configure_ssh_settings() {
printf '\n' >>"$SSH_KEYS_FILE" printf '\n' >>"$SSH_KEYS_FILE"
fi fi
if [[ -s "$SSH_KEYS_FILE" || "$PW" == -password* ]]; then # Always show SSH access dialog - user should be able to enable SSH even without keys
if (whiptail --backtitle "Proxmox VE Helper Scripts" --defaultno --title "SSH ACCESS" --yesno "Enable root SSH access?" 10 58); then if (whiptail --backtitle "$backtitle" --defaultno --title "SSH ACCESS" --yesno "Enable root SSH access?" 10 58); then
SSH="yes" SSH="yes"
else
SSH="no"
fi
else else
SSH="no" SSH="no"
fi fi