clonebox 0.1.23__tar.gz → 0.1.25__tar.gz

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.
Files changed (30) hide show
  1. {clonebox-0.1.23/src/clonebox.egg-info → clonebox-0.1.25}/PKG-INFO +124 -5
  2. {clonebox-0.1.23 → clonebox-0.1.25}/README.md +123 -4
  3. {clonebox-0.1.23 → clonebox-0.1.25}/pyproject.toml +1 -1
  4. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/cli.py +55 -0
  5. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/cloner.py +162 -28
  6. {clonebox-0.1.23 → clonebox-0.1.25/src/clonebox.egg-info}/PKG-INFO +124 -5
  7. {clonebox-0.1.23 → clonebox-0.1.25}/LICENSE +0 -0
  8. {clonebox-0.1.23 → clonebox-0.1.25}/setup.cfg +0 -0
  9. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/__init__.py +0 -0
  10. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/__main__.py +0 -0
  11. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/container.py +0 -0
  12. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/dashboard.py +0 -0
  13. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/detector.py +0 -0
  14. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/models.py +0 -0
  15. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/profiles.py +0 -0
  16. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/templates/profiles/ml-dev.yaml +0 -0
  17. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox/validator.py +0 -0
  18. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox.egg-info/SOURCES.txt +0 -0
  19. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox.egg-info/dependency_links.txt +0 -0
  20. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox.egg-info/entry_points.txt +0 -0
  21. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox.egg-info/requires.txt +0 -0
  22. {clonebox-0.1.23 → clonebox-0.1.25}/src/clonebox.egg-info/top_level.txt +0 -0
  23. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_cli.py +0 -0
  24. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_cloner.py +0 -0
  25. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_container.py +0 -0
  26. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_detector.py +0 -0
  27. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_models.py +0 -0
  28. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_network.py +0 -0
  29. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_profiles.py +0 -0
  30. {clonebox-0.1.23 → clonebox-0.1.25}/tests/test_validator.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: clonebox
3
- Version: 0.1.23
3
+ Version: 0.1.25
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,13 @@ 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 restart . --user # Easiest - stop and start
655
+ clonebox stop . --user && clonebox start . --user # Manual restart
656
+ clonebox restart . --user --open # Restart and open GUI
657
+ virsh --connect qemu:///session reboot clone-clonebox # Direct reboot
658
+ virsh --connect qemu:///session reset clone-clonebox # Hard reset if frozen
540
659
  ```
541
660
 
542
661
  ## Legacy Examples (Manual Config)
@@ -33,6 +33,9 @@ CloneBox lets you create isolated virtual machines with only the applications, d
33
33
  - ⚡ **Fast creation** - No full disk cloning, VMs are ready in seconds
34
34
  - 📥 **Auto-download** - Automatically downloads and caches Ubuntu cloud images (stored in ~/Downloads)
35
35
  - 📊 **Health monitoring** - Built-in health checks for packages, services, and mounts
36
+ - 🔄 **Self-healing** - Automatic monitoring and repair of apps and services
37
+ - 📈 **Live monitoring** - Real-time dashboard for running applications and services
38
+ - 🔧 **Repair tools** - One-click fix for common VM issues (audio, permissions, mounts)
36
39
  - 🔄 **VM migration** - Export/import VMs with data between workstations
37
40
  - 🧪 **Configuration testing** - Validate VM settings and functionality
38
41
  - 📁 **App data sync** - Include browser profiles, IDE settings, and app configs
@@ -48,10 +51,12 @@ CloneBox excels in scenarios where developers need:
48
51
  ## What's Next
49
52
 
50
53
  Project roadmap includes:
51
- - Container runtime integration (Podman/Docker lightweight mode)
52
- - Local dashboard for VM and container management
53
- - Profile system for reusable configuration presets
54
- - Proxmox export capabilities for production migration
54
+ - **v0.2.0**: `clonebox exec` command, VM snapshots, web dashboard MVP
55
+ - **v0.3.0**: Container runtime integration (Podman/Docker), multi-VM orchestration
56
+ - **v0.4.0**: Cloud provider support (AWS, GCP, Azure), Windows WSL2 support
57
+ - **v1.0.0**: Production-ready with full monitoring, backup/restore, enterprise features
58
+
59
+ See [TODO.md](TODO.md) for detailed roadmap and [CONTRIBUTING.md](CONTRIBUTING.md) for contribution guidelines.
55
60
 
56
61
 
57
62
 
@@ -63,6 +68,8 @@ Kluczowe komendy:
63
68
  - `clonebox` – interaktywny wizard (detect + create + start)
64
69
  - `clonebox detect` – skanuje usługi/apps/ścieżki
65
70
  - `clonebox clone . --user --run` – szybki klon bieżącego katalogu z użytkownikiem i autostartem
71
+ - `clonebox watch . --user` – monitoruj na żywo aplikacje i usługi w VM
72
+ - `clonebox repair . --user` – napraw problemy z uprawnieniami, audio, usługami
66
73
  - `clonebox container up|ps|stop|rm` – lekki runtime kontenerowy (podman/docker)
67
74
  - `clonebox dashboard` – lokalny dashboard (VM + containers)
68
75
 
@@ -448,6 +455,111 @@ clonebox status . --user --health
448
455
  # Or rebuild: clonebox clone . --user --run --replace
449
456
  ```
450
457
 
458
+ ## 📊 Monitoring and Self-Healing
459
+
460
+ CloneBox includes continuous monitoring and automatic self-healing capabilities for both GUI applications and system services.
461
+
462
+ ### Monitor Running Applications and Services
463
+
464
+ ```bash
465
+ # Watch real-time status of apps and services
466
+ clonebox watch . --user
467
+
468
+ # Output shows live dashboard:
469
+ # ╔══════════════════════════════════════════════════════════╗
470
+ # ║ CloneBox Live Monitor ║
471
+ # ╠══════════════════════════════════════════════════════════╣
472
+ # ║ 🖥️ GUI Apps: ║
473
+ # ║ ✅ pycharm-community PID: 1234 Memory: 512MB ║
474
+ # ║ ✅ firefox PID: 5678 Memory: 256MB ║
475
+ # ║ ❌ chromium Not running ║
476
+ # ║ ║
477
+ # ║ 🔧 System Services: ║
478
+ # ║ ✅ docker Active: 2h 15m ║
479
+ # ║ ✅ nginx Active: 1h 30m ║
480
+ # ║ ✅ uvicorn Active: 45m (port 8000) ║
481
+ # ║ ║
482
+ # ║ 📊 Last check: 2024-01-31 13:25:30 ║
483
+ # ║ 🔄 Next check in: 25 seconds ║
484
+ # ╚══════════════════════════════════════════════════════════╝
485
+
486
+ # Check detailed status with logs
487
+ clonebox status . --user --verbose
488
+
489
+ # View monitor logs from host
490
+ ./scripts/clonebox-logs.sh # Interactive log viewer
491
+ # Or via SSH:
492
+ ssh ubuntu@<IP_VM> "tail -f /var/log/clonebox-monitor.log"
493
+ ```
494
+
495
+ ### Repair and Troubleshooting
496
+
497
+ ```bash
498
+ # Run automatic repair from host
499
+ clonebox repair . --user
500
+
501
+ # This triggers the repair script inside VM which:
502
+ # - Fixes directory permissions (pulse, ibus, dconf)
503
+ # - Restarts audio services (PulseAudio/PipeWire)
504
+ # - Reconnects snap interfaces
505
+ # - Remounts missing filesystems
506
+ # - Resets GNOME keyring if needed
507
+
508
+ # Interactive repair menu (via SSH)
509
+ ssh ubuntu@<IP_VM> "clonebox-repair"
510
+
511
+ # Manual repair options from host:
512
+ clonebox repair . --user --auto # Full automatic repair
513
+ clonebox repair . --user --perms # Fix permissions only
514
+ clonebox repair . --user --audio # Fix audio only
515
+ clonebox repair . --user --snaps # Reconnect snaps only
516
+ clonebox repair . --user --mounts # Remount filesystems only
517
+
518
+ # Check repair status (via SSH)
519
+ ssh ubuntu@<IP_VM> "cat /var/run/clonebox-status"
520
+
521
+ # View repair logs
522
+ ./scripts/clonebox-logs.sh # Interactive viewer
523
+ # Or via SSH:
524
+ ssh ubuntu@<IP_VM> "tail -n 50 /var/log/clonebox-boot.log"
525
+ ```
526
+
527
+ ### Monitor Configuration
528
+
529
+ The monitoring system is configured through environment variables in `.env`:
530
+
531
+ ```bash
532
+ # Enable/disable monitoring
533
+ CLONEBOX_ENABLE_MONITORING=true
534
+ CLONEBOX_MONITOR_INTERVAL=30 # Check every 30 seconds
535
+ CLONEBOX_AUTO_REPAIR=true # Auto-restart failed services
536
+ CLONEBOX_WATCH_APPS=true # Monitor GUI apps
537
+ CLONEBOX_WATCH_SERVICES=true # Monitor system services
538
+ ```
539
+
540
+ ### Inside the VM - Manual Controls
541
+
542
+ ```bash
543
+ # Check monitor service status
544
+ systemctl --user status clonebox-monitor
545
+
546
+ # View monitor logs
547
+ journalctl --user -u clonebox-monitor -f
548
+ tail -f /var/log/clonebox-monitor.log
549
+
550
+ # Stop/start monitoring
551
+ systemctl --user stop clonebox-monitor
552
+ systemctl --user start clonebox-monitor
553
+
554
+ # Check last status
555
+ cat /var/run/clonebox-monitor-status
556
+
557
+ # Run repair manually
558
+ clonebox-repair --all # Run all fixes
559
+ clonebox-repair --status # Show current status
560
+ clonebox-repair --logs # Show recent logs
561
+ ```
562
+
451
563
  ### Export/Import Workflow
452
564
 
453
565
  ```bash
@@ -488,6 +600,13 @@ virt-viewer --connect qemu:///session clone-clonebox
488
600
  # Check VM details:
489
601
  clonebox list # List all VMs
490
602
  virsh --connect qemu:///session dominfo clone-clonebox
603
+
604
+ # Restart VM if needed:
605
+ clonebox restart . --user # Easiest - stop and start
606
+ clonebox stop . --user && clonebox start . --user # Manual restart
607
+ clonebox restart . --user --open # Restart and open GUI
608
+ virsh --connect qemu:///session reboot clone-clonebox # Direct reboot
609
+ virsh --connect qemu:///session reset clone-clonebox # Hard reset if frozen
491
610
  ```
492
611
 
493
612
  ## Legacy Examples (Manual Config)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "clonebox"
7
- version = "0.1.23"
7
+ version = "0.1.25"
8
8
  description = "Clone your workstation environment to an isolated VM with selective apps, paths and services"
9
9
  readme = "README.md"
10
10
  license = {text = "Apache-2.0"}
@@ -1007,6 +1007,39 @@ def cmd_stop(args):
1007
1007
  cloner.stop_vm(name, force=args.force, console=console)
1008
1008
 
1009
1009
 
1010
+ def cmd_restart(args):
1011
+ """Restart a VM (stop and start)."""
1012
+ name = args.name
1013
+
1014
+ # If name is a path, load config
1015
+ if name and (name.startswith(".") or name.startswith("/") or name.startswith("~")):
1016
+ target_path = Path(name).expanduser().resolve()
1017
+ config_file = target_path / ".clonebox.yaml" if target_path.is_dir() else target_path
1018
+ if config_file.exists():
1019
+ config = load_clonebox_config(config_file)
1020
+ name = config["vm"]["name"]
1021
+ else:
1022
+ console.print(f"[red]❌ Config not found: {config_file}[/]")
1023
+ return
1024
+
1025
+ cloner = SelectiveVMCloner(user_session=getattr(args, "user", False))
1026
+
1027
+ # Stop the VM
1028
+ console.print("[bold yellow]🔄 Stopping VM...[/]")
1029
+ cloner.stop_vm(name, force=args.force, console=console)
1030
+
1031
+ # Wait a moment
1032
+ time.sleep(2)
1033
+
1034
+ # Start the VM
1035
+ console.print("[bold green]🚀 Starting VM...[/]")
1036
+ cloner.start_vm(name, wait_for_agent=True, console=console)
1037
+
1038
+ console.print("[bold green]✅ VM restarted successfully![/]")
1039
+ if getattr(args, "open", False):
1040
+ cloner.open_gui(name, console=console)
1041
+
1042
+
1010
1043
  def cmd_delete(args):
1011
1044
  """Delete a VM."""
1012
1045
  name = args.name
@@ -2521,6 +2554,28 @@ def main():
2521
2554
  )
2522
2555
  stop_parser.set_defaults(func=cmd_stop)
2523
2556
 
2557
+ # Restart command
2558
+ restart_parser = subparsers.add_parser("restart", help="Restart a VM (stop and start)")
2559
+ restart_parser.add_argument("name", nargs="?", default=None, help="VM name or '.' to use .clonebox.yaml")
2560
+ restart_parser.add_argument(
2561
+ "-f",
2562
+ "--force",
2563
+ action="store_true",
2564
+ help="Force stop if VM is stuck",
2565
+ )
2566
+ restart_parser.add_argument(
2567
+ "-u",
2568
+ "--user",
2569
+ action="store_true",
2570
+ help="Use user session (qemu:///session) - no root required",
2571
+ )
2572
+ restart_parser.add_argument(
2573
+ "--open",
2574
+ action="store_true",
2575
+ help="Open GUI after restart",
2576
+ )
2577
+ restart_parser.set_defaults(func=cmd_restart)
2578
+
2524
2579
  # Delete command
2525
2580
  delete_parser = subparsers.add_parser("delete", help="Delete a VM")
2526
2581
  delete_parser.add_argument("name", nargs="?", default=None, help="VM name or '.' to use .clonebox.yaml")
@@ -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.25
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,13 @@ 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 restart . --user # Easiest - stop and start
655
+ clonebox stop . --user && clonebox start . --user # Manual restart
656
+ clonebox restart . --user --open # Restart and open GUI
657
+ virsh --connect qemu:///session reboot clone-clonebox # Direct reboot
658
+ virsh --connect qemu:///session reset clone-clonebox # Hard reset if frozen
540
659
  ```
541
660
 
542
661
  ## Legacy Examples (Manual Config)
File without changes
File without changes
File without changes