add comprehensive documentation (#9537)

This commit is contained in:
CanbiZ
2025-12-01 13:50:11 +01:00
committed by GitHub
parent 605c11d43f
commit 1294b89fcb
71 changed files with 20793 additions and 0 deletions

View File

@@ -0,0 +1,117 @@
# install.func Flowchart
## Installation Workflow
```
┌──────────────────────────────────┐
│ Container Started │
│ (Inside LXC by build.func) │
└──────────────┬───────────────────┘
┌──────────────────────┐
│ Source Functions │
│ $FUNCTIONS_FILE_PATH │
└──────────┬───────────┘
┌──────────────────────┐
│ setting_up_container│
│ Display setup msg │
└──────────┬───────────┘
┌──────────────────────┐
│ network_check() │
│ (Verify internet) │
└────┬──────────────┬──┘
│ │
OK FAIL
│ │
│ ▼
│ ┌──────────────┐
│ │ Retry Check │
│ │ 3 attempts │
│ └────┬─────┬───┘
│ │ │
│ OK FAIL
│ │ │
└──────────────┘ │
│ │
▼ ▼
┌──────────────────────┐ ┌──────────────┐
│ update_os() │ │ Exit Error │
│ (apt update/upgrade) │ │ No internet │
└──────────┬───────────┘ └──────────────┘
┌──────────────────────┐
│ verb_ip6() [optional]│
│ (Enable IPv6) │
└──────────┬───────────┘
┌──────────────────────┐
│ Application │
│ Installation │
│ (Main work) │
└──────────┬───────────┘
┌───────┴────────┐
│ │
SUCCESS FAILED
│ │
│ └─ error_handler catches
│ (if catch_errors active)
┌──────────────────────┐
│ motd_ssh() │
│ (Setup SSH/MOTD) │
└──────────┬───────────┘
┌──────────────────────┐
│ customize() │
│ (Apply settings) │
└──────────┬───────────┘
┌──────────────────────┐
│ cleanup_lxc() │
│ (Final cleanup) │
└──────────┬───────────┘
┌──────────────────────┐
│ Installation │
│ Complete ✓ │
└──────────────────────┘
```
## Network Check Retry Logic
```
network_check()
├─ Ping 8.8.8.8 (Google DNS)
│ └─ Response?
│ ├─ YES: Continue
│ └─ NO: Retry
├─ Retry 1
│ └─ Wait 5s, ping again
├─ Retry 2
│ └─ Wait 5s, ping again
└─ Retry 3
├─ If OK: Continue
└─ If FAIL: Exit Error
(Network unavailable)
```
---
**Visual Reference for**: install.func container setup workflows
**Last Updated**: December 2025

View File

@@ -0,0 +1,237 @@
# install.func Functions Reference
Complete reference of all functions in install.func with detailed usage information.
## Function Index
- `setting_up_container()` - Initialize container setup
- `network_check()` - Verify network connectivity
- `update_os()` - Update OS packages
- `verb_ip6()` - Enable IPv6
- `motd_ssh()` - Configure SSH and MOTD
- `customize()` - Apply container customizations
- `cleanup_lxc()` - Final container cleanup
---
## Core Functions
### setting_up_container()
Display setup message and initialize container environment.
**Signature**:
```bash
setting_up_container
```
**Purpose**: Announce container initialization and set initial environment
**Usage**:
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
# Output: ⏳ Setting up container...
```
---
### network_check()
Verify network connectivity with automatic retry logic.
**Signature**:
```bash
network_check
```
**Purpose**: Ensure internet connectivity before critical operations
**Behavior**:
- Pings 8.8.8.8 (Google DNS)
- 3 attempts with 5-second delays
- Exits with error if all attempts fail
**Usage**:
```bash
network_check
# If no internet: Exits with error message
# If internet OK: Continues to next step
```
**Error Handling**:
```bash
if ! network_check; then
msg_error "No internet connection"
exit 1
fi
```
---
### update_os()
Update OS packages with error handling.
**Signature**:
```bash
update_os
```
**Purpose**: Prepare container with latest packages
**On Debian/Ubuntu**:
- Runs: `apt-get update && apt-get upgrade -y`
**On Alpine**:
- Runs: `apk update && apk upgrade`
**Usage**:
```bash
update_os
```
---
### verb_ip6()
Enable IPv6 support in container (optional).
**Signature**:
```bash
verb_ip6
```
**Purpose**: Enable IPv6 if needed for application
**Usage**:
```bash
verb_ip6 # Enable IPv6
network_check # Verify connectivity with IPv6
```
---
### motd_ssh()
Configure SSH daemon and MOTD for container access.
**Signature**:
```bash
motd_ssh
```
**Purpose**: Setup SSH and create login message
**Configures**:
- SSH daemon startup and keys
- Custom MOTD displaying application access info
- SSH port and security settings
**Usage**:
```bash
motd_ssh
# SSH is now configured and application info is in MOTD
```
---
### customize()
Apply container customizations and final setup.
**Signature**:
```bash
customize
```
**Purpose**: Apply any remaining customizations
**Usage**:
```bash
customize
```
---
### cleanup_lxc()
Final cleanup and completion of installation.
**Signature**:
```bash
cleanup_lxc
```
**Purpose**: Remove temporary files and finalize installation
**Cleans**:
- Temporary installation files
- Package manager cache
- Log files from installation process
**Usage**:
```bash
cleanup_lxc
# Installation is now complete and ready
```
---
## Common Patterns
### Basic Installation Pattern
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
network_check
update_os
# ... application installation ...
motd_ssh
customize
cleanup_lxc
```
### With IPv6 Support
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
verb_ip6 # Enable IPv6
network_check
update_os
# ... application installation ...
```
### With Error Handling
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
catch_errors # Setup error trapping
setting_up_container
if ! network_check; then
msg_error "Network connectivity failed"
exit 1
fi
update_os
```
---
**Last Updated**: December 2025
**Total Functions**: 7
**Maintained by**: community-scripts team

View File

@@ -0,0 +1,104 @@
# install.func Integration Guide
How install.func integrates with the ProxmoxVE ecosystem and connects to other function libraries.
## Component Integration
### install.func in the Installation Pipeline
```
install/app-install.sh (container-side)
├─ Sources: core.func (messaging)
├─ Sources: error_handler.func (error handling)
├─ ★ Uses: install.func ★
│ ├─ setting_up_container()
│ ├─ network_check()
│ ├─ update_os()
│ └─ motd_ssh()
├─ Uses: tools.func (package installation)
└─ Back to install.func:
├─ customize()
└─ cleanup_lxc()
```
### Integration with tools.func
install.func and tools.func work together:
```
setting_up_container() [install.func]
update_os() [install.func]
pkg_update() [tools.func]
setup_nodejs() [tools.func]
setup_mariadb() [tools.func]
motd_ssh() [install.func]
customize() [install.func]
cleanup_lxc() [install.func]
```
---
## Dependencies
### External Dependencies
- `curl`, `wget` - For downloads
- `apt-get` or `apk` - Package management
- `ping` - Network verification
- `systemctl` or `rc-service` - Service management
### Internal Dependencies
```
install.func uses:
├─ core.func (for messaging and colors)
├─ error_handler.func (for error handling)
└─ tools.func (for package operations)
```
---
## Best Practices
### Always Follow This Pattern
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
# 1. Setup error handling
catch_errors
# 2. Initialize container
setting_up_container
# 3. Verify network
network_check
# 4. Update OS
update_os
# 5. Installation (your code)
# ... install application ...
# 6. Configure access
motd_ssh
# 7. Customize
customize
# 8. Cleanup
cleanup_lxc
```
---
**Last Updated**: December 2025
**Maintainers**: community-scripts team

View File

@@ -0,0 +1,93 @@
# install.func Usage Examples
Practical examples for using install.func functions in application installation scripts.
## Basic Examples
### Example 1: Minimal Setup
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
network_check
update_os
# ... application installation ...
motd_ssh
customize
cleanup_lxc
```
### Example 2: With Error Handling
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
catch_errors
setting_up_container
if ! network_check; then
msg_error "Network failed"
exit 1
fi
if ! update_os; then
msg_error "OS update failed"
exit 1
fi
# ... continue ...
```
---
## Production Examples
### Example 3: Full Application Installation
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
catch_errors
setting_up_container
network_check
update_os
msg_info "Installing application"
# ... install steps ...
msg_ok "Application installed"
motd_ssh
customize
cleanup_lxc
```
### Example 4: With IPv6 Support
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
catch_errors
setting_up_container
verb_ip6
network_check
update_os
# ... application installation ...
motd_ssh
customize
cleanup_lxc
```
---
**Last Updated**: December 2025
**Examples**: Basic and production patterns
**All examples production-ready**

View File

@@ -0,0 +1,248 @@
# install.func Documentation
## Overview
The `install.func` file provides container installation workflow orchestration and fundamental operations for applications deployed inside LXC containers. It handles network setup, OS configuration, connectivity verification, and installation mechanics.
## Purpose and Use Cases
- **Container Setup**: Initialize new container with proper configuration
- **Network Verification**: Verify IPv4 and IPv6 connectivity
- **OS Configuration**: Update OS, apply system settings
- **Installation Workflow**: Orchestrate application installation steps
- **Error Handling**: Comprehensive signal trapping and error recovery
## Quick Reference
### Key Function Groups
- **Initialization**: `setting_up_container()` - Setup message and environment
- **Network**: `network_check()`, `verb_ip6()` - Connectivity verification
- **OS Configuration**: `update_os()` - OS updates and package management
- **Installation**: `motd_ssh()`, `customize()` - Container customization
- **Cleanup**: `cleanup_lxc()` - Final container cleanup
### Dependencies
- **External**: `curl`, `apt-get`, `ping`, `dns` utilities
- **Internal**: Uses functions from `core.func`, `error_handler.func`, `tools.func`
### Integration Points
- Used by: All install/*.sh scripts at startup
- Uses: Environment variables from build.func and core.func
- Provides: Container initialization and management services
## Documentation Files
### 📊 [INSTALL_FUNC_FLOWCHART.md](./INSTALL_FUNC_FLOWCHART.md)
Visual execution flows showing initialization, network checks, and installation workflows.
### 📚 [INSTALL_FUNC_FUNCTIONS_REFERENCE.md](./INSTALL_FUNC_FUNCTIONS_REFERENCE.md)
Complete alphabetical reference of all functions with parameters, dependencies, and usage details.
### 💡 [INSTALL_FUNC_USAGE_EXAMPLES.md](./INSTALL_FUNC_USAGE_EXAMPLES.md)
Practical examples showing how to use installation functions and common patterns.
### 🔗 [INSTALL_FUNC_INTEGRATION.md](./INSTALL_FUNC_INTEGRATION.md)
How install.func integrates with other components and provides installation services.
## Key Features
### Container Initialization
- **Environment Setup**: Prepare container variables and functions
- **Message System**: Display installation progress with colored output
- **Error Handlers**: Setup signal trapping for proper cleanup
### Network & Connectivity
- **IPv4 Verification**: Ping external hosts to verify internet access
- **IPv6 Support**: Optional IPv6 enablement and verification
- **DNS Checking**: Verify DNS resolution is working
- **Retry Logic**: Automatic retries for transient failures
### OS Configuration
- **Package Updates**: Safely update OS package lists
- **System Optimization**: Disable unnecessary services (wait-online)
- **Timezone**: Validate and set container timezone
- **SSH Setup**: Configure SSH daemon and keys
### Container Customization
- **MOTD**: Create custom login message
- **Auto-Login**: Optional passwordless root login
- **Update Script**: Register application update function
- **Customization Hooks**: Application-specific setup
## Function Categories
### 🔹 Core Functions
- `setting_up_container()` - Display setup message and set environment
- `network_check()` - Verify network connectivity
- `update_os()` - Update OS packages with retry logic
- `verb_ip6()` - Enable IPv6 (optional)
### 🔹 Configuration Functions
- `motd_ssh()` - Setup MOTD and SSH configuration
- `customize()` - Apply container customizations
- `cleanup_lxc()` - Final cleanup before completion
### 🔹 Utility Functions
- `create_update_script()` - Register application update function
- `set_timezone()` - Configure container timezone
- `disable_wait_online()` - Disable systemd-networkd-wait-online
## Execution Flow
```
Container Started
source $FUNCTIONS_FILE_PATH
setting_up_container() ← Display "Setting up container..."
network_check() ← Verify internet connectivity
update_os() ← Update package lists
[Application-Specific Installation]
motd_ssh() ← Configure SSH/MOTD
customize() ← Apply customizations
cleanup_lxc() ← Final cleanup
Installation Complete
```
## Common Usage Patterns
### Basic Container Setup
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
network_check
update_os
# ... application installation ...
motd_ssh
customize
cleanup_lxc
```
### With Optional IPv6
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
verb_ip6 # Enable IPv6
network_check
update_os
# ... installation ...
motd_ssh
customize
cleanup_lxc
```
### With Custom Update Script
```bash
#!/usr/bin/env bash
source /dev/stdin <<<"$FUNCTIONS_FILE_PATH"
setting_up_container
network_check
update_os
# ... installation ...
# Register update function
function update_script() {
# Update logic here
}
export -f update_script
motd_ssh
customize
cleanup_lxc
```
## Best Practices
### ✅ DO
- Call `setting_up_container()` at the start
- Check `network_check()` output before main installation
- Use `$STD` variable for silent operations
- Call `cleanup_lxc()` at the very end
- Test network connectivity before critical operations
### ❌ DON'T
- Skip network verification
- Assume internet is available
- Hardcode container paths
- Use `echo` instead of `msg_*` functions
- Forget to call cleanup at the end
## Environment Variables
### Available Variables
- `$FUNCTIONS_FILE_PATH` - Path to core functions (set by build.func)
- `$CTID` - Container ID number
- `$NSAPP` - Normalized application name (lowercase)
- `$APP` - Application display name
- `$STD` - Output suppression (`silent` or empty)
- `$VERBOSE` - Verbose output mode (`yes` or `no`)
### Setting Container Variables
```bash
CONTAINER_TIMEZONE="UTC"
CONTAINER_HOSTNAME="myapp-container"
CONTAINER_FQDN="myapp.example.com"
```
## Troubleshooting
### "Network check failed"
```bash
# Container may not have internet access
# Check:
ping 8.8.8.8 # External connectivity
nslookup example.com # DNS resolution
ip route show # Routing table
```
### "Package update failed"
```bash
# APT may be locked by another process
ps aux | grep apt # Check for running apt
# Or wait for existing apt to finish
sleep 30
update_os
```
### "Cannot source functions"
```bash
# $FUNCTIONS_FILE_PATH may not be set
# This variable is set by build.func before running install script
# If missing, the install script was not called properly
```
## Related Documentation
- **[tools.func/](../tools.func/)** - Package and tool installation
- **[core.func/](../core.func/)** - Utility functions and messaging
- **[error_handler.func/](../error_handler.func/)** - Error handling
- **[alpine-install.func/](../alpine-install.func/)** - Alpine-specific setup
- **[UPDATED_APP-install.md](../../UPDATED_APP-install.md)** - Application script guide
## Recent Updates
### Version 2.0 (Dec 2025)
- ✅ Improved network connectivity checks
- ✅ Enhanced OS update error handling
- ✅ Added IPv6 support with verb_ip6()
- ✅ Better timezone validation
- ✅ Streamlined cleanup procedures
---
**Last Updated**: December 2025
**Maintainers**: community-scripts team
**License**: MIT