From d160a1a4e5d34f03223e73a69bdb028ee59e6b7a Mon Sep 17 00:00:00 2001 From: robojerk Date: Sat, 12 Jul 2025 12:54:28 -0700 Subject: [PATCH] Fix Unicode character issues in apt-layer scriptlets and recompile with clean source --- apt-layer.sh | 781 ++++++++++++++++-- dos2unix.sh | 144 ++++ src/apt-layer/compile.sh | 48 +- src/apt-layer/scriptlets/00-header.sh | 9 +- src/apt-layer/scriptlets/01-dependencies.sh | 37 +- src/apt-layer/scriptlets/02-transactions.sh | 1 + src/apt-layer/scriptlets/03-traditional.sh | 1 + src/apt-layer/scriptlets/04-container.sh | 1 + src/apt-layer/scriptlets/05-live-overlay.sh | 12 +- .../scriptlets/06-oci-integration.sh | 9 +- .../08-advanced-package-management.sh | 4 +- .../scriptlets/09-atomic-deployment.sh | 3 +- .../scriptlets/10-rpm-ostree-compat.sh | 1 + src/apt-layer/scriptlets/11-layer-signing.sh | 18 +- .../scriptlets/14-admin-utilities.sh | 8 +- src/apt-layer/scriptlets/15-multi-tenant.sh | 18 +- src/apt-layer/scriptlets/23-cloud-security.sh | 14 +- .../scriptlets/24-dpkg-direct-install.sh | 1 + src/apt-layer/scriptlets/99-main.sh | 1 + 19 files changed, 965 insertions(+), 146 deletions(-) create mode 100644 dos2unix.sh diff --git a/apt-layer.sh b/apt-layer.sh index de9e1fd..0569b1f 100644 --- a/apt-layer.sh +++ b/apt-layer.sh @@ -6,7 +6,7 @@ # DO NOT modify this file directly as it will be overwritten # # # # Particle-OS apt-layer Tool # -# Generated on: 2025-07-11 12:27:50 # +# Generated on: 2025-07-12 12:54:12 # # # ################################################################################################################ @@ -18,7 +18,7 @@ set -euo pipefail # Inspired by Vanilla OS Apx approach, ParticleOS apt-layer, and rpm-ostree live layering -# Version: 25.07.11 +# Version: 25.07.12 # Particle-OS apt-layer Tool # Enhanced with Container Support and LIVE SYSTEM LAYERING @@ -70,12 +70,17 @@ log_transaction() { } -# Source Particle-OS configuration (if available) -if [[ -f "/usr/local/etc/particle-config.sh" ]]; then - source "/usr/local/etc/particle-config.sh" - log_info "Loaded Particle-OS configuration" "apt-layer" +# Source Particle-OS configuration (if available, skip for help commands) +# Skip configuration loading for help commands to avoid permission issues +if [[ "${1:-}" != "--help" && "${1:-}" != "-h" && "${1:-}" != "--help-full" && "${1:-}" != "--examples" ]]; then + if [[ -f "/usr/local/etc/particle-config.sh" ]]; then + source "/usr/local/etc/particle-config.sh" + log_info "Loaded Particle-OS configuration" "apt-layer" + else + log_warning "Particle-OS configuration not found, using defaults" "apt-layer" + fi else - log_warning "Particle-OS configuration not found, using defaults" "apt-layer" + log_info "Skipping configuration loading for help command" "apt-layer" fi @@ -152,7 +157,7 @@ WORKSPACE="/var/lib/particle-os" BUILD_DIR="/var/lib/particle-os/build" LIVE_OVERLAY_DIR="/var/lib/particle-os/live-overlay" COMPOSEFS_DIR="/var/lib/particle-os/composefs" -COMPOSEFS_SCRIPT="/usr/local/bin/composefs" +COMPOSEFS_SCRIPT="/usr/local/bin/composefs-alternative.sh" CONTAINER_RUNTIME="podman" # Transaction state variables @@ -256,6 +261,146 @@ check_root() { fi } +# Require root privileges for specific operations +require_root() { + local operation="${1:-this operation}" + if [[ $EUID -ne 0 ]]; then + log_error "Root privileges required for: $operation" "apt-layer" + log_info "Please run with sudo" "apt-layer" + exit 1 + fi +} + +# Check if system needs initialization +check_initialization_needed() { + local needs_init=false + local missing_items=() + + # Check for configuration file + if [[ ! -f "/usr/local/etc/particle-config.sh" ]]; then + needs_init=true + missing_items+=("configuration file") + fi + + # Check for workspace directory + if [[ ! -d "$WORKSPACE" ]]; then + needs_init=true + missing_items+=("workspace directory") + fi + + # Check for log directory + if [[ ! -d "/var/log/particle-os" ]]; then + needs_init=true + missing_items+=("log directory") + fi + + # Check for cache directory + if [[ ! -d "/var/cache/particle-os" ]]; then + needs_init=true + missing_items+=("cache directory") + fi + + if [[ "$needs_init" == "true" ]]; then + log_error "Particle-OS system not initialized. Missing: ${missing_items[*]}" "apt-layer" + log_info "Run 'sudo $0 --init' to initialize the system" "apt-layer" + exit 1 + fi +} + +# Initialize required directories and files with proper error handling +initialize_directories() { + log_info "Initializing Particle-OS directories and files..." "apt-layer" + + # Create main directories with proper error handling + local dirs=( + "$WORKSPACE" + "$BUILD_DIR" + "$LIVE_OVERLAY_DIR" + "$COMPOSEFS_DIR" + "/var/log/particle-os" + "/var/cache/particle-os" + "/usr/local/etc/particle-os" + ) + + for dir in "${dirs[@]}"; do + if ! mkdir -p "$dir" 2>/dev/null; then + log_warning "Failed to create directory $dir, attempting with sudo..." "apt-layer" + if ! sudo mkdir -p "$dir" 2>/dev/null; then + log_error "Failed to create directory: $dir" "apt-layer" + return 1 + fi + fi + + # Set proper permissions even if directory already exists + if [[ -d "$dir" ]]; then + sudo chown root:root "$dir" 2>/dev/null || true + sudo chmod 755 "$dir" 2>/dev/null || true + fi + done + + # Create required files with proper error handling + local files=( + "$WORKSPACE/current-deployment" + "$WORKSPACE/pending-deployment" + "$WORKSPACE/deployments.json" + "$TRANSACTION_STATE" + "$TRANSACTION_LOG" + ) + + for file in "${files[@]}"; do + if ! touch "$file" 2>/dev/null; then + log_warning "Failed to create file $file, attempting with sudo..." "apt-layer" + if ! sudo touch "$file" 2>/dev/null; then + log_error "Failed to create file: $file" "apt-layer" + return 1 + fi + fi + + # Set proper permissions even if file already exists + if [[ -f "$file" ]]; then + sudo chown root:root "$file" 2>/dev/null || true + sudo chmod 644 "$file" 2>/dev/null || true + fi + done + + # Initialize deployment database if it doesn't exist or is empty + if [[ ! -f "$WORKSPACE/deployments.json" ]] || [[ ! -s "$WORKSPACE/deployments.json" ]]; then + if ! cat > "$WORKSPACE/deployments.json" << 'EOF' +{ + "deployments": {}, + "current_deployment": null, + "pending_deployment": null, + "deployment_counter": 0, + "created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" +} +EOF + then + log_warning "Failed to create deployment database, attempting with sudo..." "apt-layer" + if ! sudo tee "$WORKSPACE/deployments.json" > /dev/null << 'EOF' +{ + "deployments": {}, + "current_deployment": null, + "pending_deployment": null, + "deployment_counter": 0, + "created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" +} +EOF + then + log_error "Failed to create deployment database" "apt-layer" + return 1 + fi + fi + + # Set proper permissions for deployment database + sudo chown root:root "$WORKSPACE/deployments.json" 2>/dev/null || true + sudo chmod 644 "$WORKSPACE/deployments.json" 2>/dev/null || true + log_success "Deployment database initialized" "apt-layer" + fi + + log_success "Particle-OS directories and files initialized successfully" "apt-layer" + return 0 +} + # Initialize workspace init_workspace() { log_info "Initializing Particle-OS workspace..." "apt-layer" @@ -492,69 +637,170 @@ get_available_space() { # ============================================================================ # Dependency Checking and Validation # ============================================================================ -# Dependency checking and validation for Ubuntu uBlue apt-layer Tool +# Enhanced dependency checking and validation for Particle-OS apt-layer Tool check_dependencies() { - log_info "Checking dependencies..." "apt-layer" + local command_type="${1:-}" + local packages=("${@:2}") + + log_info "Checking dependencies for command: ${command_type:-general}" "apt-layer" local missing_deps=() + local missing_packages=() + local missing_tools=() + local missing_scripts=() + local missing_modules=() - # Core dependencies - for dep in chroot apt-get; do + # Core system dependencies + local core_deps=("chroot" "apt-get" "dpkg" "jq" "mount" "umount") + for dep in "${core_deps[@]}"; do if ! command -v "$dep" >/dev/null 2>&1; then missing_deps+=("$dep") + missing_tools+=("$dep") fi done - # Check for container runtime if container mode is requested - if [[ "${1:-}" == "--container" ]] && ! command -v "$CONTAINER_RUNTIME" >/dev/null 2>&1; then - missing_deps+=("$CONTAINER_RUNTIME") + # Container-specific dependencies + if [[ "$command_type" == "--container" || "$command_type" == "container" ]]; then + local container_deps=("podman" "docker" "systemd-nspawn") + local found_container=false + + for dep in "${container_deps[@]}"; do + if command -v "$dep" >/dev/null 2>&1; then + found_container=true + break + fi + done + + if [[ "$found_container" == "false" ]]; then + missing_deps+=("container-runtime") + missing_tools+=("podman, docker, or systemd-nspawn") + fi fi - # Check for composefs-alternative.sh - if [[ ! -f "$COMPOSEFS_SCRIPT" ]]; then - missing_deps+=("composefs-alternative.sh") - log_warning "composefs-alternative.sh not found at $COMPOSEFS_SCRIPT" "apt-layer" - log_info "Please ensure composefs-alternative.sh is installed and accessible" "apt-layer" - elif [[ ! -x "$COMPOSEFS_SCRIPT" ]]; then - missing_deps+=("composefs-alternative.sh (not executable)") - log_warning "composefs-alternative.sh not executable at $COMPOSEFS_SCRIPT" "apt-layer" - log_info "Please ensure composefs-alternative.sh has execute permissions" "apt-layer" + # ComposeFS-specific dependencies + if [[ "$command_type" == "--composefs" || "$command_type" == "composefs" ]]; then + local composefs_deps=("mksquashfs" "unsquashfs" "skopeo") + for dep in "${composefs_deps[@]}"; do + if ! command -v "$dep" >/dev/null 2>&1; then + missing_deps+=("$dep") + missing_tools+=("$dep") + fi + done fi + # Security scanning dependencies + if [[ "$command_type" == "--scan" || "$command_type" == "security" ]]; then + local security_deps=("curl" "wget" "gpg") + for dep in "${security_deps[@]}"; do + if ! command -v "$dep" >/dev/null 2>&1; then + missing_deps+=("$dep") + missing_tools+=("$dep") + fi + done + fi + + # Check for required scripts + local required_scripts=( + "composefs-alternative.sh:/usr/local/bin/composefs-alternative.sh" + "bootc-alternative.sh:/usr/local/bin/bootc-alternative.sh" + "bootupd-alternative.sh:/usr/local/bin/bootupd-alternative.sh" + ) + + for script_info in "${required_scripts[@]}"; do + local script_name="${script_info%%:*}" + local script_path="${script_info##*:}" + + if [[ ! -f "$script_path" ]]; then + missing_deps+=("$script_name") + missing_scripts+=("$script_name") + elif [[ ! -x "$script_path" ]]; then + missing_deps+=("$script_name (not executable)") + missing_scripts+=("$script_name (needs chmod +x)") + fi + done + # Check for kernel modules check_kernel_modules - if [ ${#missing_deps[@]} -ne 0 ]; then - log_error "Missing dependencies: ${missing_deps[*]}" "apt-layer" - log_info "Install missing packages with: sudo apt install -y ${missing_deps[*]}" "apt-layer" + # Validate package names if provided + if [[ ${#packages[@]} -gt 0 ]]; then + if ! validate_package_names "${packages[@]}"; then + return 1 + fi + fi + + # Report missing dependencies with specific installation instructions + if [[ ${#missing_deps[@]} -gt 0 ]]; then + echo "" + log_error "Missing dependencies detected!" "apt-layer" + echo "" + + if [[ ${#missing_tools[@]} -gt 0 ]]; then + echo " Missing system packages:" + for tool in "${missing_tools[@]}"; do + echo " $tool" + done + echo "" + echo " Install with: sudo apt install -y ${missing_tools[*]}" + echo "" + fi + + if [[ ${#missing_scripts[@]} -gt 0 ]]; then + echo " Missing or non-executable scripts:" + for script in "${missing_scripts[@]}"; do + echo " $script" + done + echo "" + echo " Ensure scripts are installed and executable:" + echo " sudo chmod +x /usr/local/bin/*-alternative.sh" + echo "" + fi + + if [[ ${#missing_modules[@]} -gt 0 ]]; then + echo " Missing kernel modules:" + for module in "${missing_modules[@]}"; do + echo " $module" + done + echo "" + echo " Load modules with: sudo modprobe ${missing_modules[*]}" + echo " Or install with: sudo apt install linux-modules-extra-\$(uname -r)" + echo "" + fi + + echo " Quick fix for common dependencies:" + echo " sudo apt install -y squashfs-tools jq coreutils util-linux" + echo "" + echo " For more information, run: apt-layer --help" + echo "" + exit 1 fi - log_success "All dependencies found" "apt-layer" + log_success "All dependencies found and validated" "apt-layer" } # Check kernel modules check_kernel_modules() { - log_info "Checking kernel modules..." "apt-layer" + log_debug "Checking kernel modules..." "apt-layer" local missing_modules=() + local required_modules=("squashfs" "overlay" "fuse") - # Check for squashfs module - if ! modprobe -n squashfs >/dev/null 2>&1; then - missing_modules+=("squashfs") - fi + for module in "${required_modules[@]}"; do + if ! modprobe -n "$module" >/dev/null 2>&1; then + missing_modules+=("$module") + fi + done - # Check for overlay module - if ! modprobe -n overlay >/dev/null 2>&1; then - missing_modules+=("overlay") - fi - - if [ ${#missing_modules[@]} -ne 0 ]; then + if [[ ${#missing_modules[@]} -gt 0 ]]; then log_warning "Missing kernel modules: ${missing_modules[*]}" "apt-layer" log_info "Load modules with: sudo modprobe ${missing_modules[*]}" "apt-layer" log_info "Or install with: sudo apt install linux-modules-extra-$(uname -r)" "apt-layer" + + # Store missing modules for the main error report + missing_modules_global=("${missing_modules[@]}") else - log_success "All required kernel modules available" "apt-layer" + log_debug "All required kernel modules available" "apt-layer" fi } @@ -626,7 +872,7 @@ check_disk_space() { # Check if system is in a bootable state check_system_state() { - log_info "Checking system state..." "apt-layer" + log_debug "Checking system state..." "apt-layer" # Check if running from a live system if [[ -f "/run/ostree-booted" ]]; then @@ -642,6 +888,119 @@ check_system_state() { log_warning "Unable to determine system state" "apt-layer" return 1 +} + +# Enhanced error reporting with actionable messages +show_actionable_error() { + local error_type="$1" + local error_message="$2" + local command="${3:-}" + local packages="${4:-}" + + echo "" + log_error "$error_message" "apt-layer" + echo "" + + case "$error_type" in + "missing_dependencies") + echo " To fix this issue:" + echo " 1. Install missing dependencies:" + echo " sudo apt update" + echo " sudo apt install -y $packages" + echo "" + echo " 2. Ensure scripts are executable:" + echo " sudo chmod +x /usr/local/bin/*-alternative.sh" + echo "" + echo " 3. Load required kernel modules:" + echo " sudo modprobe squashfs overlay fuse" + echo "" + ;; + "permission_denied") + echo " Permission issue detected:" + echo " This command requires root privileges." + echo "" + echo " Run with sudo:" + echo " sudo apt-layer $command" + echo "" + ;; + "invalid_arguments") + echo " Invalid arguments provided:" + echo " Check the command syntax and try again." + echo "" + echo " For help, run:" + echo " apt-layer --help" + echo " apt-layer $command --help" + echo "" + ;; + "system_not_initialized") + echo " System not initialized:" + echo " Particle-OS needs to be initialized first." + echo "" + echo " Run initialization:" + echo " sudo apt-layer --init" + echo "" + ;; + "disk_space") + echo " Insufficient disk space:" + echo " Free up space or use a different location." + echo "" + echo " Check available space:" + echo " df -h" + echo "" + ;; + *) + echo " Unknown error occurred." + echo " Please check the error message above." + echo "" + echo " For help, run: apt-layer --help" + echo "" + ;; + esac + + echo " For more information:" + echo " apt-layer --help" + echo " apt-layer --help-full" + echo " apt-layer --examples" + echo "" +} + +# Pre-flight validation before any command +pre_flight_check() { + local command_type="$1" + local packages=("${@:2}") + + log_info "Running pre-flight checks..." "apt-layer" + + # Check if running as root for privileged operations + if [[ "$command_type" =~ ^(install|upgrade|rebase|rollback|init|live-overlay)$ ]]; then + if [[ $EUID -ne 0 ]]; then + show_actionable_error "permission_denied" "This command requires root privileges" "$command_type" + exit 1 + fi + fi + + # Check system initialization (skip for help commands) + if [[ "$command_type" != "--init" && "$command_type" != "init" && "$command_type" != "--help" && "$command_type" != "-h" && "$command_type" != "--help-full" && "$command_type" != "--examples" ]]; then + if [[ ! -f "/usr/local/etc/particle-config.sh" ]]; then + show_actionable_error "system_not_initialized" "Particle-OS system not initialized" "$command_type" + exit 1 + fi + fi + + # Check dependencies + if ! check_dependencies "$command_type" "${packages[@]}"; then + exit 1 + fi + + # Check disk space for operations that create files + if [[ "$command_type" =~ ^(create|build|install|upgrade)$ ]]; then + if ! check_disk_space 1000; then + show_actionable_error "disk_space" "Insufficient disk space for operation" "$command_type" + exit 1 + fi + fi + + log_success "Pre-flight checks passed" "apt-layer" } # --- END OF SCRIPTLET: 01-dependencies.sh --- @@ -649,9 +1008,123 @@ check_system_state() { # ============================================================================ # Transaction Management # ============================================================================ -# Transaction management for Ubuntu uBlue apt-layer Tool +# Transaction management for Particle-OS apt-layer Tool # Provides atomic operations with automatic rollback and recovery +# System initialization functions +initialize_particle_os_system() { + log_info "Initializing Particle-OS system..." "apt-layer" + + # Create configuration directory + mkdir -p "/usr/local/etc/particle-os" + + # Create workspace directory + mkdir -p "/var/lib/particle-os" + + # Create log directory + mkdir -p "/var/log/particle-os" + + # Create cache directory + mkdir -p "/var/cache/particle-os" + + # Create configuration file if it doesn't exist + if [[ ! -f "/usr/local/etc/particle-config.sh" ]]; then + create_default_configuration + fi + + # Set proper permissions + chmod 755 "/var/lib/particle-os" + chmod 755 "/var/log/particle-os" + chmod 755 "/var/cache/particle-os" + chmod 644 "/usr/local/etc/particle-config.sh" + + log_success "Particle-OS system initialized successfully" "apt-layer" +} + +create_default_configuration() { + log_info "Creating default configuration..." "apt-layer" + + cat > "/usr/local/etc/particle-config.sh" << 'EOF' +#!/bin/bash +# Particle-OS Configuration File +# Generated automatically on $(date) + +# Core paths +export PARTICLE_WORKSPACE="/var/lib/particle-os" +export PARTICLE_CONFIG_DIR="/usr/local/etc/particle-os" +export PARTICLE_LOG_DIR="/var/log/particle-os" +export PARTICLE_CACHE_DIR="/var/cache/particle-os" + +# Build and temporary directories +export PARTICLE_BUILD_DIR="$PARTICLE_WORKSPACE/build" +export PARTICLE_TEMP_DIR="$PARTICLE_WORKSPACE/temp" +export PARTICLE_BACKUP_DIR="$PARTICLE_WORKSPACE/backup" + +# Layer management +export PARTICLE_LAYERS_DIR="$PARTICLE_WORKSPACE/layers" +export PARTICLE_IMAGES_DIR="$PARTICLE_WORKSPACE/images" +export PARTICLE_MOUNTS_DIR="$PARTICLE_WORKSPACE/mounts" + +# ComposeFS integration +export PARTICLE_COMPOSEFS_DIR="$PARTICLE_WORKSPACE/composefs" +export PARTICLE_COMPOSEFS_SCRIPT="/usr/local/bin/composefs-alternative.sh" + +# Boot management +export PARTICLE_BOOTC_SCRIPT="/usr/local/bin/bootc-alternative.sh" +export PARTICLE_BOOTUPD_SCRIPT="/usr/local/bin/bootupd-alternative.sh" + +# Transaction management +export PARTICLE_TRANSACTION_LOG="$PARTICLE_LOG_DIR/transactions.log" +export PARTICLE_TRANSACTION_STATE="$PARTICLE_CACHE_DIR/transaction.state" + +# Logging configuration +export PARTICLE_LOG_LEVEL="INFO" +export PARTICLE_LOG_FILE="$PARTICLE_LOG_DIR/apt-layer.log" + +# Security settings +export PARTICLE_SIGNING_ENABLED="false" +export PARTICLE_VERIFY_SIGNATURES="false" + +# Container settings +export PARTICLE_CONTAINER_RUNTIME="podman" +export PARTICLE_CHROOT_ENABLED="true" + +# Default package sources +export PARTICLE_DEFAULT_SOURCES="main restricted universe multiverse" + +# Performance settings +export PARTICLE_PARALLEL_JOBS="4" +export PARTICLE_CACHE_ENABLED="true" + +# Load configuration if it exists +if [[ -f "$PARTICLE_CONFIG_DIR/particle-config.sh" ]]; then + source "$PARTICLE_CONFIG_DIR/particle-config.sh" +fi +EOF + + log_success "Default configuration created: /usr/local/etc/particle-config.sh" "apt-layer" +} + +reset_particle_os_system() { + log_warning "Resetting Particle-OS system..." "apt-layer" + + # Backup existing configuration + if [[ -f "/usr/local/etc/particle-config.sh" ]]; then + cp "/usr/local/etc/particle-config.sh" "/usr/local/etc/particle-config.sh.backup.$(date +%Y%m%d_%H%M%S)" + log_info "Existing configuration backed up" "apt-layer" + fi + + # Remove existing directories + rm -rf "/var/lib/particle-os" + rm -rf "/var/log/particle-os" + rm -rf "/var/cache/particle-os" + + # Reinitialize system + initialize_particle_os_system + + log_success "Particle-OS system reset successfully" "apt-layer" +} + # Transaction management functions start_transaction() { local operation="$1" @@ -1702,7 +2175,7 @@ container_status() { # ============================================================================ # OCI Export/Import Integration # ============================================================================ -# OCI Integration for Ubuntu uBlue apt-layer Tool +# OCI Integration for Particle-OS apt-layer Tool # Provides ComposeFS OCI export/import functionality for container-based layer creation # OCI registry configuration @@ -2286,7 +2759,11 @@ DEPLOYMENT_HISTORY_DIR="/var/lib/particle-os/history" init_deployment_db() { log_info "Initializing atomic deployment database..." "apt-layer" - mkdir -p "$DEPLOYMENT_HISTORY_DIR" + # Ensure directories exist with proper permissions + mkdir -p "$DEPLOYMENT_HISTORY_DIR" 2>/dev/null || { + log_error "Failed to create deployment history directory: $DEPLOYMENT_HISTORY_DIR" "apt-layer" + return 1 + } # Create deployment database if it doesn't exist if [[ ! -f "$DEPLOYMENT_DB" ]]; then @@ -2299,12 +2776,32 @@ init_deployment_db() { "created": "$(date -u +%Y-%m-%dT%H:%M:%SZ)" } EOF - log_success "Deployment database initialized" "apt-layer" + if [[ $? -eq 0 ]]; then + log_success "Deployment database initialized" "apt-layer" + else + log_error "Failed to create deployment database: $DEPLOYMENT_DB" "apt-layer" + return 1 + fi fi - # Ensure deployment files exist - touch "$CURRENT_DEPLOYMENT_FILE" - touch "$PENDING_DEPLOYMENT_FILE" + # Ensure deployment files exist with proper error handling + touch "$CURRENT_DEPLOYMENT_FILE" 2>/dev/null || { + log_warning "Failed to create current deployment file, attempting with sudo..." "apt-layer" + sudo touch "$CURRENT_DEPLOYMENT_FILE" 2>/dev/null || { + log_error "Failed to create current deployment file: $CURRENT_DEPLOYMENT_FILE" "apt-layer" + return 1 + } + } + + touch "$PENDING_DEPLOYMENT_FILE" 2>/dev/null || { + log_warning "Failed to create pending deployment file, attempting with sudo..." "apt-layer" + sudo touch "$PENDING_DEPLOYMENT_FILE" 2>/dev/null || { + log_error "Failed to create pending deployment file: $PENDING_DEPLOYMENT_FILE" "apt-layer" + return 1 + } + } + + log_success "Deployment database initialization completed" "apt-layer" } # Create a new deployment commit @@ -2633,7 +3130,7 @@ rpm_ostree_install() { log_info "rpm-ostree install compatibility: ${packages[*]}" "apt-layer" # Use live overlay for package installation - if ! apt-layer --live-install "${packages[@]}"; then + if ! live_install "${packages[@]}"; then log_error "rpm-ostree install failed" "apt-layer" return 1 fi @@ -2707,7 +3204,7 @@ rpm_ostree_status() { # Show live overlay status echo "" echo "=== Live Overlay Status ===" - apt-layer --live-overlay status + get_live_overlay_status # Show package diff if pending deployment local pending_deployment @@ -2801,7 +3298,7 @@ rpm_ostree_cancel() { clear_pending_deployment # Clean up live overlay - apt-layer --live-overlay stop + stop_live_overlay log_success "rpm-ostree cancel completed successfully" "apt-layer" } @@ -15823,6 +16320,8 @@ Particle-OS apt-layer Tool - Enhanced with Container Support and LIVE SYSTEM LAY Like rpm-ostree + Vanilla OS Apx for Ubuntu/Debian, now ComposeFS-based BASIC USAGE: + apt-layer --init # Initialize Particle-OS system + apt-layer --reset # Reset Particle-OS system apt-layer base-image new-image [packages...] # Create new layer apt-layer --container base-image new-image [packages...] # Container-based layer apt-layer --live-install packages # Install on live system @@ -16571,6 +17070,126 @@ ENTERPRISE FEATURES: EOF } +# Initialize Particle-OS system +initialize_particle_system() { + log_info "Initializing Particle-OS system..." "apt-layer" + + # Check if running as root + check_root + + # Create configuration file + if [[ ! -f "/usr/local/etc/particle-config.sh" ]]; then + log_info "Creating configuration file..." "apt-layer" + mkdir -p "/usr/local/etc" + + cat > "/usr/local/etc/particle-config.sh" << 'EOF' +#!/bin/bash +# Particle-OS Configuration File +# This file contains the main configuration for Particle-OS + +# Workspace and directory configuration +PARTICLE_WORKSPACE="/var/lib/particle-os" +PARTICLE_CONFIG_DIR="/usr/local/etc/particle-os" +PARTICLE_LOG_DIR="/var/log/particle-os" +PARTICLE_CACHE_DIR="/var/cache/particle-os" + +# Build and temporary directories +PARTICLE_BUILD_DIR="$PARTICLE_WORKSPACE/build" +PARTICLE_TEMP_DIR="$PARTICLE_WORKSPACE/temp" +PARTICLE_LAYERS_DIR="$PARTICLE_WORKSPACE/layers" + +# ComposeFS configuration +PARTICLE_COMPOSEFS_DIR="$PARTICLE_WORKSPACE/composefs" +PARTICLE_COMPOSEFS_SCRIPT="/usr/local/bin/composefs-alternative.sh" + +# Container configuration +PARTICLE_CONTAINER_RUNTIME="podman" +PARTICLE_CONTAINER_WORKSPACE="$PARTICLE_WORKSPACE/containers" + +# Live overlay configuration +PARTICLE_LIVE_OVERLAY_DIR="$PARTICLE_WORKSPACE/live-overlay" + +# Transaction configuration +PARTICLE_TRANSACTION_STATE="$PARTICLE_WORKSPACE/transaction-state" +PARTICLE_TRANSACTION_LOG="$PARTICLE_LOG_DIR/transaction.log" + +# Logging configuration +PARTICLE_LOG_LEVEL="info" +PARTICLE_LOG_COLOR="true" + +# Security configuration +PARTICLE_SECURITY_ENABLED="true" +PARTICLE_SECURITY_SCAN_LEVEL="standard" + +# Audit configuration +PARTICLE_AUDIT_ENABLED="true" +PARTICLE_AUDIT_RETENTION_DAYS="90" + +# OCI configuration +PARTICLE_OCI_ENABLED="true" +PARTICLE_OCI_WORKSPACE="$PARTICLE_WORKSPACE/oci" + +# Export variables for use in scripts +export PARTICLE_WORKSPACE +export PARTICLE_CONFIG_DIR +export PARTICLE_LOG_DIR +export PARTICLE_CACHE_DIR +export PARTICLE_BUILD_DIR +export PARTICLE_TEMP_DIR +export PARTICLE_LAYERS_DIR +export PARTICLE_COMPOSEFS_DIR +export PARTICLE_COMPOSEFS_SCRIPT +export PARTICLE_CONTAINER_RUNTIME +export PARTICLE_CONTAINER_WORKSPACE +export PARTICLE_LIVE_OVERLAY_DIR +export PARTICLE_TRANSACTION_STATE +export PARTICLE_TRANSACTION_LOG +export PARTICLE_LOG_LEVEL +export PARTICLE_LOG_COLOR +export PARTICLE_SECURITY_ENABLED +export PARTICLE_SECURITY_SCAN_LEVEL +export PARTICLE_AUDIT_ENABLED +export PARTICLE_AUDIT_RETENTION_DAYS +export PARTICLE_OCI_ENABLED +export PARTICLE_OCI_WORKSPACE +EOF + + chmod 644 "/usr/local/etc/particle-config.sh" + log_success "Configuration file created: /usr/local/etc/particle-config.sh" "apt-layer" + fi + + # Create workspace directory + if [[ ! -d "$WORKSPACE" ]]; then + log_info "Creating workspace directory..." "apt-layer" + mkdir -p "$WORKSPACE" + log_success "Workspace directory created: $WORKSPACE" "apt-layer" + fi + + # Create log directory + if [[ ! -d "/var/log/particle-os" ]]; then + log_info "Creating log directory..." "apt-layer" + mkdir -p "/var/log/particle-os" + log_success "Log directory created: /var/log/particle-os" "apt-layer" + fi + + # Create cache directory + if [[ ! -d "/var/cache/particle-os" ]]; then + log_info "Creating cache directory..." "apt-layer" + mkdir -p "/var/cache/particle-os" + log_success "Cache directory created: /var/cache/particle-os" "apt-layer" + fi + + # Initialize workspace subdirectories + init_workspace + + log_success "Particle-OS system initialization completed successfully!" "apt-layer" + echo "" + echo "System is now ready for use. You can run:" + echo " apt-layer --help" + echo " apt-layer status" + echo " apt-layer --list" +} + # Main execution main() { # Initialize deployment database @@ -16579,8 +17198,23 @@ main() { # Check for incomplete transactions first check_incomplete_transactions + # Check if system needs initialization (skip for help and initialization commands) + if [[ "${1:-}" != "--init" && "${1:-}" != "--reset" && "${1:-}" != "--help" && "${1:-}" != "-h" && "${1:-}" != "--help-full" && "${1:-}" != "--examples" ]]; then + check_initialization_needed + fi + # Parse command line arguments first (before dependency checks) case "${1:-}" in + --init) + # Initialize Particle-OS system + initialize_particle_os_system + exit 0 + ;; + --reset) + # Reset Particle-OS system + reset_particle_os_system + exit 0 + ;; --help|-h) show_usage exit 0 @@ -16724,20 +17358,22 @@ main() { ;; esac - # Initialize workspace - init_workspace + # Initialize workspace (skip for help commands) + if [[ "${1:-}" != "--help" && "${1:-}" != "-h" && "${1:-}" != "--help-full" && "${1:-}" != "--examples" ]]; then + init_workspace + # Initialize OCI integration system + init_oci_system + fi - # Initialize OCI integration system - init_oci_system - - # Check dependencies - check_dependencies "$@" + # Run pre-flight checks for all commands + pre_flight_check "${1:-}" "${@:2}" # Parse remaining command line arguments case "${1:-}" in # rpm-ostree compatibility commands install) # rpm-ostree install compatibility + require_root "package installation" if [ $# -lt 2 ]; then log_error "No packages specified for install" "apt-layer" show_usage @@ -16749,10 +17385,12 @@ main() { ;; upgrade) # rpm-ostree upgrade compatibility + require_root "system upgrade" rpm_ostree_upgrade ;; rebase) # rpm-ostree rebase compatibility + require_root "system rebase" if [ -z "${2:-}" ]; then log_error "New base image required for rebase" "apt-layer" show_usage @@ -16762,6 +17400,7 @@ main() { ;; rollback) # rpm-ostree rollback compatibility + require_root "system rollback" local target_commit="${2:-}" rpm_ostree_rollback "$target_commit" ;; @@ -16795,15 +17434,18 @@ main() { ;; cleanup) # rpm-ostree cleanup compatibility + require_root "system cleanup" local purge="${2:-}" rpm_ostree_cleanup "$purge" ;; cancel) # rpm-ostree cancel compatibility + require_root "transaction cancellation" rpm_ostree_cancel ;; initramfs) # rpm-ostree initramfs compatibility + require_root "initramfs management" if [ -z "${2:-}" ]; then log_error "Action required for initramfs" "apt-layer" show_usage @@ -16813,6 +17455,7 @@ main() { ;; kargs) # rpm-ostree kargs compatibility + require_root "kernel arguments management" if [ -z "${2:-}" ]; then log_error "Action required for kargs" "apt-layer" show_usage @@ -16858,6 +17501,7 @@ main() { ;; bootloader) # Bootloader management + require_root "bootloader management" if [ -z "${2:-}" ]; then log_error "Action required for bootloader" "apt-layer" show_usage @@ -16903,6 +17547,7 @@ main() { ;; usroverlay) # rpm-ostree usroverlay compatibility + require_root "usr overlay management" if [ -z "${2:-}" ]; then log_error "Action required for usroverlay" "apt-layer" show_usage @@ -16912,6 +17557,7 @@ main() { ;; composefs) # rpm-ostree composefs compatibility + require_root "composefs management" if [ -z "${2:-}" ]; then log_error "Action required for composefs" "apt-layer" show_usage @@ -16924,6 +17570,7 @@ main() { ;; --live-install) # Live system installation + require_root "live system installation" if [ $# -lt 2 ]; then log_error "No packages specified for --live-install" "apt-layer" show_usage @@ -16937,6 +17584,7 @@ main() { ;; --live-overlay) # Live overlay management + require_root "live overlay management" if [ -z "${2:-}" ]; then log_error "Action required for --live-overlay" "apt-layer" show_usage @@ -16951,15 +17599,18 @@ main() { ;; --live-commit) # Commit live overlay changes + require_root "live overlay commit" local message="${2:-Live overlay changes}" commit_live_overlay "$message" ;; --live-rollback) # Rollback live overlay changes + require_root "live overlay rollback" rollback_live_overlay ;; --container) # Container-based layer creation + require_root "container-based layer creation" if [ $# -lt 4 ]; then log_error "Insufficient arguments for --container" "apt-layer" show_usage @@ -17013,6 +17664,7 @@ main() { ;; --advanced-install) # Advanced package installation with security checks + require_root "advanced package installation" if [ $# -lt 2 ]; then log_error "No packages specified for --advanced-install" "apt-layer" show_usage @@ -17029,6 +17681,7 @@ main() { ;; --advanced-remove) # Advanced package removal with dependency checking + require_root "advanced package removal" if [ $# -lt 2 ]; then log_error "No packages specified for --advanced-remove" "apt-layer" show_usage @@ -17045,6 +17698,7 @@ main() { ;; --advanced-update) # Advanced package update with rollback capability + require_root "advanced package update" if [ $# -lt 2 ]; then log_error "No packages specified for --advanced-update" "apt-layer" show_usage @@ -17061,6 +17715,7 @@ main() { ;; --add-user) # Add user to package management system + require_root "user management" if [ $# -lt 3 ]; then log_error "Username and role required for --add-user" "apt-layer" show_usage @@ -17077,6 +17732,7 @@ main() { ;; --remove-user) # Remove user from package management system + require_root "user management" if [ $# -lt 2 ]; then log_error "Username required for --remove-user" "apt-layer" show_usage @@ -17128,6 +17784,7 @@ main() { ;; --cleanup-backups) # Clean up old backups + require_root "backup cleanup" local max_age_days="${2:-30}" # Initialize advanced package management system @@ -17137,6 +17794,7 @@ main() { ;; --generate-key) # Generate signing key pair + require_root "key generation" if [ $# -lt 3 ]; then log_error "Key name and type required for --generate-key" "apt-layer" show_usage @@ -17153,6 +17811,7 @@ main() { ;; --sign-layer) # Sign layer with specified key + require_root "layer signing" if [ $# -lt 3 ]; then log_error "Layer path and key name required for --sign-layer" "apt-layer" show_usage @@ -17184,6 +17843,7 @@ main() { ;; --revoke-layer) # Revoke layer + require_root "layer revocation" if [ $# -lt 2 ]; then log_error "Layer path required for --revoke-layer" "apt-layer" show_usage @@ -17288,6 +17948,7 @@ main() { ;; --cleanup-audit-logs) # Clean up old audit logs + require_root "audit log cleanup" local max_age_days="${2:-90}" # Initialize audit reporting system @@ -17351,6 +18012,7 @@ main() { ;; --update-cve-database) # Update CVE database from NVD + require_root "CVE database update" # Initialize security scanning system init_security_scanning_on_startup @@ -17358,6 +18020,7 @@ main() { ;; --cleanup-security-reports) # Clean up old security reports + require_root "security report cleanup" local max_age_days="${2:-90}" # Initialize security scanning system @@ -17367,6 +18030,7 @@ main() { ;; admin) # Admin utilities + require_root "admin utilities" if [ -z "${2:-}" ]; then log_error "Action required for admin" "apt-layer" show_usage @@ -17380,6 +18044,7 @@ main() { ;; tenant) # Multi-tenant management + require_root "multi-tenant management" if [ -z "${2:-}" ]; then log_error "Action required for tenant" "apt-layer" show_usage diff --git a/dos2unix.sh b/dos2unix.sh new file mode 100644 index 0000000..f2be871 --- /dev/null +++ b/dos2unix.sh @@ -0,0 +1,144 @@ +#!/bin/bash + +# dos2unix mimic script +# Converts DOS/Windows line endings (CRLF) to Unix line endings (LF) + +# Function to display usage +usage() { + echo "Usage: $0 [OPTIONS] FILE..." + echo "Convert DOS/Windows line endings to Unix line endings" + echo "" + echo "Options:" + echo " -h, --help Show this help message" + echo " -n, --newfile Create new file with .unix extension" + echo " -b, --backup Create backup with .bak extension" + echo " -q, --quiet Suppress output messages" + echo "" + echo "Examples:" + echo " $0 file.txt" + echo " $0 -n file.txt" + echo " $0 -b file.txt" + echo " $0 *.txt" + exit 1 +} + +# Function to convert file +convert_file() { + local input_file="$1" + local output_file="$2" + local backup="$3" + local quiet="$4" + + # Check if input file exists + if [ ! -f "$input_file" ]; then + echo "Error: File '$input_file' not found" >&2 + return 1 + fi + + # Check if file has DOS line endings + if ! grep -q $'\r' "$input_file"; then + [ "$quiet" != "true" ] && echo "dos2unix: converting file $input_file to Unix format..." + [ "$quiet" != "true" ] && echo "dos2unix: $input_file: No conversion needed (already Unix format)" + return 0 + fi + + # Create backup if requested + if [ "$backup" = "true" ]; then + if ! cp "$input_file" "${input_file}.bak"; then + echo "Error: Cannot create backup file" >&2 + return 1 + fi + [ "$quiet" != "true" ] && echo "dos2unix: created backup: ${input_file}.bak" + fi + + # Convert line endings using sed + if sed 's/\r$//' "$input_file" > "$output_file"; then + [ "$quiet" != "true" ] && echo "dos2unix: converting file $input_file to Unix format..." + + # If output file is different from input (newfile mode), show message + if [ "$input_file" != "$output_file" ]; then + [ "$quiet" != "true" ] && echo "dos2unix: converted to $output_file" + fi + + return 0 + else + echo "Error: Failed to convert $input_file" >&2 + return 1 + fi +} + +# Parse command line arguments +newfile=false +backup=false +quiet=false +files=() + +while [[ $# -gt 0 ]]; do + case $1 in + -h|--help) + usage + ;; + -n|--newfile) + newfile=true + shift + ;; + -b|--backup) + backup=true + shift + ;; + -q|--quiet) + quiet=true + shift + ;; + -*) + echo "Error: Unknown option $1" >&2 + usage + ;; + *) + files+=("$1") + shift + ;; + esac +done + +# Check if at least one file is provided +if [ ${#files[@]} -eq 0 ]; then + echo "Error: No files specified" >&2 + usage +fi + +# Process each file +exit_code=0 +for file in "${files[@]}"; do + # Expand wildcards + for expanded_file in $file; do + if [ -f "$expanded_file" ]; then + if [ "$newfile" = "true" ]; then + # Create new file with .unix extension + output_file="${expanded_file}.unix" + else + # Overwrite original file + output_file="$expanded_file" + fi + + if [ "$newfile" = "true" ]; then + # For newfile mode, we can directly convert + convert_file "$expanded_file" "$output_file" "$backup" "$quiet" + else + # For in-place conversion, use temporary file + temp_file=$(mktemp) + if convert_file "$expanded_file" "$temp_file" "$backup" "$quiet"; then + mv "$temp_file" "$expanded_file" + else + rm -f "$temp_file" + exit_code=1 + fi + fi + else + echo "Error: File '$expanded_file' not found" >&2 + exit_code=1 + fi + done +done + +exit $exit_code \ No newline at end of file diff --git a/src/apt-layer/compile.sh b/src/apt-layer/compile.sh index 6b5f234..39964df 100644 --- a/src/apt-layer/compile.sh +++ b/src/apt-layer/compile.sh @@ -88,7 +88,7 @@ validate_json_files() { print_error "Invalid JSON in file: $json_file" exit 1 fi - print_status "✓ Validated: $json_file" + print_status " Validated: $json_file" done fi } @@ -114,7 +114,7 @@ convert_line_endings() { if grep -q $'\r' "$file" 2>/dev/null; then print_status "Converting Windows line endings to Unix: $file" if "$dos2unix_cmd" -q "$file"; then - print_status "✓ Converted: $file" + print_status " Converted: $file" else print_warning "Failed to convert line endings for: $file" fi @@ -530,28 +530,28 @@ print_status "Lines of code: $(wc -l < "$OUTPUT_FILE")" print_status "" print_status "The compiled apt-layer.sh is now self-contained and includes:" -print_status "✅ Particle-OS configuration integration" -print_status "✅ Transactional operations with automatic rollback" -print_status "✅ Traditional chroot-based layer creation" -print_status "✅ Container-based layer creation (Apx-style)" -print_status "✅ OCI export/import integration" -print_status "✅ Live overlay system (rpm-ostree style)" -print_status "✅ Bootloader integration (UEFI/GRUB/systemd-boot)" -print_status "✅ Advanced package management (Enterprise features)" -print_status "✅ Layer signing & verification (Enterprise security)" -print_status "✅ Centralized audit & reporting (Enterprise compliance)" -print_status "✅ Automated security scanning (Enterprise security)" -print_status "✅ Admin utilities (Health monitoring, performance analytics, maintenance)" -print_status "✅ Multi-tenant support (Enterprise features)" -print_status "✅ Atomic deployment system with rollback" -print_status "✅ rpm-ostree compatibility layer (1:1 command mapping)" -print_status "✅ ComposeFS backend integration" -print_status "✅ Dependency validation and error handling" -print_status "✅ Comprehensive JSON configuration system" -print_status "✅ Direct dpkg installation (Performance optimization)" -print_status "✅ All dependencies merged into a single file" +print_status " Particle-OS configuration integration" +print_status " Transactional operations with automatic rollback" +print_status " Traditional chroot-based layer creation" +print_status " Container-based layer creation (Apx-style)" +print_status " OCI export/import integration" +print_status " Live overlay system (rpm-ostree style)" +print_status " Bootloader integration (UEFI/GRUB/systemd-boot)" +print_status " Advanced package management (Enterprise features)" +print_status " Layer signing & verification (Enterprise security)" +print_status " Centralized audit & reporting (Enterprise compliance)" +print_status " Automated security scanning (Enterprise security)" +print_status " Admin utilities (Health monitoring, performance analytics, maintenance)" +print_status " Multi-tenant support (Enterprise features)" +print_status " Atomic deployment system with rollback" +print_status " rpm-ostree compatibility layer (1:1 command mapping)" +print_status " ComposeFS backend integration" +print_status " Dependency validation and error handling" +print_status " Comprehensive JSON configuration system" +print_status " Direct dpkg installation (Performance optimization)" +print_status " All dependencies merged into a single file" print_status "" -print_status "🎉 Particle-OS apt-layer compilation complete with all features!" +print_status " Particle-OS apt-layer compilation complete with all features!" print_status "" print_status "Usage:" @@ -590,4 +590,4 @@ print_status " sudo ./apt-layer.sh --list" print_status " sudo ./apt-layer.sh --help" print_status "" -print_status "Ready for distribution! 🚀" +print_status "Ready for distribution! " diff --git a/src/apt-layer/scriptlets/00-header.sh b/src/apt-layer/scriptlets/00-header.sh index eb223dd..8daed57 100644 --- a/src/apt-layer/scriptlets/00-header.sh +++ b/src/apt-layer/scriptlets/00-header.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Utility functions for Particle-OS apt-layer Tool # These functions provide system introspection and core utilities @@ -514,14 +515,14 @@ get_system_info() { echo "Architecture: $(uname -m)" echo "Available modules:" if modprobe -n squashfs >/dev/null 2>&1; then - echo " ✓ squashfs module available" + echo " squashfs module available" else - echo " ✗ squashfs module not available" + echo " squashfs module not available" fi if modprobe -n overlay >/dev/null 2>&1; then - echo " ✓ overlay module available" + echo " overlay module available" else - echo " ✗ overlay module not available" + echo " overlay module not available" fi } diff --git a/src/apt-layer/scriptlets/01-dependencies.sh b/src/apt-layer/scriptlets/01-dependencies.sh index f051d14..32230bc 100644 --- a/src/apt-layer/scriptlets/01-dependencies.sh +++ b/src/apt-layer/scriptlets/01-dependencies.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Enhanced dependency checking and validation for Particle-OS apt-layer Tool check_dependencies() { local command_type="${1:-}" @@ -97,9 +98,9 @@ check_dependencies() { echo "" if [[ ${#missing_tools[@]} -gt 0 ]]; then - echo "📦 Missing system packages:" + echo " Missing system packages:" for tool in "${missing_tools[@]}"; do - echo " • $tool" + echo " $tool" done echo "" echo " Install with: sudo apt install -y ${missing_tools[*]}" @@ -107,9 +108,9 @@ check_dependencies() { fi if [[ ${#missing_scripts[@]} -gt 0 ]]; then - echo "📜 Missing or non-executable scripts:" + echo " Missing or non-executable scripts:" for script in "${missing_scripts[@]}"; do - echo " • $script" + echo " $script" done echo "" echo " Ensure scripts are installed and executable:" @@ -118,9 +119,9 @@ check_dependencies() { fi if [[ ${#missing_modules[@]} -gt 0 ]]; then - echo "🔧 Missing kernel modules:" + echo " Missing kernel modules:" for module in "${missing_modules[@]}"; do - echo " • $module" + echo " $module" done echo "" echo " Load modules with: sudo modprobe ${missing_modules[*]}" @@ -128,10 +129,10 @@ check_dependencies() { echo "" fi - echo "💡 Quick fix for common dependencies:" + echo " Quick fix for common dependencies:" echo " sudo apt install -y squashfs-tools jq coreutils util-linux" echo "" - echo "🔍 For more information, run: apt-layer --help" + echo " For more information, run: apt-layer --help" echo "" exit 1 @@ -264,7 +265,7 @@ show_actionable_error() { case "$error_type" in "missing_dependencies") - echo "🔧 To fix this issue:" + echo " To fix this issue:" echo " 1. Install missing dependencies:" echo " sudo apt update" echo " sudo apt install -y $packages" @@ -277,7 +278,7 @@ show_actionable_error() { echo "" ;; "permission_denied") - echo "🔐 Permission issue detected:" + echo " Permission issue detected:" echo " This command requires root privileges." echo "" echo " Run with sudo:" @@ -285,7 +286,7 @@ show_actionable_error() { echo "" ;; "invalid_arguments") - echo "📝 Invalid arguments provided:" + echo " Invalid arguments provided:" echo " Check the command syntax and try again." echo "" echo " For help, run:" @@ -294,7 +295,7 @@ show_actionable_error() { echo "" ;; "system_not_initialized") - echo "🚀 System not initialized:" + echo " System not initialized:" echo " Particle-OS needs to be initialized first." echo "" echo " Run initialization:" @@ -302,7 +303,7 @@ show_actionable_error() { echo "" ;; "disk_space") - echo "💾 Insufficient disk space:" + echo " Insufficient disk space:" echo " Free up space or use a different location." echo "" echo " Check available space:" @@ -310,7 +311,7 @@ show_actionable_error() { echo "" ;; *) - echo "❓ Unknown error occurred." + echo " Unknown error occurred." echo " Please check the error message above." echo "" echo " For help, run: apt-layer --help" @@ -318,10 +319,10 @@ show_actionable_error() { ;; esac - echo "📚 For more information:" - echo " • apt-layer --help" - echo " • apt-layer --help-full" - echo " • apt-layer --examples" + echo " For more information:" + echo " apt-layer --help" + echo " apt-layer --help-full" + echo " apt-layer --examples" echo "" } diff --git a/src/apt-layer/scriptlets/02-transactions.sh b/src/apt-layer/scriptlets/02-transactions.sh index 20bc373..591c34b 100644 --- a/src/apt-layer/scriptlets/02-transactions.sh +++ b/src/apt-layer/scriptlets/02-transactions.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Transaction management for Particle-OS apt-layer Tool # Provides atomic operations with automatic rollback and recovery diff --git a/src/apt-layer/scriptlets/03-traditional.sh b/src/apt-layer/scriptlets/03-traditional.sh index 2395f90..3570583 100644 --- a/src/apt-layer/scriptlets/03-traditional.sh +++ b/src/apt-layer/scriptlets/03-traditional.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Traditional layer creation for Ubuntu uBlue apt-layer Tool # Provides chroot-based package installation for layer creation diff --git a/src/apt-layer/scriptlets/04-container.sh b/src/apt-layer/scriptlets/04-container.sh index ffd4cd5..d304e98 100644 --- a/src/apt-layer/scriptlets/04-container.sh +++ b/src/apt-layer/scriptlets/04-container.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Container-based layer creation for Ubuntu uBlue apt-layer Tool # Provides Apx-style isolated container installation with ComposeFS backend diff --git a/src/apt-layer/scriptlets/05-live-overlay.sh b/src/apt-layer/scriptlets/05-live-overlay.sh index 5ec91df..c21b3e6 100644 --- a/src/apt-layer/scriptlets/05-live-overlay.sh +++ b/src/apt-layer/scriptlets/05-live-overlay.sh @@ -172,7 +172,7 @@ get_live_overlay_status() { echo "=== Live Overlay Status ===" if is_live_overlay_active; then - log_success "✓ Live overlay is ACTIVE" "apt-layer" + log_success " Live overlay is ACTIVE" "apt-layer" # Show mount details if mountpoint -q "$LIVE_OVERLAY_MOUNT_POINT"; then @@ -190,22 +190,22 @@ get_live_overlay_status() { log_info "Packages installed in overlay: $package_count" "apt-layer" fi else - log_warning "⚠️ Overlay mount point not mounted" "apt-layer" + log_warning " Overlay mount point not mounted" "apt-layer" fi # Check for active processes if check_active_processes; then - log_warning "⚠️ Active processes detected - overlay cannot be stopped" "apt-layer" + log_warning " Active processes detected - overlay cannot be stopped" "apt-layer" fi else - log_info "ℹ Live overlay is not active" "apt-layer" + log_info " Live overlay is not active" "apt-layer" # Check if system supports live overlay if check_live_overlay_support >/dev/null 2>&1; then - log_info "ℹ System supports live overlay" "apt-layer" + log_info " System supports live overlay" "apt-layer" log_info "Use '--live-overlay start' to start live overlay" "apt-layer" else - log_warning "⚠️ System does not support live overlay" "apt-layer" + log_warning " System does not support live overlay" "apt-layer" fi fi diff --git a/src/apt-layer/scriptlets/06-oci-integration.sh b/src/apt-layer/scriptlets/06-oci-integration.sh index 3674d24..459d5f5 100644 --- a/src/apt-layer/scriptlets/06-oci-integration.sh +++ b/src/apt-layer/scriptlets/06-oci-integration.sh @@ -1,5 +1,6 @@ +#!/bin/bash # OCI Integration for Particle-OS apt-layer Tool -# Provides ComposeFS ↔ OCI export/import functionality for container-based layer creation +# Provides ComposeFS OCI export/import functionality for container-based layer creation # OCI registry configuration declare -A OCI_REGISTRY_CONFIG @@ -539,9 +540,9 @@ oci_status() { echo "=== OCI Tool Configuration ===" echo "Preferred tool: $OCI_TOOL" echo "Available tools:" - command -v skopeo &> /dev/null && echo " ✓ skopeo" - command -v podman &> /dev/null && echo " ✓ podman" - command -v docker &> /dev/null && echo " ✓ docker" + command -v skopeo &> /dev/null && echo " skopeo" + command -v podman &> /dev/null && echo " podman" + command -v docker &> /dev/null && echo " docker" echo "" echo "=== OCI Workspace ===" diff --git a/src/apt-layer/scriptlets/08-advanced-package-management.sh b/src/apt-layer/scriptlets/08-advanced-package-management.sh index 178d2b6..4cc21ad 100644 --- a/src/apt-layer/scriptlets/08-advanced-package-management.sh +++ b/src/apt-layer/scriptlets/08-advanced-package-management.sh @@ -975,9 +975,9 @@ get_advanced_package_info() { echo "" echo "Security Information:" if check_package_signature "$package"; then - echo " ✓ Package is signed" + echo " Package is signed" else - echo " ✗ Package is not signed" + echo " Package is not signed" fi # Size information diff --git a/src/apt-layer/scriptlets/09-atomic-deployment.sh b/src/apt-layer/scriptlets/09-atomic-deployment.sh index 7b7ee23..81e5cf9 100644 --- a/src/apt-layer/scriptlets/09-atomic-deployment.sh +++ b/src/apt-layer/scriptlets/09-atomic-deployment.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Atomic deployment system for Ubuntu uBlue apt-layer Tool # Implements commit-based state management and true system upgrades (not package upgrades) @@ -314,7 +315,7 @@ atomic_status() { fi if [[ -n "$pending_deployment" ]]; then - echo "⚠️ Pending deployment will activate on next boot" + echo " Pending deployment will activate on next boot" fi } diff --git a/src/apt-layer/scriptlets/10-rpm-ostree-compat.sh b/src/apt-layer/scriptlets/10-rpm-ostree-compat.sh index 66a7d93..de7176f 100644 --- a/src/apt-layer/scriptlets/10-rpm-ostree-compat.sh +++ b/src/apt-layer/scriptlets/10-rpm-ostree-compat.sh @@ -1,3 +1,4 @@ +#!/bin/bash # rpm-ostree compatibility layer for Ubuntu uBlue apt-layer Tool # Provides 1:1 command compatibility with rpm-ostree diff --git a/src/apt-layer/scriptlets/11-layer-signing.sh b/src/apt-layer/scriptlets/11-layer-signing.sh index 5f07323..0dddaed 100644 --- a/src/apt-layer/scriptlets/11-layer-signing.sh +++ b/src/apt-layer/scriptlets/11-layer-signing.sh @@ -657,11 +657,11 @@ get_layer_signing_status() { # Check if layer exists if [[ ! -f "$layer_path" ]]; then - echo " ✗ Layer file not found" + echo " Layer file not found" return 1 fi - echo " ✓ Layer file exists" + echo " Layer file exists" # Check for signatures local signature_db="$LAYER_SIGNING_SIGNATURES_DIR/signatures.json" @@ -679,21 +679,21 @@ get_layer_signing_status() { local signed_at signed_at=$(echo "$signature_info" | jq -r '.signed_at // "unknown"') - echo " ✓ Signed with $method using key: $key_name" - echo " ✓ Signature status: $status" - echo " ✓ Signed at: $signed_at" + echo " Signed with $method using key: $key_name" + echo " Signature status: $status" + echo " Signed at: $signed_at" else - echo " ✗ No signature found" + echo " No signature found" fi else - echo " ✗ Signature database not found" + echo " Signature database not found" fi # Check for revocation if check_layer_revocation "$layer_path"; then - echo " ⚠ Layer is revoked" + echo " Layer is revoked" else - echo " ✓ Layer is not revoked" + echo " Layer is not revoked" fi echo "" diff --git a/src/apt-layer/scriptlets/14-admin-utilities.sh b/src/apt-layer/scriptlets/14-admin-utilities.sh index 73d2e89..6021053 100644 --- a/src/apt-layer/scriptlets/14-admin-utilities.sh +++ b/src/apt-layer/scriptlets/14-admin-utilities.sh @@ -9,10 +9,10 @@ YELLOW='\033[1;33m' RED='\033[0;31m' CYAN='\033[0;36m' NC='\033[0m' -CHECK="✅" -WARN="⚠️ " -CROSS="❌" -INFO="ℹ️ " +CHECK="" +WARN=" " +CROSS="" +INFO=" " # --- Helper: Check for WSL --- is_wsl() { diff --git a/src/apt-layer/scriptlets/15-multi-tenant.sh b/src/apt-layer/scriptlets/15-multi-tenant.sh index d775fd2..178f626 100644 --- a/src/apt-layer/scriptlets/15-multi-tenant.sh +++ b/src/apt-layer/scriptlets/15-multi-tenant.sh @@ -521,16 +521,16 @@ check_tenant_health() { # Check tenant exists if [[ ! -d "$tenant_dir" ]]; then - echo "❌ Tenant directory not found" + echo " Tenant directory not found" return 1 fi if ! jq -e ".tenants[] | select(.name == \"$tenant_name\")" "$tenant_db" > /dev/null 2>&1; then - echo "❌ Tenant not found in database" + echo " Tenant not found in database" return 1 fi - echo "✅ Tenant exists" + echo " Tenant exists" # Check directory structure local missing_dirs=() @@ -541,9 +541,9 @@ check_tenant_health() { done if [[ ${#missing_dirs[@]} -gt 0 ]]; then - echo "⚠️ Missing directories: ${missing_dirs[*]}" + echo " Missing directories: ${missing_dirs[*]}" else - echo "✅ Directory structure complete" + echo " Directory structure complete" fi # Check quota usage @@ -556,7 +556,7 @@ check_tenant_health() { storage_used=$(echo "$tenant_info" | jq -r '.quotas.used_storage_gb') storage_max=$(echo "$tenant_info" | jq -r '.quotas.max_storage_gb') - echo "📊 Resource Usage:" + echo " Resource Usage:" echo " Layers: $layers_used/$layers_max" echo " Storage: ${storage_used}GB/${storage_max}GB" @@ -565,14 +565,14 @@ check_tenant_health() { local storage_percent=$((storage_used * 100 / storage_max)) if [[ $layer_percent -gt 80 ]]; then - echo "⚠️ Layer quota usage high: ${layer_percent}%" + echo " Layer quota usage high: ${layer_percent}%" fi if [[ $storage_percent -gt 80 ]]; then - echo "⚠️ Storage quota usage high: ${storage_percent}%" + echo " Storage quota usage high: ${storage_percent}%" fi - echo "✅ Tenant health check complete" + echo " Tenant health check complete" } # Multi-tenant command handler diff --git a/src/apt-layer/scriptlets/23-cloud-security.sh b/src/apt-layer/scriptlets/23-cloud-security.sh index 6ead604..d8733ac 100644 --- a/src/apt-layer/scriptlets/23-cloud-security.sh +++ b/src/apt-layer/scriptlets/23-cloud-security.sh @@ -683,25 +683,25 @@ cloud_security_status() { # Check if system is initialized if [[ -d "$cloud_security_dir" ]]; then - echo "✅ System initialized: $cloud_security_dir" + echo " System initialized: $cloud_security_dir" # Check configuration local config_file="$cloud_security_dir/cloud-security-config.json" if [[ -f "$config_file" ]]; then - echo "✅ Configuration: $config_file" + echo " Configuration: $config_file" local enabled_providers=$(jq -r '.enabled_providers[]' "$config_file" 2>/dev/null | tr '\n' ', ' | sed 's/,$//') echo " Enabled providers: $enabled_providers" else - echo "❌ Configuration missing" + echo " Configuration missing" fi # Check directories local dirs=("scans" "policies" "reports" "integrations") for dir in "${dirs[@]}"; do if [[ -d "$cloud_security_dir/$dir" ]]; then - echo "✅ $dir directory: $cloud_security_dir/$dir" + echo " $dir directory: $cloud_security_dir/$dir" else - echo "❌ $dir directory missing" + echo " $dir directory missing" fi done @@ -710,13 +710,13 @@ cloud_security_status() { local policy_count=$(find "$cloud_security_dir/policies" -name "*.json" 2>/dev/null | wc -l) local report_count=$(find "$cloud_security_dir/reports" -name "*.json" 2>/dev/null | wc -l) - echo "📊 Statistics:" + echo " Statistics:" echo " Security scans: $scan_count" echo " Policy files: $policy_count" echo " Compliance reports: $report_count" else - echo "❌ System not initialized" + echo " System not initialized" echo " Run 'cloud-security init' to initialize" fi } diff --git a/src/apt-layer/scriptlets/24-dpkg-direct-install.sh b/src/apt-layer/scriptlets/24-dpkg-direct-install.sh index e102394..5a65b08 100644 --- a/src/apt-layer/scriptlets/24-dpkg-direct-install.sh +++ b/src/apt-layer/scriptlets/24-dpkg-direct-install.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Direct dpkg installation for Particle-OS apt-layer Tool # Provides faster, more controlled package installation using dpkg directly diff --git a/src/apt-layer/scriptlets/99-main.sh b/src/apt-layer/scriptlets/99-main.sh index 92ffa6a..8779807 100644 --- a/src/apt-layer/scriptlets/99-main.sh +++ b/src/apt-layer/scriptlets/99-main.sh @@ -1,3 +1,4 @@ +#!/bin/bash # Main execution and command dispatch for Particle-OS apt-layer Tool # Show concise usage information