From 112b896e6127821787dd9ab9d1698413681733b6 Mon Sep 17 00:00:00 2001 From: Michael Czechowski Date: Wed, 17 Sep 2025 09:20:17 +0200 Subject: [PATCH] feat: enhance abra installation with proper verification and user commands - Replace incorrect file-based abra verification with functional testing - Add network connectivity monitoring to abra installer service - Implement retry logic with proper error handling - Add user-friendly 'install' command for manual abra repair - Update documentation to include install command and troubleshooting - Fix false positive detection in abra installation verification The enhanced service now: - Uses 'sudo abra --version' for reliable verification - Waits for internet connectivity before attempting installation - Retries up to 3 times with proper backoff - Provides clear success/failure reporting - Includes automatic service restart on failure User can now run 'install' command as fallback when abra installation fails. --- README.md | 10 ++++ common.nix | 105 ++++++++++++++++++++++++++-------- docs/MANUAL_NETWORK_SETUP.md | 18 ++++-- docs/USB_BOOT_INSTRUCTIONS.md | 7 +++ 4 files changed, 112 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 4898d21..d41b244 100644 --- a/README.md +++ b/README.md @@ -128,6 +128,7 @@ Based on Co-op Cloud with quality scoring: - `recipes` - Show complete Co-op Cloud catalog - `deploy ` - Deploy locally with tab completion - `browser [app]` - Launch Firefox [to specific app] +- `install` - Repair abra installation if needed - `desktop` - Start GUI session - `help` - Show all commands and debug info @@ -175,6 +176,15 @@ make clean # Clean build artifacts (./build/ and ./result/) # Check WiFi connection (should connect automatically) nmcli connection show --active +# Check abra installation +sudo abra --version + +# Repair abra installation +install + +# Check abra service status +sudo systemctl status workshop-abra-install + # Check DNS resolution dig @127.0.0.1 test.workshop.local diff --git a/common.nix b/common.nix index 9ad07e9..f0bb939 100644 --- a/common.nix +++ b/common.nix @@ -489,12 +489,12 @@ isoConfig }; }; - # Abra Installation Service (System-wide) + # Abra Installation Service (System-wide) with Enhanced Verification systemd.services.workshop-abra-install = { - description = "Install abra CLI system-wide"; + description = "Install abra CLI system-wide with retry logic and proper verification"; wantedBy = [ "multi-user.target" ]; - after = [ "workshop-system-setup.service" ]; - wants = [ "workshop-system-setup.service" ]; + after = [ "network-online.target" ]; + wants = [ "network-online.target" ]; path = with pkgs; [ bash wget @@ -509,38 +509,69 @@ isoConfig ]; script = '' - # Set proper environment + # Enhanced installation with proper verification export TERM=xterm-256color export HOME=/root - # Check if abra is already installed - if [ -x "/root/.local/bin/abra" ]; then - echo "✅ abra already installed" - /root/.local/bin/abra --version + # Check if abra is already properly installed (CORRECTED VERIFICATION) + if sudo abra --version >/dev/null 2>&1; then + echo "✅ abra already installed and functional" exit 0 fi - echo "🚀 Installing abra system-wide..." + # Wait for actual internet connectivity + echo "🌐 Waiting for internet connectivity..." + for i in {1..30}; do + if curl -s --max-time 5 https://abra.coopcloud.tech >/dev/null 2>&1; then + echo "✅ Internet connectivity confirmed" + break + fi + if [ $i -eq 30 ]; then + echo "❌ No internet connectivity after 60 seconds" + exit 1 + fi + sleep 2 + done - # Install to /usr/local/bin (default behavior) - curl -fsSL https://install.abra.coopcloud.tech | bash + # Attempt installation with retry logic + for attempt in {1..3}; do + echo "🚀 Installing abra (attempt $attempt/3)..." - # Add to bashrc only once - if ! grep -q "/root/.local/bin" /root/.bashrc 2>/dev/null; then - echo 'export PATH="$PATH:/root/.local/bin"' >> /root/.bashrc - echo "✅ Added /root/.local/bin to PATH in /root/.bashrc" - fi + if curl -fsSL https://install.abra.coopcloud.tech | bash; then + # Verify installation success using CORRECT check method + if sudo abra --version >/dev/null 2>&1; then + echo "✅ abra installed successfully" - # Verify - if [ -x "/root/.local/bin/abra" ]; then - echo "✅ abra installed to /root/.local/bin/abra" - fi + # Add to bashrc only once + if ! grep -q "/root/.local/bin" /root/.bashrc 2>/dev/null; then + echo 'export PATH="$PATH:/root/.local/bin"' >> /root/.bashrc + echo "✅ Added /root/.local/bin to PATH in /root/.bashrc" + fi + + exit 0 + else + echo "⚠️ Installation script completed but abra not functional" + fi + else + echo "❌ Installation attempt $attempt failed" + fi + + if [ $attempt -lt 3 ]; then + echo "⏳ Retrying in 10 seconds..." + sleep 10 + fi + done + + echo "❌ abra installation failed after 3 attempts" + exit 1 ''; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; User = "root"; + Restart = "on-failure"; + RestartSec = "30s"; Environment = [ "TERM=xterm-256color" "HOME=/root" @@ -1172,9 +1203,35 @@ isoConfig echo "❌ No GUI session. Run 'desktop' first" echo "🌐 Target was: $target_url" fi - } - - recipes() { + } + + install() { + echo "🔄 Checking and repairing abra installation..." + + # Use the CORRECT check method (matches service verification) + if sudo abra --version >/dev/null 2>&1; then + echo "✅ abra is already installed and functional" + return 0 + fi + + echo "🔄 Restarting abra installation service..." + sudo systemctl restart workshop-abra-install + + # Monitor installation progress + echo "📊 Monitoring installation..." + for i in {1..30}; do + if sudo abra --version >/dev/null 2>&1; then + echo "✅ abra installation completed successfully!" + return 0 + fi + sleep 2 + done + + echo "❌ Installation still not complete. Check status:" + echo " sudo systemctl status workshop-abra-install" + } + + recipes() { echo "📚 Complete Co-op Cloud Recipe Catalog:" echo "" echo "⭐ Tier 1 - Production Ready: gitea mealie nextcloud" diff --git a/docs/MANUAL_NETWORK_SETUP.md b/docs/MANUAL_NETWORK_SETUP.md index 3195149..2edb292 100644 --- a/docs/MANUAL_NETWORK_SETUP.md +++ b/docs/MANUAL_NETWORK_SETUP.md @@ -119,8 +119,15 @@ When internet is not available during workshop setup: 3. **Manual abra Installation** (if needed) ```bash - # Download abra binary manually on another machine and transfer via USB - # Or use a local package repository + # Use the install command (preferred) + install + + # Or manually restart the service + sudo systemctl restart workshop-abra-install + + # Check installation status + sudo systemctl status workshop-abra-install + sudo abra --version ``` 4. **Deploy Local Services** @@ -223,11 +230,14 @@ ping 8.8.8.8 # Test DNS nslookup google.com -# Test workshop services -curl http://traefik.workshop.local +# Test abra installation +sudo abra --version # Test abra connectivity sudo abra server ls + +# Test workshop services +curl http://traefik.workshop.local ``` ## Getting Help diff --git a/docs/USB_BOOT_INSTRUCTIONS.md b/docs/USB_BOOT_INSTRUCTIONS.md index 4cc1a4e..d3b1570 100644 --- a/docs/USB_BOOT_INSTRUCTIONS.md +++ b/docs/USB_BOOT_INSTRUCTIONS.md @@ -78,6 +78,9 @@ setup # See available app recipes recipes +# If abra installation failed (rare case) +install + # Get help help ``` @@ -120,3 +123,7 @@ Name: Android, Password: (ask facilitator) → WiFi should connect automatically to "CODE_CRISPIES" → If not, use mobile hotspot as backup → Check: nmcli connection show --active + +**Abra not working** +→ Run: install +→ Check: sudo systemctl status workshop-abra-install