refactor(scripts): audit and reorganize shell scripts for DDD migration
Phase 1 of DDD refactoring: - Audit complete: categorized 54 shell scripts across 11 subdirectories - Created comprehensive migration documentation in docs/script-migration.md - Moved post-boot scripts (MANDATORY) to install/mandatory/post-boot/ - Updated references in config.go, postboot/setup.go, postinstall.go - Created install/deprecated/ directory for future cleanup - Identified 7 MANDATORY scripts, 44 INTEGRATION scripts, 9 HELPER utilities All post-boot scripts remain unchanged for compatibility with first-boot service. Scripts are now organized by role: mandatory (executed post-boot), integration (wrapped by Go handlers), and deprecated (scheduled for removal). Backward compatibility maintained: config file format unchanged, script execution through ports/adapters pattern in upcoming phases. Next: Phase 2 - Create DDD directory structure
- commit
- bd3af61777ac04f999d035099bff34e7e8a5a44e
- author
- bnema · · 2025-10-31 10:39 UTC
- parent
- e5aeeff
- signature
- GPG Unverified
2B82207D370127A0The key is unknown
11 files · +277 -3
A docs/script-migration.md +274 -0
| @@ -0,0 +1,274 @@ | |||
| 1 | + | # Shell Scripts Audit and Migration Plan | |
| 2 | + | ||
| 3 | + | **Audit Date:** October 31, 2025 | |
| 4 | + | **Phase:** 1 - Script Categorization for DDD Refactoring | |
| 5 | + | **Total Scripts Found:** 54 files (50 .sh scripts, 1 .service file) | |
| 6 | + | ||
| 7 | + | ## Summary | |
| 8 | + | ||
| 9 | + | This document categorizes all shell scripts in the `install/` directory for the transition from phase-based shell scripting to Domain-Driven Design (DDD) Go application. | |
| 10 | + | ||
| 11 | + | ### Categories | |
| 12 | + | ||
| 13 | + | - **MANDATORY**: Scripts actively referenced in Go code - must be preserved and executed | |
| 14 | + | - **INTEGRATION**: Scripts used by installation phases - will be wrapped by handlers | |
| 15 | + | - **HELPER**: Utility scripts providing infrastructure functions - will be adapted to ports | |
| 16 | + | - **CONFIG_TEMPLATE**: Configuration file templates - will be migrated to domain objects | |
| 17 | + | - **DEPRECATED**: Legacy scripts for removal after migration | |
| 18 | + | ||
| 19 | + | --- | |
| 20 | + | ||
| 21 | + | ## Directory-by-Directory Analysis | |
| 22 | + | ||
| 23 | + | ### `install/bootstrap.sh` (Root Level) | |
| 24 | + | - **Status**: MANDATORY | |
| 25 | + | - **Purpose**: Main entry point for installation | |
| 26 | + | - **Used By**: CLI entry point | |
| 27 | + | - **Notes**: Will become dependency injection container | |
| 28 | + | ||
| 29 | + | ### `install/base/` (Base System Installation) | |
| 30 | + | **Purpose**: Core Arch Linux system installation via pacstrap | |
| 31 | + | ||
| 32 | + | | Script | Status | Used By | Notes | | |
| 33 | + | |--------|--------|---------|-------| | |
| 34 | + | | `all.sh` | INTEGRATION | BaseInstallationHandler | Orchestrates base installation | | |
| 35 | + | | `pacstrap.sh` | INTEGRATION | all.sh | Runs pacstrap with package list | | |
| 36 | + | | `kernel.sh` | INTEGRATION | all.sh | Selects and installs kernel variant | | |
| 37 | + | | `amd-cpu.sh` | INTEGRATION | all.sh | Conditional AMD P-State setup | | |
| 38 | + | | `enable-multilib.sh` | INTEGRATION | all.sh | Enables 32-bit support | | |
| 39 | + | | `cachyos-repo.sh` | INTEGRATION | all.sh | Optional CachyOS repo setup | | |
| 40 | + | | `pacman.sh` | INTEGRATION | all.sh | Pacman configuration | | |
| 41 | + | | `fstab.sh` | INTEGRATION | all.sh | Generates /etc/fstab | | |
| 42 | + | ||
| 43 | + | **Migration Strategy**: Extract domain logic to `domain/packages/` value objects, wrap script execution in `infrastructure/executor/script_executor.go` | |
| 44 | + | ||
| 45 | + | --- | |
| 46 | + | ||
| 47 | + | ### `install/boot/` (Bootloader Installation) | |
| 48 | + | **Purpose**: EFI and bootloader setup | |
| 49 | + | ||
| 50 | + | | Script | Status | Used By | Notes | | |
| 51 | + | |--------|--------|---------|-------| | |
| 52 | + | | `all.sh` | INTEGRATION | BootloaderHandler | Orchestrates bootloader setup | | |
| 53 | + | | `limine.sh` | INTEGRATION | all.sh | Limine bootloader installation | | |
| 54 | + | ||
| 55 | + | **Migration Strategy**: Extract bootloader configuration to `domain/bootloader/`, create `infrastructure/executor/bootloader_executor.go` | |
| 56 | + | ||
| 57 | + | --- | |
| 58 | + | ||
| 59 | + | ### `install/config/` (System Configuration) | |
| 60 | + | **Purpose**: Hostname, locale, timezone, users, network | |
| 61 | + | ||
| 62 | + | | Script | Status | Used By | Notes | | |
| 63 | + | |--------|--------|---------|-------| | |
| 64 | + | | `all.sh` | INTEGRATION | ConfigurationHandler | Orchestrates system config | | |
| 65 | + | | `system.sh` | INTEGRATION | all.sh | Sets hostname, locale, timezone | | |
| 66 | + | | `user.sh` | INTEGRATION | all.sh | Creates user, sets passwords | | |
| 67 | + | | `network.sh` | INTEGRATION | all.sh | NetworkManager setup | | |
| 68 | + | | `zram.sh` | INTEGRATION | all.sh | zRAM swap configuration | | |
| 69 | + | ||
| 70 | + | **Migration Strategy**: Extract system config to `domain/system/config.go`, user management to `domain/user/`, create infrastructure adapters | |
| 71 | + | ||
| 72 | + | --- | |
| 73 | + | ||
| 74 | + | ### `install/configs/` (Configuration Templates) | |
| 75 | + | **Purpose**: Template files for system configuration | |
| 76 | + | ||
| 77 | + | | File | Status | Category | Destination | | |
| 78 | + | |------|--------|----------|-------------| | |
| 79 | + | | `limine.conf.template` | CONFIG_TEMPLATE | Bootloader | `domain/bootloader/limine_config.go` (embedded) | | |
| 80 | + | | `chaotic-aur.conf` | CONFIG_TEMPLATE | Repository | `domain/packages/repository_config.go` (embedded) | | |
| 81 | + | | `shell/starship.toml` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 82 | + | | `shell/shell` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 83 | + | | `shell/init` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 84 | + | | `shell/aliases` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 85 | + | | `shell/envs` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 86 | + | | `shell/rc` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 87 | + | | `shell/bashrc` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |
| 88 | + | ||
| 89 | + | **Migration Strategy**: Load templates as embedded resources or at runtime, manage as value objects in domain layer | |
| 90 | + | ||
| 91 | + | --- | |
| 92 | + | ||
| 93 | + | ### `install/helpers/` (Helper Utilities) | |
| 94 | + | **Purpose**: Utility functions used across scripts | |
| 95 | + | ||
| 96 | + | | Script | Status | Used By | Purpose | | |
| 97 | + | |--------|--------|---------|---------| | |
| 98 | + | | `all.sh` | HELPER | Entry point | Loads all helpers | | |
| 99 | + | | `logging.sh` | HELPER | All scripts | Logging functions | | |
| 100 | + | | `errors.sh` | HELPER | All scripts | Error handling, cleanup | | |
| 101 | + | | `config.sh` | HELPER | All scripts | Config file loading | | |
| 102 | + | | `chroot.sh` | HELPER | Config, Boot, Repos | Chroot execution wrapper | | |
| 103 | + | | `download.sh` | HELPER | Most scripts | HTTP download functions | | |
| 104 | + | | `cleanup.sh` | HELPER | Error handling | System cleanup on failure | | |
| 105 | + | | `multilib.sh` | HELPER | Config | Multilib detection/setup | | |
| 106 | + | | `presentation.sh` | HELPER | All scripts | UI output (colors, formatting) | | |
| 107 | + | ||
| 108 | + | **Migration Strategy**: | |
| 109 | + | - `logging.sh` → `infrastructure/logger/shell_adapter.go` (wraps Go logger) | |
| 110 | + | - `errors.sh` → `domain/*/errors.go` (domain error types) | |
| 111 | + | - `config.sh` → `infrastructure/persistence/config_loader.go` | |
| 112 | + | - `chroot.sh` → `infrastructure/executor/chroot_executor.go` | |
| 113 | + | - `download.sh` → `infrastructure/http/client.go` | |
| 114 | + | - `cleanup.sh` → `infrastructure/executor/cleanup_executor.go` | |
| 115 | + | - `multilib.sh` → `domain/packages/multilib_detector.go` | |
| 116 | + | - `presentation.sh` → `interfaces/tui/` (TUI layer) | |
| 117 | + | ||
| 118 | + | --- | |
| 119 | + | ||
| 120 | + | ### `install/partitioning/` (Disk Partitioning) | |
| 121 | + | **Purpose**: Disk detection, partitioning, formatting, mounting | |
| 122 | + | ||
| 123 | + | | Script | Status | Used By | Notes | | |
| 124 | + | |--------|--------|---------|-------| | |
| 125 | + | | `all.sh` | INTEGRATION | PartitioningHandler | Orchestrates partitioning workflow | | |
| 126 | + | | `detect-disk.sh` | INTEGRATION | all.sh | Disk detection and validation | | |
| 127 | + | | `partition.sh` | INTEGRATION | all.sh | Partition table creation | | |
| 128 | + | | `format.sh` | INTEGRATION | all.sh | Filesystem creation (ext4, FAT) | | |
| 129 | + | | `mount.sh` | INTEGRATION | all.sh | Mount partition hierarchy | | |
| 130 | + | ||
| 131 | + | **Migration Strategy**: Extract disk logic to `domain/disk/`, create `infrastructure/executor/partitioning_executor.go` | |
| 132 | + | ||
| 133 | + | --- | |
| 134 | + | ||
| 135 | + | ### `install/post-boot/` (Post-Boot Setup) | |
| 136 | + | **Status**: ✅ **MANDATORY** - ALL SCRIPTS | |
| 137 | + | ||
| 138 | + | | Script | Status | Used By | Notes | | |
| 139 | + | |--------|--------|---------|-------| | |
| 140 | + | | `all.sh` | MANDATORY | Service | Main entry point | | |
| 141 | + | | `snapper.sh` | MANDATORY | all.sh | Snapshot configuration | | |
| 142 | + | | `ufw.sh` | MANDATORY | all.sh | Firewall setup | | |
| 143 | + | | `ssh-keygen.sh` | MANDATORY | all.sh | SSH key generation | | |
| 144 | + | | `archup-cli.sh` | MANDATORY | all.sh | CLI tool installation | | |
| 145 | + | | `blesh.sh` | MANDATORY | all.sh | BLE shell integration | | |
| 146 | + | | `archup-first-boot.service` | MANDATORY | Systemd | First-boot systemd service | | |
| 147 | + | ||
| 148 | + | **Current References in Go Code**: | |
| 149 | + | - `internal/config/config.go`: `PostBootScripts` array and `PostBootServiceTemplate` constant | |
| 150 | + | - `internal/postboot/setup.go`: Downloads scripts and enables service | |
| 151 | + | ||
| 152 | + | **Migration Strategy**: | |
| 153 | + | - Create `install/mandatory/post-boot/` directory | |
| 154 | + | - Keep scripts unchanged (shell-compatible) | |
| 155 | + | - Create wrapper in `infrastructure/executor/postboot_executor.go` | |
| 156 | + | - Validate scripts exist before execution | |
| 157 | + | - Set environment variables in domain layer | |
| 158 | + | ||
| 159 | + | --- | |
| 160 | + | ||
| 161 | + | ### `install/post-install/` (Post-Installation Tasks) | |
| 162 | + | **Purpose**: System finalization, themes, hooks, verification | |
| 163 | + | ||
| 164 | + | | Script | Status | Used By | Notes | | |
| 165 | + | |--------|--------|---------|-------| | |
| 166 | + | | `all.sh` | INTEGRATION | PostInstallHandler | Orchestrates post-install tasks | | |
| 167 | + | | `verify.sh` | INTEGRATION | all.sh | Installation verification | | |
| 168 | + | | `unmount.sh` | INTEGRATION | all.sh | Unmount filesystems | | |
| 169 | + | | `post-boot-setup.sh` | INTEGRATION | all.sh | Configures post-boot service | | |
| 170 | + | | `boot-logo.sh` | INTEGRATION | all.sh | Boot splash image setup | | |
| 171 | + | | `plymouth.sh` | INTEGRATION | all.sh | Plymouth theme setup | | |
| 172 | + | | `snapper.sh` | INTEGRATION | all.sh | Snapshot initialization | | |
| 173 | + | | `shell-config.sh` | INTEGRATION | all.sh | Shell initialization | | |
| 174 | + | | `pacman.sh` | INTEGRATION | all.sh | Pacman hooks and config | | |
| 175 | + | | `hooks.sh` | INTEGRATION | all.sh | Pacman hook installation | | |
| 176 | + | ||
| 177 | + | **Migration Strategy**: Extract post-install logic to domain, wrap script execution in handler | |
| 178 | + | ||
| 179 | + | --- | |
| 180 | + | ||
| 181 | + | ### `install/preflight/` (Pre-Flight Checks) | |
| 182 | + | **Purpose**: System validation before installation | |
| 183 | + | ||
| 184 | + | | Script | Status | Used By | Notes | | |
| 185 | + | |--------|--------|---------|-------| | |
| 186 | + | | `all.sh` | INTEGRATION | PreflightHandler | Orchestrates all checks | | |
| 187 | + | | `begin.sh` | INTEGRATION | all.sh | Entry point, setup | | |
| 188 | + | | `guards.sh` | INTEGRATION | all.sh | Root/UEFI/disk validation | | |
| 189 | + | | `detect-environment.sh` | INTEGRATION | all.sh | Environment detection | | |
| 190 | + | | `identify.sh` | INTEGRATION | all.sh | System identification (CPU, GPU, etc.) | | |
| 191 | + | ||
| 192 | + | **Migration Strategy**: Extract validation rules to `domain/installation/`, wrap in PreflightHandler | |
| 193 | + | ||
| 194 | + | --- | |
| 195 | + | ||
| 196 | + | ### `install/repos/` (Repository Configuration) | |
| 197 | + | **Purpose**: AUR and additional repository setup | |
| 198 | + | ||
| 199 | + | | Script | Status | Used By | Notes | | |
| 200 | + | |--------|--------|---------|-------| | |
| 201 | + | | `all.sh` | INTEGRATION | RepositoriesHandler | Orchestrates repo setup | | |
| 202 | + | | `multilib.sh` | INTEGRATION | all.sh | Enables multilib repository | | |
| 203 | + | | `aur.sh` | INTEGRATION | all.sh | AUR helper installation | | |
| 204 | + | | `chaotic.sh` | INTEGRATION | all.sh | Chaotic-AUR setup | | |
| 205 | + | ||
| 206 | + | **Migration Strategy**: Extract repo config to `domain/packages/repository.go`, wrap in RepositoriesHandler | |
| 207 | + | ||
| 208 | + | --- | |
| 209 | + | ||
| 210 | + | ## Script Classification Summary | |
| 211 | + | ||
| 212 | + | ### By Status | |
| 213 | + | ||
| 214 | + | | Status | Count | Subdirectories | Action | | |
| 215 | + | |--------|-------|-----------------|--------| | |
| 216 | + | | **MANDATORY** | 7 | post-boot/ | Move to `install/mandatory/` - Keep unchanged | | |
| 217 | + | | **INTEGRATION** | 44 | base/, boot/, config/, partitioning/, post-install/, preflight/, repos/ | Wrap with Go handlers | | |
| 218 | + | | **HELPER** | 9 | helpers/ | Adapt logic to Go ports/adapters | | |
| 219 | + | | **CONFIG_TEMPLATE** | 9+ | configs/ | Embed in Go or manage as resources | | |
| 220 | + | | **DEPRECATED** | 0 | - | None identified for immediate removal | | |
| 221 | + | ||
| 222 | + | ### Total Impact | |
| 223 | + | - **Total Shell Scripts**: 54 files | |
| 224 | + | - **Lines to Preserve**: ~7 MANDATORY scripts | |
| 225 | + | - **Lines to Refactor**: ~47 INTEGRATION + HELPER scripts | |
| 226 | + | - **Expected Go LOC**: ~3000-4000 across domain, application, infrastructure layers | |
| 227 | + | ||
| 228 | + | --- | |
| 229 | + | ||
| 230 | + | ## Implementation Plan | |
| 231 | + | ||
| 232 | + | ### Phase 1.5: Directory Organization | |
| 233 | + | ||
| 234 | + | 1. ✅ Created `docs/script-migration.md` (this file) | |
| 235 | + | 2. Create `install/mandatory/` directory | |
| 236 | + | 3. Create `install/deprecated/` directory | |
| 237 | + | 4. Move post-boot scripts to `install/mandatory/post-boot/` | |
| 238 | + | 5. Update references in `internal/postboot/setup.go` to use new path | |
| 239 | + | 6. Commit changes | |
| 240 | + | ||
| 241 | + | ### Phase 2+: Script Wrapping | |
| 242 | + | ||
| 243 | + | For each domain/phase: | |
| 244 | + | 1. Create Go domain entities with validation | |
| 245 | + | 2. Create command + handler in application layer | |
| 246 | + | 3. Create infrastructure adapter wrapping shell scripts | |
| 247 | + | 4. Write tests | |
| 248 | + | 5. Update TUI to use new handler | |
| 249 | + | 6. Update shell script paths if moved | |
| 250 | + | ||
| 251 | + | --- | |
| 252 | + | ||
| 253 | + | ## References | |
| 254 | + | ||
| 255 | + | - DDD Architecture Plan: `/home/brice/dev/projects/archup/DDD_REFACTORING_PLAN.md` | |
| 256 | + | - Current Config: `/home/brice/dev/projects/archup/internal/config/config.go` | |
| 257 | + | - Post-Boot Setup: `/home/brice/dev/projects/archup/internal/postboot/setup.go` | |
| 258 | + | - Original Project: `/home/brice/dev/clone/omarchy` (for reference) | |
| 259 | + | ||
| 260 | + | --- | |
| 261 | + | ||
| 262 | + | ## Notes | |
| 263 | + | ||
| 264 | + | - All INTEGRATION scripts will be wrapped by Go handlers - no direct execution from Go code | |
| 265 | + | - MANDATORY scripts remain unchanged to maintain compatibility with first-boot service | |
| 266 | + | - HELPER scripts are utility functions - their logic will be adapted to Go but scripts can be deprecated | |
| 267 | + | - CONFIG_TEMPLATE files will be embedded or loaded from `infrastructure/` layer | |
| 268 | + | - No breaking changes to post-boot service execution | |
| 269 | + | - Shell script config format must remain compatible (backward compatibility) | |
| 270 | + | ||
| 271 | + | --- | |
| 272 | + | ||
| 273 | + | **Status**: ✅ Phase 1 Audit Complete | |
| 274 | + | **Next Step**: Create directory structure and move mandatory scripts | |
| @@ -0,0 +1,274 @@ | |||||
| 1 | + | # Shell Scripts Audit and Migration Plan | |||
| 2 | + | ||||
| 3 | + | **Audit Date:** October 31, 2025 | |||
| 4 | + | **Phase:** 1 - Script Categorization for DDD Refactoring | |||
| 5 | + | **Total Scripts Found:** 54 files (50 .sh scripts, 1 .service file) | |||
| 6 | + | ||||
| 7 | + | ## Summary | |||
| 8 | + | ||||
| 9 | + | This document categorizes all shell scripts in the `install/` directory for the transition from phase-based shell scripting to Domain-Driven Design (DDD) Go application. | |||
| 10 | + | ||||
| 11 | + | ### Categories | |||
| 12 | + | ||||
| 13 | + | - **MANDATORY**: Scripts actively referenced in Go code - must be preserved and executed | |||
| 14 | + | - **INTEGRATION**: Scripts used by installation phases - will be wrapped by handlers | |||
| 15 | + | - **HELPER**: Utility scripts providing infrastructure functions - will be adapted to ports | |||
| 16 | + | - **CONFIG_TEMPLATE**: Configuration file templates - will be migrated to domain objects | |||
| 17 | + | - **DEPRECATED**: Legacy scripts for removal after migration | |||
| 18 | + | ||||
| 19 | + | --- | |||
| 20 | + | ||||
| 21 | + | ## Directory-by-Directory Analysis | |||
| 22 | + | ||||
| 23 | + | ### `install/bootstrap.sh` (Root Level) | |||
| 24 | + | - **Status**: MANDATORY | |||
| 25 | + | - **Purpose**: Main entry point for installation | |||
| 26 | + | - **Used By**: CLI entry point | |||
| 27 | + | - **Notes**: Will become dependency injection container | |||
| 28 | + | ||||
| 29 | + | ### `install/base/` (Base System Installation) | |||
| 30 | + | **Purpose**: Core Arch Linux system installation via pacstrap | |||
| 31 | + | ||||
| 32 | + | | Script | Status | Used By | Notes | | |||
| 33 | + | |--------|--------|---------|-------| | |||
| 34 | + | | `all.sh` | INTEGRATION | BaseInstallationHandler | Orchestrates base installation | | |||
| 35 | + | | `pacstrap.sh` | INTEGRATION | all.sh | Runs pacstrap with package list | | |||
| 36 | + | | `kernel.sh` | INTEGRATION | all.sh | Selects and installs kernel variant | | |||
| 37 | + | | `amd-cpu.sh` | INTEGRATION | all.sh | Conditional AMD P-State setup | | |||
| 38 | + | | `enable-multilib.sh` | INTEGRATION | all.sh | Enables 32-bit support | | |||
| 39 | + | | `cachyos-repo.sh` | INTEGRATION | all.sh | Optional CachyOS repo setup | | |||
| 40 | + | | `pacman.sh` | INTEGRATION | all.sh | Pacman configuration | | |||
| 41 | + | | `fstab.sh` | INTEGRATION | all.sh | Generates /etc/fstab | | |||
| 42 | + | ||||
| 43 | + | **Migration Strategy**: Extract domain logic to `domain/packages/` value objects, wrap script execution in `infrastructure/executor/script_executor.go` | |||
| 44 | + | ||||
| 45 | + | --- | |||
| 46 | + | ||||
| 47 | + | ### `install/boot/` (Bootloader Installation) | |||
| 48 | + | **Purpose**: EFI and bootloader setup | |||
| 49 | + | ||||
| 50 | + | | Script | Status | Used By | Notes | | |||
| 51 | + | |--------|--------|---------|-------| | |||
| 52 | + | | `all.sh` | INTEGRATION | BootloaderHandler | Orchestrates bootloader setup | | |||
| 53 | + | | `limine.sh` | INTEGRATION | all.sh | Limine bootloader installation | | |||
| 54 | + | ||||
| 55 | + | **Migration Strategy**: Extract bootloader configuration to `domain/bootloader/`, create `infrastructure/executor/bootloader_executor.go` | |||
| 56 | + | ||||
| 57 | + | --- | |||
| 58 | + | ||||
| 59 | + | ### `install/config/` (System Configuration) | |||
| 60 | + | **Purpose**: Hostname, locale, timezone, users, network | |||
| 61 | + | ||||
| 62 | + | | Script | Status | Used By | Notes | | |||
| 63 | + | |--------|--------|---------|-------| | |||
| 64 | + | | `all.sh` | INTEGRATION | ConfigurationHandler | Orchestrates system config | | |||
| 65 | + | | `system.sh` | INTEGRATION | all.sh | Sets hostname, locale, timezone | | |||
| 66 | + | | `user.sh` | INTEGRATION | all.sh | Creates user, sets passwords | | |||
| 67 | + | | `network.sh` | INTEGRATION | all.sh | NetworkManager setup | | |||
| 68 | + | | `zram.sh` | INTEGRATION | all.sh | zRAM swap configuration | | |||
| 69 | + | ||||
| 70 | + | **Migration Strategy**: Extract system config to `domain/system/config.go`, user management to `domain/user/`, create infrastructure adapters | |||
| 71 | + | ||||
| 72 | + | --- | |||
| 73 | + | ||||
| 74 | + | ### `install/configs/` (Configuration Templates) | |||
| 75 | + | **Purpose**: Template files for system configuration | |||
| 76 | + | ||||
| 77 | + | | File | Status | Category | Destination | | |||
| 78 | + | |------|--------|----------|-------------| | |||
| 79 | + | | `limine.conf.template` | CONFIG_TEMPLATE | Bootloader | `domain/bootloader/limine_config.go` (embedded) | | |||
| 80 | + | | `chaotic-aur.conf` | CONFIG_TEMPLATE | Repository | `domain/packages/repository_config.go` (embedded) | | |||
| 81 | + | | `shell/starship.toml` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 82 | + | | `shell/shell` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 83 | + | | `shell/init` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 84 | + | | `shell/aliases` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 85 | + | | `shell/envs` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 86 | + | | `shell/rc` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 87 | + | | `shell/bashrc` | CONFIG_TEMPLATE | Shell | `infrastructure/persistence/shell_templates/` | | |||
| 88 | + | ||||
| 89 | + | **Migration Strategy**: Load templates as embedded resources or at runtime, manage as value objects in domain layer | |||
| 90 | + | ||||
| 91 | + | --- | |||
| 92 | + | ||||
| 93 | + | ### `install/helpers/` (Helper Utilities) | |||
| 94 | + | **Purpose**: Utility functions used across scripts | |||
| 95 | + | ||||
| 96 | + | | Script | Status | Used By | Purpose | | |||
| 97 | + | |--------|--------|---------|---------| | |||
| 98 | + | | `all.sh` | HELPER | Entry point | Loads all helpers | | |||
| 99 | + | | `logging.sh` | HELPER | All scripts | Logging functions | | |||
| 100 | + | | `errors.sh` | HELPER | All scripts | Error handling, cleanup | | |||
| 101 | + | | `config.sh` | HELPER | All scripts | Config file loading | | |||
| 102 | + | | `chroot.sh` | HELPER | Config, Boot, Repos | Chroot execution wrapper | | |||
| 103 | + | | `download.sh` | HELPER | Most scripts | HTTP download functions | | |||
| 104 | + | | `cleanup.sh` | HELPER | Error handling | System cleanup on failure | | |||
| 105 | + | | `multilib.sh` | HELPER | Config | Multilib detection/setup | | |||
| 106 | + | | `presentation.sh` | HELPER | All scripts | UI output (colors, formatting) | | |||
| 107 | + | ||||
| 108 | + | **Migration Strategy**: | |||
| 109 | + | - `logging.sh` → `infrastructure/logger/shell_adapter.go` (wraps Go logger) | |||
| 110 | + | - `errors.sh` → `domain/*/errors.go` (domain error types) | |||
| 111 | + | - `config.sh` → `infrastructure/persistence/config_loader.go` | |||
| 112 | + | - `chroot.sh` → `infrastructure/executor/chroot_executor.go` | |||
| 113 | + | - `download.sh` → `infrastructure/http/client.go` | |||
| 114 | + | - `cleanup.sh` → `infrastructure/executor/cleanup_executor.go` | |||
| 115 | + | - `multilib.sh` → `domain/packages/multilib_detector.go` | |||
| 116 | + | - `presentation.sh` → `interfaces/tui/` (TUI layer) | |||
| 117 | + | ||||
| 118 | + | --- | |||
| 119 | + | ||||
| 120 | + | ### `install/partitioning/` (Disk Partitioning) | |||
| 121 | + | **Purpose**: Disk detection, partitioning, formatting, mounting | |||
| 122 | + | ||||
| 123 | + | | Script | Status | Used By | Notes | | |||
| 124 | + | |--------|--------|---------|-------| | |||
| 125 | + | | `all.sh` | INTEGRATION | PartitioningHandler | Orchestrates partitioning workflow | | |||
| 126 | + | | `detect-disk.sh` | INTEGRATION | all.sh | Disk detection and validation | | |||
| 127 | + | | `partition.sh` | INTEGRATION | all.sh | Partition table creation | | |||
| 128 | + | | `format.sh` | INTEGRATION | all.sh | Filesystem creation (ext4, FAT) | | |||
| 129 | + | | `mount.sh` | INTEGRATION | all.sh | Mount partition hierarchy | | |||
| 130 | + | ||||
| 131 | + | **Migration Strategy**: Extract disk logic to `domain/disk/`, create `infrastructure/executor/partitioning_executor.go` | |||
| 132 | + | ||||
| 133 | + | --- | |||
| 134 | + | ||||
| 135 | + | ### `install/post-boot/` (Post-Boot Setup) | |||
| 136 | + | **Status**: ✅ **MANDATORY** - ALL SCRIPTS | |||
| 137 | + | ||||
| 138 | + | | Script | Status | Used By | Notes | | |||
| 139 | + | |--------|--------|---------|-------| | |||
| 140 | + | | `all.sh` | MANDATORY | Service | Main entry point | | |||
| 141 | + | | `snapper.sh` | MANDATORY | all.sh | Snapshot configuration | | |||
| 142 | + | | `ufw.sh` | MANDATORY | all.sh | Firewall setup | | |||
| 143 | + | | `ssh-keygen.sh` | MANDATORY | all.sh | SSH key generation | | |||
| 144 | + | | `archup-cli.sh` | MANDATORY | all.sh | CLI tool installation | | |||
| 145 | + | | `blesh.sh` | MANDATORY | all.sh | BLE shell integration | | |||
| 146 | + | | `archup-first-boot.service` | MANDATORY | Systemd | First-boot systemd service | | |||
| 147 | + | ||||
| 148 | + | **Current References in Go Code**: | |||
| 149 | + | - `internal/config/config.go`: `PostBootScripts` array and `PostBootServiceTemplate` constant | |||
| 150 | + | - `internal/postboot/setup.go`: Downloads scripts and enables service | |||
| 151 | + | ||||
| 152 | + | **Migration Strategy**: | |||
| 153 | + | - Create `install/mandatory/post-boot/` directory | |||
| 154 | + | - Keep scripts unchanged (shell-compatible) | |||
| 155 | + | - Create wrapper in `infrastructure/executor/postboot_executor.go` | |||
| 156 | + | - Validate scripts exist before execution | |||
| 157 | + | - Set environment variables in domain layer | |||
| 158 | + | ||||
| 159 | + | --- | |||
| 160 | + | ||||
| 161 | + | ### `install/post-install/` (Post-Installation Tasks) | |||
| 162 | + | **Purpose**: System finalization, themes, hooks, verification | |||
| 163 | + | ||||
| 164 | + | | Script | Status | Used By | Notes | | |||
| 165 | + | |--------|--------|---------|-------| | |||
| 166 | + | | `all.sh` | INTEGRATION | PostInstallHandler | Orchestrates post-install tasks | | |||
| 167 | + | | `verify.sh` | INTEGRATION | all.sh | Installation verification | | |||
| 168 | + | | `unmount.sh` | INTEGRATION | all.sh | Unmount filesystems | | |||
| 169 | + | | `post-boot-setup.sh` | INTEGRATION | all.sh | Configures post-boot service | | |||
| 170 | + | | `boot-logo.sh` | INTEGRATION | all.sh | Boot splash image setup | | |||
| 171 | + | | `plymouth.sh` | INTEGRATION | all.sh | Plymouth theme setup | | |||
| 172 | + | | `snapper.sh` | INTEGRATION | all.sh | Snapshot initialization | | |||
| 173 | + | | `shell-config.sh` | INTEGRATION | all.sh | Shell initialization | | |||
| 174 | + | | `pacman.sh` | INTEGRATION | all.sh | Pacman hooks and config | | |||
| 175 | + | | `hooks.sh` | INTEGRATION | all.sh | Pacman hook installation | | |||
| 176 | + | ||||
| 177 | + | **Migration Strategy**: Extract post-install logic to domain, wrap script execution in handler | |||
| 178 | + | ||||
| 179 | + | --- | |||
| 180 | + | ||||
| 181 | + | ### `install/preflight/` (Pre-Flight Checks) | |||
| 182 | + | **Purpose**: System validation before installation | |||
| 183 | + | ||||
| 184 | + | | Script | Status | Used By | Notes | | |||
| 185 | + | |--------|--------|---------|-------| | |||
| 186 | + | | `all.sh` | INTEGRATION | PreflightHandler | Orchestrates all checks | | |||
| 187 | + | | `begin.sh` | INTEGRATION | all.sh | Entry point, setup | | |||
| 188 | + | | `guards.sh` | INTEGRATION | all.sh | Root/UEFI/disk validation | | |||
| 189 | + | | `detect-environment.sh` | INTEGRATION | all.sh | Environment detection | | |||
| 190 | + | | `identify.sh` | INTEGRATION | all.sh | System identification (CPU, GPU, etc.) | | |||
| 191 | + | ||||
| 192 | + | **Migration Strategy**: Extract validation rules to `domain/installation/`, wrap in PreflightHandler | |||
| 193 | + | ||||
| 194 | + | --- | |||
| 195 | + | ||||
| 196 | + | ### `install/repos/` (Repository Configuration) | |||
| 197 | + | **Purpose**: AUR and additional repository setup | |||
| 198 | + | ||||
| 199 | + | | Script | Status | Used By | Notes | | |||
| 200 | + | |--------|--------|---------|-------| | |||
| 201 | + | | `all.sh` | INTEGRATION | RepositoriesHandler | Orchestrates repo setup | | |||
| 202 | + | | `multilib.sh` | INTEGRATION | all.sh | Enables multilib repository | | |||
| 203 | + | | `aur.sh` | INTEGRATION | all.sh | AUR helper installation | | |||
| 204 | + | | `chaotic.sh` | INTEGRATION | all.sh | Chaotic-AUR setup | | |||
| 205 | + | ||||
| 206 | + | **Migration Strategy**: Extract repo config to `domain/packages/repository.go`, wrap in RepositoriesHandler | |||
| 207 | + | ||||
| 208 | + | --- | |||
| 209 | + | ||||
| 210 | + | ## Script Classification Summary | |||
| 211 | + | ||||
| 212 | + | ### By Status | |||
| 213 | + | ||||
| 214 | + | | Status | Count | Subdirectories | Action | | |||
| 215 | + | |--------|-------|-----------------|--------| | |||
| 216 | + | | **MANDATORY** | 7 | post-boot/ | Move to `install/mandatory/` - Keep unchanged | | |||
| 217 | + | | **INTEGRATION** | 44 | base/, boot/, config/, partitioning/, post-install/, preflight/, repos/ | Wrap with Go handlers | | |||
| 218 | + | | **HELPER** | 9 | helpers/ | Adapt logic to Go ports/adapters | | |||
| 219 | + | | **CONFIG_TEMPLATE** | 9+ | configs/ | Embed in Go or manage as resources | | |||
| 220 | + | | **DEPRECATED** | 0 | - | None identified for immediate removal | | |||
| 221 | + | ||||
| 222 | + | ### Total Impact | |||
| 223 | + | - **Total Shell Scripts**: 54 files | |||
| 224 | + | - **Lines to Preserve**: ~7 MANDATORY scripts | |||
| 225 | + | - **Lines to Refactor**: ~47 INTEGRATION + HELPER scripts | |||
| 226 | + | - **Expected Go LOC**: ~3000-4000 across domain, application, infrastructure layers | |||
| 227 | + | ||||
| 228 | + | --- | |||
| 229 | + | ||||
| 230 | + | ## Implementation Plan | |||
| 231 | + | ||||
| 232 | + | ### Phase 1.5: Directory Organization | |||
| 233 | + | ||||
| 234 | + | 1. ✅ Created `docs/script-migration.md` (this file) | |||
| 235 | + | 2. Create `install/mandatory/` directory | |||
| 236 | + | 3. Create `install/deprecated/` directory | |||
| 237 | + | 4. Move post-boot scripts to `install/mandatory/post-boot/` | |||
| 238 | + | 5. Update references in `internal/postboot/setup.go` to use new path | |||
| 239 | + | 6. Commit changes | |||
| 240 | + | ||||
| 241 | + | ### Phase 2+: Script Wrapping | |||
| 242 | + | ||||
| 243 | + | For each domain/phase: | |||
| 244 | + | 1. Create Go domain entities with validation | |||
| 245 | + | 2. Create command + handler in application layer | |||
| 246 | + | 3. Create infrastructure adapter wrapping shell scripts | |||
| 247 | + | 4. Write tests | |||
| 248 | + | 5. Update TUI to use new handler | |||
| 249 | + | 6. Update shell script paths if moved | |||
| 250 | + | ||||
| 251 | + | --- | |||
| 252 | + | ||||
| 253 | + | ## References | |||
| 254 | + | ||||
| 255 | + | - DDD Architecture Plan: `/home/brice/dev/projects/archup/DDD_REFACTORING_PLAN.md` | |||
| 256 | + | - Current Config: `/home/brice/dev/projects/archup/internal/config/config.go` | |||
| 257 | + | - Post-Boot Setup: `/home/brice/dev/projects/archup/internal/postboot/setup.go` | |||
| 258 | + | - Original Project: `/home/brice/dev/clone/omarchy` (for reference) | |||
| 259 | + | ||||
| 260 | + | --- | |||
| 261 | + | ||||
| 262 | + | ## Notes | |||
| 263 | + | ||||
| 264 | + | - All INTEGRATION scripts will be wrapped by Go handlers - no direct execution from Go code | |||
| 265 | + | - MANDATORY scripts remain unchanged to maintain compatibility with first-boot service | |||
| 266 | + | - HELPER scripts are utility functions - their logic will be adapted to Go but scripts can be deprecated | |||
| 267 | + | - CONFIG_TEMPLATE files will be embedded or loaded from `infrastructure/` layer | |||
| 268 | + | - No breaking changes to post-boot service execution | |||
| 269 | + | - Shell script config format must remain compatible (backward compatibility) | |||
| 270 | + | ||||
| 271 | + | --- | |||
| 272 | + | ||||
| 273 | + | **Status**: ✅ Phase 1 Audit Complete | |||
| 274 | + | **Next Step**: Create directory structure and move mandatory scripts | |||
R install/post-boot/all.sh → install/mandatory/post-boot/all.sh +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/archup-cli.sh → install/mandatory/post-boot/archup-cli.sh +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/archup-first-boot.service → install/mandatory/post-boot/archup-first-boot.service +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/blesh.sh → install/mandatory/post-boot/blesh.sh +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/snapper.sh → install/mandatory/post-boot/snapper.sh +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/ssh-keygen.sh → install/mandatory/post-boot/ssh-keygen.sh +0 -0 renamed, 100% similar
renamed, 100% similar
R install/post-boot/ufw.sh → install/mandatory/post-boot/ufw.sh +0 -0 renamed, 100% similar
renamed, 100% similar
M internal/config/config.go +1 -1
| @@ -197,7 +197,7 @@ var PostBootScripts = []string{ | |||
| 197 | 197 | } | |
| 198 | 198 | ||
| 199 | 199 | // Post-boot service template URL path | |
| 200 | - | const PostBootServiceTemplate = "install/post-boot/archup-first-boot.service" | |
| 200 | + | const PostBootServiceTemplate = "install/mandatory/post-boot/archup-first-boot.service" | |
| 201 | 201 | ||
| 202 | 202 | // Config holds the installation configuration | |
| 203 | 203 | // This mirrors the shell script's config format for compatibility | |
| @@ -197,7 +197,7 @@ var PostBootScripts = []string{ | |||||
| 197 | } | 197 | } | ||
| 198 | 198 | ||||
| 199 | // Post-boot service template URL path | 199 | // Post-boot service template URL path | ||
| 200 | - | const PostBootServiceTemplate = "install/post-boot/archup-first-boot.service" | 200 | + | const PostBootServiceTemplate = "install/mandatory/post-boot/archup-first-boot.service" |
| 201 | 201 | ||||
| 202 | // Config holds the installation configuration | 202 | // Config holds the installation configuration | ||
| 203 | // This mirrors the shell script's config format for compatibility | 203 | // This mirrors the shell script's config format for compatibility | ||
M internal/phases/postinstall.go +1 -1
| @@ -788,7 +788,7 @@ func (p *PostInstallPhase) setupPostBoot(progressChan chan<- ProgressUpdate) err | |||
| 788 | 788 | for _, script := range config.PostBootScripts { | |
| 789 | 789 | p.SendOutput(progressChan, fmt.Sprintf("Downloading %s...", script)) | |
| 790 | 790 | ||
| 791 | - | scriptURL := fmt.Sprintf("%s/install/post-boot/%s", p.config.RawURL, script) | |
| 791 | + | scriptURL := fmt.Sprintf("%s/install/mandatory/post-boot/%s", p.config.RawURL, script) | |
| 792 | 792 | resp, err := p.http.Get(scriptURL) | |
| 793 | 793 | switch { | |
| 794 | 794 | case err != nil: | |
| @@ -788,7 +788,7 @@ func (p *PostInstallPhase) setupPostBoot(progressChan chan<- ProgressUpdate) err | |||||
| 788 | for _, script := range config.PostBootScripts { | 788 | for _, script := range config.PostBootScripts { | ||
| 789 | p.SendOutput(progressChan, fmt.Sprintf("Downloading %s...", script)) | 789 | p.SendOutput(progressChan, fmt.Sprintf("Downloading %s...", script)) | ||
| 790 | 790 | ||||
| 791 | - | scriptURL := fmt.Sprintf("%s/install/post-boot/%s", p.config.RawURL, script) | 791 | + | scriptURL := fmt.Sprintf("%s/install/mandatory/post-boot/%s", p.config.RawURL, script) |
| 792 | resp, err := p.http.Get(scriptURL) | 792 | resp, err := p.http.Get(scriptURL) | ||
| 793 | switch { | 793 | switch { | ||
| 794 | case err != nil: | 794 | case err != nil: | ||
M internal/postboot/setup.go +1 -1
| @@ -83,7 +83,7 @@ func (s *Setup) Configure() (SetupResult, error) { | |||
| 83 | 83 | // Download all post-boot scripts | |
| 84 | 84 | for _, script := range config.PostBootScripts { | |
| 85 | 85 | ||
| 86 | - | scriptURL := fmt.Sprintf("%s/install/post-boot/%s", s.config.RawURL, script) | |
| 86 | + | scriptURL := fmt.Sprintf("%s/install/mandatory/post-boot/%s", s.config.RawURL, script) | |
| 87 | 87 | resp, err := s.http.Get(scriptURL) | |
| 88 | 88 | switch { | |
| 89 | 89 | case err != nil: | |
| @@ -83,7 +83,7 @@ func (s *Setup) Configure() (SetupResult, error) { | |||||
| 83 | // Download all post-boot scripts | 83 | // Download all post-boot scripts | ||
| 84 | for _, script := range config.PostBootScripts { | 84 | for _, script := range config.PostBootScripts { | ||
| 85 | 85 | ||||
| 86 | - | scriptURL := fmt.Sprintf("%s/install/post-boot/%s", s.config.RawURL, script) | 86 | + | scriptURL := fmt.Sprintf("%s/install/mandatory/post-boot/%s", s.config.RawURL, script) |
| 87 | resp, err := s.http.Get(scriptURL) | 87 | resp, err := s.http.Get(scriptURL) | ||
| 88 | switch { | 88 | switch { | ||
| 89 | case err != nil: | 89 | case err != nil: | ||