59 lines
1.7 KiB
Python
Executable File
59 lines
1.7 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/"
|
|
|
|
|
|
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 → rsync → config → commit ║")
|
|
print("╚═══════════════════════════════════════╝")
|
|
print()
|
|
|
|
log_info("Step 1/4: Copy mods from workshop...")
|
|
subprocess.run([sys.executable, PREPARE_LOCAL], check=True)
|
|
log_ok("LocalMods ready")
|
|
print()
|
|
|
|
log_info("Step 2/4: Rsyncing LocalMods/ to server...")
|
|
subprocess.run([
|
|
"rsync", "-avz", "--delete",
|
|
"-e", "ssh -p 22",
|
|
LOCALMODS_DIR + "/", RSYNC_DEST
|
|
], check=True)
|
|
log_ok("LocalMods synced to homelabvm")
|
|
print()
|
|
|
|
log_info("Step 3/4: Generating config_player.xml...")
|
|
subprocess.run([sys.executable, AUTOGEN], check=True)
|
|
log_ok("config_player.xml generated")
|
|
print()
|
|
|
|
log_ok("Done.")
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|