76 lines
2.2 KiB
Python
Executable File
76 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Prepare local mods, rsync to server, generate config, and commit."""
|
|
|
|
import os
|
|
import subprocess
|
|
import sys
|
|
|
|
BASE = os.path.dirname(os.path.abspath(__file__))
|
|
PREPARE_LOCAL = os.path.join(BASE, "prepare_local")
|
|
AUTOGEN = os.path.join(BASE, "scripts", "autogen_config.py")
|
|
LOCALMODS_DIR = os.path.join(BASE, "LocalMods")
|
|
|
|
RSYNC_DEST = "root@barotrauma:/opt/barotrauma/LocalMods/"
|
|
CONFIG_PATH = os.path.join(BASE, "config_player.xml")
|
|
RSYNC_SSH = "ssh -p 22"
|
|
|
|
|
|
def log_ok(msg):
|
|
print(f"\033[92m✓\033[0m {msg}")
|
|
|
|
def log_info(msg):
|
|
print(f"• {msg}")
|
|
|
|
def log_err(msg):
|
|
print(f"\033[91m✗\033[0m {msg}", file=sys.stderr)
|
|
|
|
|
|
def main():
|
|
msg = " ".join(sys.argv[1:]) if len(sys.argv) > 1 else "Update LocalMods"
|
|
|
|
print()
|
|
print("╔══════════════════════════════════════════╗")
|
|
print("║ Prep: mods → config → rsync → commit ║")
|
|
print("╚══════════════════════════════════════════╝")
|
|
print()
|
|
|
|
log_info("Step 1/5: Copy mods from workshop...")
|
|
subprocess.run([sys.executable, PREPARE_LOCAL], check=True)
|
|
log_ok("LocalMods ready")
|
|
print()
|
|
|
|
log_info("Step 2/5: Generating config_player.xml...")
|
|
subprocess.run([sys.executable, AUTOGEN], check=True)
|
|
log_ok("config_player.xml generated")
|
|
print()
|
|
|
|
log_info("Step 3/5: Rsyncing LocalMods/ to server...")
|
|
subprocess.run([
|
|
"rsync", "-avz", "--delete",
|
|
"-e", RSYNC_SSH,
|
|
LOCALMODS_DIR + "/", RSYNC_DEST
|
|
], check=True)
|
|
log_ok("LocalMods synced")
|
|
print()
|
|
|
|
log_info("Step 4/5: Rsyncing config_player.xml to server...")
|
|
subprocess.run([
|
|
"rsync", "-avz",
|
|
"-e", RSYNC_SSH,
|
|
CONFIG_PATH, "root@barotrauma:/opt/barotrauma/config_player.xml"
|
|
], check=True)
|
|
log_ok("config_player.xml synced")
|
|
print()
|
|
|
|
log_info("Step 5/5: Committing...")
|
|
subprocess.run(["git", "add", "-A"], cwd=BASE, check=True)
|
|
subprocess.run(["git", "commit", "-m", msg], cwd=BASE, check=True)
|
|
log_ok(f"Committed: {msg}")
|
|
print()
|
|
|
|
log_ok("Done. Push manually when ready.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|