- Add .aurelio/config.toml, mcp_config.json, sync.py, README.md - Seed .aurelio/realm/AGENTS.md and memory/index.md
64 lines
2.3 KiB
Python
Executable file
64 lines
2.3 KiB
Python
Executable file
#!/usr/bin/env python3
|
|
import os
|
|
import argparse
|
|
import subprocess
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
# Config
|
|
VM_IP = "192.168.0.38"
|
|
CONTAINER_ID = 208
|
|
TARGET_DIR = "/opt/pf-services-208/gabinete/.aurelio/brain"
|
|
LOCAL_BRAIN = Path(__file__).parent / "brain"
|
|
|
|
def run_cmd(cmd: str):
|
|
print(f"Running: {cmd}")
|
|
result = subprocess.run(cmd, shell=True)
|
|
if result.returncode != 0:
|
|
print(f"Error executing: {cmd}")
|
|
sys.exit(result.returncode)
|
|
|
|
def push():
|
|
print("Pushing local brain to CT 208 Gabinete...")
|
|
# Tar local brain
|
|
if not LOCAL_BRAIN.exists():
|
|
print("Local brain does not exist. Nothing to push.")
|
|
return
|
|
|
|
run_cmd(f"tar czf /tmp/local_brain.tar.gz -C {LOCAL_BRAIN.parent} brain")
|
|
run_cmd(f"scp /tmp/local_brain.tar.gz root@{VM_IP}:/tmp/")
|
|
|
|
# Copy archive into container and extract inside the container
|
|
run_cmd(f"ssh root@{VM_IP} 'pct push {CONTAINER_ID} /tmp/local_brain.tar.gz /tmp/local_brain.tar.gz'")
|
|
run_cmd(f"ssh root@{VM_IP} 'pct exec {CONTAINER_ID} -- bash -c \"mkdir -p {TARGET_DIR} && tar xzf /tmp/local_brain.tar.gz -C /opt/pf-services-208/gabinete/.aurelio/\"'")
|
|
print("Push complete.")
|
|
|
|
def pull():
|
|
print("Pulling central brain from CT 208 Gabinete to local workspace...")
|
|
# Tar remote brain
|
|
run_cmd(f"ssh root@{VM_IP} 'pct exec {CONTAINER_ID} -- bash -c \"mkdir -p {TARGET_DIR} && tar czf /tmp/remote_brain.tar.gz -C /opt/pf-services-208/gabinete/.aurelio/ brain\"'")
|
|
run_cmd(f"ssh root@{VM_IP} 'pct pull {CONTAINER_ID} /tmp/remote_brain.tar.gz /tmp/remote_brain.tar.gz'")
|
|
run_cmd(f"scp root@{VM_IP}:/tmp/remote_brain.tar.gz /tmp/")
|
|
|
|
# Extract locally
|
|
if not LOCAL_BRAIN.exists():
|
|
LOCAL_BRAIN.mkdir(parents=True)
|
|
run_cmd(f"tar xzf /tmp/remote_brain.tar.gz -C {LOCAL_BRAIN.parent}")
|
|
print("Pull complete.")
|
|
|
|
def main():
|
|
parser = argparse.ArgumentParser(description="Aurelio Sync Utility")
|
|
parser.add_argument("--push", action="store_true", help="Push local brain to central server")
|
|
parser.add_argument("--pull", action="store_true", help="Pull central brain to local workspace")
|
|
|
|
args = parser.parse_args()
|
|
|
|
if args.push:
|
|
push()
|
|
elif args.pull:
|
|
pull()
|
|
else:
|
|
parser.print_help()
|
|
|
|
if __name__ == "__main__":
|
|
main()
|