clonebox 0.1.23__py3-none-any.whl → 0.1.24__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
clonebox/cloner.py CHANGED
@@ -606,12 +606,76 @@ connect_interfaces() {{
606
606
  }}
607
607
 
608
608
  test_launch() {{
609
- case "$1" in
610
- pycharm-community) /snap/pycharm-community/current/jbr/bin/java -version &>/dev/null ;;
611
- chromium) timeout 10 chromium --headless=new --dump-dom about:blank &>/dev/null ;;
612
- firefox) timeout 10 firefox --headless --screenshot /tmp/ff-test.png about:blank &>/dev/null; rm -f /tmp/ff-test.png ;;
613
- docker) docker info &>/dev/null ;;
614
- *) command -v "$1" &>/dev/null ;;
609
+ local app="$1"
610
+ local temp_output="/tmp/$app-test.log"
611
+ local error_detail="/tmp/$app-error.log"
612
+
613
+ case "$app" in
614
+ pycharm-community)
615
+ if timeout 10 /snap/pycharm-community/current/jbr/bin/java -version &>"$temp_output"; then
616
+ return 0
617
+ else
618
+ echo "PyCharm Java test failed:" >> "$error_detail"
619
+ cat "$temp_output" >> "$error_detail" 2>&1 || true
620
+ return 1
621
+ fi
622
+ ;;
623
+ chromium)
624
+ # First check if chromium can run at all
625
+ if ! command -v chromium >/dev/null 2>&1; then
626
+ echo "ERROR: chromium not found in PATH" >> "$error_detail"
627
+ echo "PATH=$PATH" >> "$error_detail"
628
+ return 1
629
+ fi
630
+
631
+ # Try with different approaches
632
+ if timeout 10 chromium --headless=new --dump-dom about:blank &>"$temp_output" 2>&1; then
633
+ return 0
634
+ else
635
+ echo "Chromium headless test failed:" >> "$error_detail"
636
+ cat "$temp_output" >> "$error_detail"
637
+
638
+ # Try basic version check
639
+ echo "Trying chromium --version:" >> "$error_detail"
640
+ timeout 5 chromium --version >> "$error_detail" 2>&1 || true
641
+
642
+ # Check display
643
+ echo "Display check:" >> "$error_detail"
644
+ echo "DISPLAY=${{DISPLAY:-unset}}" >> "$error_detail"
645
+ echo "XDG_RUNTIME_DIR=${{XDG_RUNTIME_DIR:-unset}}" >> "$error_detail"
646
+ ls -la /tmp/.X11-unix/ >> "$error_detail" 2>&1 || true
647
+
648
+ return 1
649
+ fi
650
+ ;;
651
+ firefox)
652
+ if timeout 10 firefox --headless --screenshot /tmp/ff-test.png about:blank &>/dev/null; then
653
+ rm -f /tmp/ff-test.png
654
+ return 0
655
+ else
656
+ echo "Firefox headless test failed" >> "$error_detail"
657
+ timeout 5 firefox --version >> "$error_detail" 2>&1 || true
658
+ return 1
659
+ fi
660
+ ;;
661
+ docker)
662
+ if docker info &>/dev/null; then
663
+ return 0
664
+ else
665
+ echo "Docker info failed:" >> "$error_detail"
666
+ docker info >> "$error_detail" 2>&1 || true
667
+ return 1
668
+ fi
669
+ ;;
670
+ *)
671
+ if command -v "$1" &>/dev/null; then
672
+ return 0
673
+ else
674
+ echo "Command not found: $1" >> "$error_detail"
675
+ echo "PATH=$PATH" >> "$error_detail"
676
+ return 1
677
+ fi
678
+ ;;
615
679
  esac
616
680
  }}
617
681
 
@@ -751,6 +815,11 @@ for app in "${{APPS_TO_TEST[@]}}"; do
751
815
  ok "$app launches OK"
752
816
  else
753
817
  fail "$app launch test FAILED"
818
+ # Show error details in main log
819
+ if [ -f "/tmp/$app-error.log" ]; then
820
+ echo " Error details:" | tee -a "$LOG"
821
+ head -10 "/tmp/$app-error.log" | sed 's/^/ /' | tee -a "$LOG" || true
822
+ fi
754
823
  fi
755
824
  done
756
825
 
@@ -1481,6 +1550,15 @@ esac
1481
1550
  # Enable lingering for the user (allows user services to run without login)
1482
1551
  runcmd_lines.append(f" - loginctl enable-linger {config.username}")
1483
1552
 
1553
+ # Add environment variables for monitoring
1554
+ runcmd_lines.extend([
1555
+ " - echo 'CLONEBOX_ENABLE_MONITORING=true' >> /etc/environment",
1556
+ " - echo 'CLONEBOX_MONITOR_INTERVAL=30' >> /etc/environment",
1557
+ " - echo 'CLONEBOX_AUTO_REPAIR=true' >> /etc/environment",
1558
+ " - echo 'CLONEBOX_WATCH_APPS=true' >> /etc/environment",
1559
+ " - echo 'CLONEBOX_WATCH_SERVICES=true' >> /etc/environment",
1560
+ ])
1561
+
1484
1562
  # Generate autostart configurations based on installed apps (if enabled)
1485
1563
  autostart_apps = []
1486
1564
 
@@ -1627,7 +1705,69 @@ WantedBy=multi-user.target
1627
1705
  runcmd_lines.append(f" - systemctl enable {svc_name}.service")
1628
1706
  runcmd_lines.append(f" - systemctl start {svc_name}.service || true")
1629
1707
 
1630
- # Create Python monitor service for continuous diagnostics
1708
+ # Install CloneBox Monitor for continuous monitoring and self-healing
1709
+ scripts_dir = Path(__file__).resolve().parent.parent.parent / "scripts"
1710
+ try:
1711
+ with open(scripts_dir / "clonebox-monitor.sh") as f:
1712
+ monitor_script = f.read()
1713
+ with open(scripts_dir / "clonebox-monitor.service") as f:
1714
+ monitor_service = f.read()
1715
+ with open(scripts_dir / "clonebox-monitor.default") as f:
1716
+ monitor_config = f.read()
1717
+ except (FileNotFoundError, OSError):
1718
+ # Fallback to embedded scripts if files not found
1719
+ monitor_script = '''#!/bin/bash
1720
+ # CloneBox Monitor - Fallback embedded version
1721
+ set -euo pipefail
1722
+ LOG_FILE="/var/log/clonebox-monitor.log"
1723
+ log() { echo "[$(date '+%Y-%m-%d %H:%M:%S')] $1" | tee -a "$LOG_FILE"; }
1724
+ log_info() { log "[INFO] $1"; }
1725
+ log_warn() { log "[WARN] $1"; }
1726
+ log_error() { log "[ERROR] $1"; }
1727
+ log_success() { log "[SUCCESS] $1"; }
1728
+ while true; do
1729
+ log_info "CloneBox Monitor running..."
1730
+ sleep 60
1731
+ done
1732
+ '''
1733
+ monitor_service = '''[Unit]
1734
+ Description=CloneBox Monitor
1735
+ After=graphical-session.target
1736
+ [Service]
1737
+ Type=simple
1738
+ User=ubuntu
1739
+ ExecStart=/usr/local/bin/clonebox-monitor
1740
+ Restart=always
1741
+ [Install]
1742
+ WantedBy=default.target
1743
+ '''
1744
+ monitor_config = '''# CloneBox Monitor Configuration
1745
+ CLONEBOX_MONITOR_INTERVAL=30
1746
+ CLONEBOX_AUTO_REPAIR=true
1747
+ '''
1748
+
1749
+ # Install monitor script
1750
+ monitor_b64 = base64.b64encode(monitor_script.encode()).decode()
1751
+ runcmd_lines.append(f" - echo '{monitor_b64}' | base64 -d > /usr/local/bin/clonebox-monitor")
1752
+ runcmd_lines.append(" - chmod +x /usr/local/bin/clonebox-monitor")
1753
+
1754
+ # Install monitor configuration
1755
+ config_b64 = base64.b64encode(monitor_config.encode()).decode()
1756
+ runcmd_lines.append(f" - echo '{config_b64}' | base64 -d > /etc/default/clonebox-monitor")
1757
+
1758
+ # Install systemd user service
1759
+ service_b64 = base64.b64encode(monitor_service.encode()).decode()
1760
+ runcmd_lines.append(f" - echo '{service_b64}' | base64 -d > /etc/systemd/user/clonebox-monitor.service")
1761
+
1762
+ # Enable lingering and start monitor
1763
+ runcmd_lines.extend([
1764
+ " - loginctl enable-linger ubuntu",
1765
+ " - sudo -u ubuntu systemctl --user daemon-reload",
1766
+ " - sudo -u ubuntu systemctl --user enable clonebox-monitor.service",
1767
+ " - sudo -u ubuntu systemctl --user start clonebox-monitor.service || true",
1768
+ ])
1769
+
1770
+ # Create Python monitor service for continuous diagnostics (legacy)
1631
1771
  monitor_script = f'''#!/usr/bin/env python3
1632
1772
  """CloneBox Monitor - Continuous diagnostics and app restart service."""
1633
1773
  import subprocess
@@ -1729,28 +1869,22 @@ def main():
1729
1869
  if __name__ == "__main__":
1730
1870
  main()
1731
1871
  '''
1732
- monitor_b64 = base64.b64encode(monitor_script.encode()).decode()
1733
- runcmd_lines.append(f" - echo '{monitor_b64}' | base64 -d > /usr/local/bin/clonebox-monitor")
1734
- runcmd_lines.append(" - chmod +x /usr/local/bin/clonebox-monitor")
1872
+ # Note: The bash monitor is already installed above, no need to install Python monitor
1735
1873
 
1736
- # Create systemd service for the Python monitor
1737
- monitor_service = '''[Unit]
1738
- Description=CloneBox Monitor Service
1739
- After=network.target graphical.target
1740
-
1741
- [Service]
1742
- Type=simple
1743
- ExecStart=/usr/bin/python3 /usr/local/bin/clonebox-monitor
1744
- Restart=always
1745
- RestartSec=30
1746
-
1747
- [Install]
1748
- WantedBy=multi-user.target'''
1749
- monitor_svc_b64 = base64.b64encode(monitor_service.encode()).decode()
1750
- runcmd_lines.append(f" - echo '{monitor_svc_b64}' | base64 -d > /etc/systemd/system/clonebox-monitor.service")
1751
- runcmd_lines.append(" - systemctl daemon-reload")
1752
- runcmd_lines.append(" - systemctl enable clonebox-monitor.service")
1753
- runcmd_lines.append(" - systemctl start clonebox-monitor.service || true")
1874
+ # Create logs disk for host access
1875
+ runcmd_lines.extend([
1876
+ " - mkdir -p /mnt/logs",
1877
+ " - truncate -s 1G /var/lib/libvirt/images/clonebox-logs.qcow2",
1878
+ " - mkfs.ext4 -F /var/lib/libvirt/images/clonebox-logs.qcow2",
1879
+ " - echo '/var/lib/libvirt/images/clonebox-logs.qcow2 /mnt/logs ext4 loop,defaults 0 0' >> /etc/fstab",
1880
+ " - mount -a",
1881
+ " - mkdir -p /mnt/logs/var/log",
1882
+ " - mkdir -p /mnt/logs/tmp",
1883
+ " - cp -r /var/log/clonebox*.log /mnt/logs/var/log/ 2>/dev/null || true",
1884
+ " - cp -r /tmp/*-error.log /mnt/logs/tmp/ 2>/dev/null || true",
1885
+ " - echo 'Logs disk mounted at /mnt/logs - accessible from host as /var/lib/libvirt/images/clonebox-logs.qcow2'",
1886
+ " - echo 'To view logs on host: sudo mount -o loop /var/lib/libvirt/images/clonebox-logs.qcow2 /mnt/clonebox-logs'",
1887
+ ])
1754
1888
 
1755
1889
  # Add reboot command at the end if GUI is enabled
1756
1890
  if config.gui:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clonebox
3
- Version: 0.1.23
3
+ Version: 0.1.24
4
4
  Summary: Clone your workstation environment to an isolated VM with selective apps, paths and services
5
5
  Author: CloneBox Team
6
6
  License: Apache-2.0
@@ -82,6 +82,9 @@ CloneBox lets you create isolated virtual machines with only the applications, d
82
82
  - ⚡ **Fast creation** - No full disk cloning, VMs are ready in seconds
83
83
  - 📥 **Auto-download** - Automatically downloads and caches Ubuntu cloud images (stored in ~/Downloads)
84
84
  - 📊 **Health monitoring** - Built-in health checks for packages, services, and mounts
85
+ - 🔄 **Self-healing** - Automatic monitoring and repair of apps and services
86
+ - 📈 **Live monitoring** - Real-time dashboard for running applications and services
87
+ - 🔧 **Repair tools** - One-click fix for common VM issues (audio, permissions, mounts)
85
88
  - 🔄 **VM migration** - Export/import VMs with data between workstations
86
89
  - 🧪 **Configuration testing** - Validate VM settings and functionality
87
90
  - 📁 **App data sync** - Include browser profiles, IDE settings, and app configs
@@ -97,10 +100,12 @@ CloneBox excels in scenarios where developers need:
97
100
  ## What's Next
98
101
 
99
102
  Project roadmap includes:
100
- - Container runtime integration (Podman/Docker lightweight mode)
101
- - Local dashboard for VM and container management
102
- - Profile system for reusable configuration presets
103
- - Proxmox export capabilities for production migration
103
+ - **v0.2.0**: `clonebox exec` command, VM snapshots, web dashboard MVP
104
+ - **v0.3.0**: Container runtime integration (Podman/Docker), multi-VM orchestration
105
+ - **v0.4.0**: Cloud provider support (AWS, GCP, Azure), Windows WSL2 support
106
+ - **v1.0.0**: Production-ready with full monitoring, backup/restore, enterprise features
107
+
108
+ See [TODO.md](TODO.md) for detailed roadmap and [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
104
109
 
105
110
 
106
111
 
@@ -112,6 +117,8 @@ Kluczowe komendy:
112
117
  - `clonebox` – interaktywny wizard (detect + create + start)
113
118
  - `clonebox detect` – skanuje usługi/apps/ścieżki
114
119
  - `clonebox clone . --user --run` – szybki klon bieżącego katalogu z użytkownikiem i autostartem
120
+ - `clonebox watch . --user` – monitoruj na żywo aplikacje i usługi w VM
121
+ - `clonebox repair . --user` – napraw problemy z uprawnieniami, audio, usługami
115
122
  - `clonebox container up|ps|stop|rm` – lekki runtime kontenerowy (podman/docker)
116
123
  - `clonebox dashboard` – lokalny dashboard (VM + containers)
117
124
 
@@ -497,6 +504,111 @@ clonebox status . --user --health
497
504
  # Or rebuild: clonebox clone . --user --run --replace
498
505
  ```
499
506
 
507
+ ## 📊 Monitoring and Self-Healing
508
+
509
+ CloneBox includes continuous monitoring and automatic self-healing capabilities for both GUI applications and system services.
510
+
511
+ ### Monitor Running Applications and Services
512
+
513
+ ```bash
514
+ # Watch real-time status of apps and services
515
+ clonebox watch . --user
516
+
517
+ # Output shows live dashboard:
518
+ # ╔══════════════════════════════════════════════════════════╗
519
+ # ║ CloneBox Live Monitor ║
520
+ # ╠══════════════════════════════════════════════════════════╣
521
+ # ║ 🖥️ GUI Apps: ║
522
+ # ║ ✅ pycharm-community PID: 1234 Memory: 512MB ║
523
+ # ║ ✅ firefox PID: 5678 Memory: 256MB ║
524
+ # ║ ❌ chromium Not running ║
525
+ # ║ ║
526
+ # ║ 🔧 System Services: ║
527
+ # ║ ✅ docker Active: 2h 15m ║
528
+ # ║ ✅ nginx Active: 1h 30m ║
529
+ # ║ ✅ uvicorn Active: 45m (port 8000) ║
530
+ # ║ ║
531
+ # ║ 📊 Last check: 2024-01-31 13:25:30 ║
532
+ # ║ 🔄 Next check in: 25 seconds ║
533
+ # ╚══════════════════════════════════════════════════════════╝
534
+
535
+ # Check detailed status with logs
536
+ clonebox status . --user --verbose
537
+
538
+ # View monitor logs from host
539
+ ./scripts/clonebox-logs.sh # Interactive log viewer
540
+ # Or via SSH:
541
+ ssh ubuntu@<IP_VM> "tail -f /var/log/clonebox-monitor.log"
542
+ ```
543
+
544
+ ### Repair and Troubleshooting
545
+
546
+ ```bash
547
+ # Run automatic repair from host
548
+ clonebox repair . --user
549
+
550
+ # This triggers the repair script inside VM which:
551
+ # - Fixes directory permissions (pulse, ibus, dconf)
552
+ # - Restarts audio services (PulseAudio/PipeWire)
553
+ # - Reconnects snap interfaces
554
+ # - Remounts missing filesystems
555
+ # - Resets GNOME keyring if needed
556
+
557
+ # Interactive repair menu (via SSH)
558
+ ssh ubuntu@<IP_VM> "clonebox-repair"
559
+
560
+ # Manual repair options from host:
561
+ clonebox repair . --user --auto # Full automatic repair
562
+ clonebox repair . --user --perms # Fix permissions only
563
+ clonebox repair . --user --audio # Fix audio only
564
+ clonebox repair . --user --snaps # Reconnect snaps only
565
+ clonebox repair . --user --mounts # Remount filesystems only
566
+
567
+ # Check repair status (via SSH)
568
+ ssh ubuntu@<IP_VM> "cat /var/run/clonebox-status"
569
+
570
+ # View repair logs
571
+ ./scripts/clonebox-logs.sh # Interactive viewer
572
+ # Or via SSH:
573
+ ssh ubuntu@<IP_VM> "tail -n 50 /var/log/clonebox-boot.log"
574
+ ```
575
+
576
+ ### Monitor Configuration
577
+
578
+ The monitoring system is configured through environment variables in `.env`:
579
+
580
+ ```bash
581
+ # Enable/disable monitoring
582
+ CLONEBOX_ENABLE_MONITORING=true
583
+ CLONEBOX_MONITOR_INTERVAL=30 # Check every 30 seconds
584
+ CLONEBOX_AUTO_REPAIR=true # Auto-restart failed services
585
+ CLONEBOX_WATCH_APPS=true # Monitor GUI apps
586
+ CLONEBOX_WATCH_SERVICES=true # Monitor system services
587
+ ```
588
+
589
+ ### Inside the VM - Manual Controls
590
+
591
+ ```bash
592
+ # Check monitor service status
593
+ systemctl --user status clonebox-monitor
594
+
595
+ # View monitor logs
596
+ journalctl --user -u clonebox-monitor -f
597
+ tail -f /var/log/clonebox-monitor.log
598
+
599
+ # Stop/start monitoring
600
+ systemctl --user stop clonebox-monitor
601
+ systemctl --user start clonebox-monitor
602
+
603
+ # Check last status
604
+ cat /var/run/clonebox-monitor-status
605
+
606
+ # Run repair manually
607
+ clonebox-repair --all # Run all fixes
608
+ clonebox-repair --status # Show current status
609
+ clonebox-repair --logs # Show recent logs
610
+ ```
611
+
500
612
  ### Export/Import Workflow
501
613
 
502
614
  ```bash
@@ -537,6 +649,11 @@ virt-viewer --connect qemu:///session clone-clonebox
537
649
  # Check VM details:
538
650
  clonebox list # List all VMs
539
651
  virsh --connect qemu:///session dominfo clone-clonebox
652
+
653
+ # Restart VM if needed:
654
+ clonebox stop . --user && clonebox start . --user # Soft reboot
655
+ virsh --connect qemu:///session reboot clone-clonebox # Direct reboot
656
+ virsh --connect qemu:///session reset clone-clonebox # Hard reset if frozen
540
657
  ```
541
658
 
542
659
  ## Legacy Examples (Manual Config)
@@ -1,7 +1,7 @@
1
1
  clonebox/__init__.py,sha256=CyfHVVq6KqBr4CNERBpXk_O6Q5B35q03YpdQbokVvvI,408
2
2
  clonebox/__main__.py,sha256=Fcoyzwwyz5-eC_sBlQk5a5RbKx8uodQz5sKJ190U0NU,135
3
3
  clonebox/cli.py,sha256=vbJ65ShdXG1nGkQteCaFtDTas0L2RNV--aay2Qx-6F0,110765
4
- clonebox/cloner.py,sha256=a9IaIxTb-CaomRGOGkX-0wppYPFmmMRYv3lFxpBit84,73528
4
+ clonebox/cloner.py,sha256=qIcSgG-W28-qBhEVSL8d2gFx2-BI7ygh1Jyh9BjAIBI,79100
5
5
  clonebox/container.py,sha256=tiYK1ZB-DhdD6A2FuMA0h_sRNkUI7KfYcJ0tFOcdyeM,6105
6
6
  clonebox/dashboard.py,sha256=RhSPvR6kWglqXeLkCWesBZQid7wv2WpJa6w78mXbPjY,4268
7
7
  clonebox/detector.py,sha256=aS_QlbG93-DE3hsjRt88E7O-PGC2TUBgUbP9wqT9g60,23221
@@ -9,9 +9,9 @@ clonebox/models.py,sha256=yBRUlJejpeJHZjvCYMGq1nXPFcmhLFxN-LqkEyveWsA,7913
9
9
  clonebox/profiles.py,sha256=VaKVuxCrgyMxx-8_WOTcw7E8irwGxUPhZHVY6RxYYiE,2034
10
10
  clonebox/validator.py,sha256=z4YuIgVnX6ZqfIdJtjKIFwZ-iWlRUnpX7gmWwq-Jr88,35352
11
11
  clonebox/templates/profiles/ml-dev.yaml,sha256=MT7Wu3xGBnYIsO5mzZ2GDI4AAEFGOroIx0eU3XjNARg,140
12
- clonebox-0.1.23.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
- clonebox-0.1.23.dist-info/METADATA,sha256=Yr9EuaWmioFVeAQty15ueglVX6Ae85265PgonQ5DSHs,41627
14
- clonebox-0.1.23.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
- clonebox-0.1.23.dist-info/entry_points.txt,sha256=FES95Vi3btfViLEEoHdb8nikNxTqzaooi9ehZw9ZfWI,47
16
- clonebox-0.1.23.dist-info/top_level.txt,sha256=LdMo2cvCrEcRGH2M8JgQNVsCoszLV0xug6kx1JnaRjo,9
17
- clonebox-0.1.23.dist-info/RECORD,,
12
+ clonebox-0.1.24.dist-info/licenses/LICENSE,sha256=xx0jnfkXJvxRnG63LTGOxlggYnIysveWIZ6H3PNdCrQ,11357
13
+ clonebox-0.1.24.dist-info/METADATA,sha256=ua1S-CkW_inx_jQYxZLCEGvvRW6o3qY6HIZqJsark_U,46452
14
+ clonebox-0.1.24.dist-info/WHEEL,sha256=wUyA8OaulRlbfwMtmQsvNngGrxQHAvkKcvRmdizlJi0,92
15
+ clonebox-0.1.24.dist-info/entry_points.txt,sha256=FES95Vi3btfViLEEoHdb8nikNxTqzaooi9ehZw9ZfWI,47
16
+ clonebox-0.1.24.dist-info/top_level.txt,sha256=LdMo2cvCrEcRGH2M8JgQNVsCoszLV0xug6kx1JnaRjo,9
17
+ clonebox-0.1.24.dist-info/RECORD,,