Uname:Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64

Base Dir : /var/www/moonbloom

User : wp-moonbloom


403WebShell
403Webshell
Server IP : 85.155.190.233  /  Your IP : 216.73.216.103
Web Server : nginx/1.24.0
System : Linux antigravity-cli 6.8.0-31-generic #31-Ubuntu SMP PREEMPT_DYNAMIC Sat Apr 20 00:40:06 UTC 2024 x86_64
User : wp-moonbloom ( 1001)
PHP Version : 8.3.6
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : OFF
Directory :  /opt/Gemini_Swarm_Core/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /opt/Gemini_Swarm_Core/scripts/setup_remote_bridge.py
import os
import sys
import time

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
from _ssh import connect, run_cmd, safe_print, VPS_IP, VPS_PORT

SYSTEMD_UNIT = """\
[Unit]
Description=Telegram to Swarm Core Bridge
After=network.target

[Service]
Type=simple
User=root
Group=root
WorkingDirectory=/opt/Gemini_Swarm_Core
EnvironmentFile=/opt/Gemini_Swarm_Core/.env
Environment=HOME=/root
ExecStart=/opt/Gemini_Swarm_Core/venv/bin/python /opt/Gemini_Swarm_Core/scripts/tg_bridge.py
Restart=always
RestartSec=5

[Install]
WantedBy=multi-user.target
"""


def setup_remote() -> None:
    safe_print(f"Connecting to {VPS_IP}:{VPS_PORT}...")
    try:
        client = connect()
    except Exception as e:
        safe_print(f"Connection failed: {e}")
        return

    steps = [
        ("Installing Python deps", "apt-get update && apt-get install -y python3-pip python3-venv"),
        ("Creating swarm group", "groupadd -r swarm || true"),
        ("Creating swarm user", "useradd -r -s /bin/false -g swarm swarm || true"),
        ("Creating target directory", "mkdir -p /opt/Gemini_Swarm_Core && chown -R swarm:swarm /opt/Gemini_Swarm_Core"),
        ("Creating venv", "python3 -m venv /opt/Gemini_Swarm_Core/venv"),
        ("Upgrading pip", "/opt/Gemini_Swarm_Core/venv/bin/pip install --upgrade pip"),
        ("Installing aiogram", "/opt/Gemini_Swarm_Core/venv/bin/pip install aiogram"),
        ("Securing directory permissions", "chown -R swarm:swarm /opt/Gemini_Swarm_Core"),
    ]

    for label, cmd in steps:
        safe_print(f"{label}...")
        code, out, err = run_cmd(client, cmd)
        if code != 0:
            safe_print(f"  FAILED (exit {code}): {err.strip()[:300]}")
        else:
            safe_print(f"  OK{(': ' + out.strip()[:200]) if out.strip() else ''}")

    safe_print("Writing systemd unit file...")
    sftp = client.open_sftp()
    with sftp.file("/etc/systemd/system/tg-bridge.service", "w") as f:
        f.write(SYSTEMD_UNIT.encode("utf-8"))
    sftp.close()

    for label, cmd in [
        ("daemon-reload", "systemctl daemon-reload"),
        ("enable service", "systemctl enable tg-bridge.service"),
        ("start service", "systemctl restart tg-bridge.service"),
    ]:
        safe_print(f"{label}...")
        code, _, err = run_cmd(client, cmd)
        if code != 0:
            safe_print(f"  FAILED: {err.strip()}")
        else:
            safe_print("  OK")

    time.sleep(3)
    safe_print("Service status:")
    _, out, _ = run_cmd(client, "systemctl status tg-bridge.service --no-pager")
    safe_print(out)

    client.close()
    safe_print("Remote setup complete.")


if __name__ == "__main__":
    setup_remote()

Youez - 2016 - github.com/yon3zu
LinuXploit