chore: unify education management naming

This commit is contained in:
Codex
2026-06-15 12:38:25 +08:00
parent 5112f7ab4e
commit 41452bcd73
13 changed files with 40 additions and 36 deletions
+3 -3
View File
@@ -19,7 +19,7 @@ DEFAULT_IDENTITY_FILE = Path.home() / ".ssh" / "xsk_records_vps_ed25519"
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="部署新时空课程记录查询网页到 VPS")
parser = argparse.ArgumentParser(description="部署新时空教务管理系统到 VPS")
parser.add_argument("--remote-host", default=os.getenv("XSK_REMOTE_HOST", DEFAULT_REMOTE_HOST))
parser.add_argument("--remote-user", default=os.getenv("XSK_REMOTE_USER", DEFAULT_REMOTE_USER))
parser.add_argument("--remote-port", type=int, default=int(os.getenv("XSK_REMOTE_PORT", str(DEFAULT_REMOTE_PORT))))
@@ -27,7 +27,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--identity-file",
default=os.getenv("XSK_IDENTITY_FILE", str(DEFAULT_IDENTITY_FILE) if DEFAULT_IDENTITY_FILE.exists() else ""),
help="SSH 私钥路径;默认使用 ~/.ssh/xsk_records_vps_ed25519(如果存在)",
help="SSH 私钥路径;默认兼容使用历史文件 ~/.ssh/xsk_records_vps_ed25519(如果存在)",
)
parser.add_argument("--app-port", default=os.getenv("XSK_APP_PORT", "18080"))
parser.add_argument(
@@ -137,7 +137,7 @@ def main() -> int:
run(ssh_command(args) + [f"mkdir -p {shlex.quote(app_dir)} {shlex.quote(data_dir)}"])
run(rsync_command(args) + [f"{PROJECT_DIR}/", f"{base_remote(args)}:{app_dir}/"])
run(rsync_command(args) + [str(env_file), f"{base_remote(args)}:{app_dir}/.env"])
run(ssh_command(args) + [f"cd {shlex.quote(app_dir)} && docker compose up -d --build"])
run(ssh_command(args) + [f"cd {shlex.quote(app_dir)} && docker compose up -d --build --remove-orphans"])
print(f"部署完成: http://{args.remote_host}:{args.app_port}/")
finally:
env_file.unlink(missing_ok=True)
+7 -3
View File
@@ -9,13 +9,15 @@ import subprocess
PROJECT_DIR = Path(__file__).resolve().parents[1]
LABEL = "com.xsk.records.sync"
LABEL = "com.xsk.education-management.sync"
OLD_LABEL = "com.xsk.records.sync"
PLIST_PATH = Path.home() / "Library" / "LaunchAgents" / f"{LABEL}.plist"
LOG_DIR = Path.home() / "Library" / "Logs" / "xsk-records-web"
OLD_PLIST_PATH = Path.home() / "Library" / "LaunchAgents" / f"{OLD_LABEL}.plist"
LOG_DIR = Path.home() / "Library" / "Logs" / "xsk-education-management"
def parse_args() -> argparse.Namespace:
parser = argparse.ArgumentParser(description="安装新时空课程记录同步 LaunchAgent")
parser = argparse.ArgumentParser(description="安装新时空教务管理系统同步 LaunchAgent")
parser.add_argument("--use-sshpass", action="store_true", default=os.getenv("XSK_USE_SSHPASS", "") == "1")
parser.add_argument("--ssh-password", default=os.getenv("XSK_SSH_PASSWORD"))
return parser.parse_args()
@@ -50,6 +52,8 @@ def main() -> int:
with PLIST_PATH.open("wb") as handle:
plistlib.dump(plist, handle)
subprocess.run(["launchctl", "unload", str(OLD_PLIST_PATH)], check=False, capture_output=True)
OLD_PLIST_PATH.unlink(missing_ok=True)
subprocess.run(["launchctl", "unload", str(PLIST_PATH)], check=False, capture_output=True)
subprocess.run(["launchctl", "load", str(PLIST_PATH)], check=True)
print(f"已安装并启动 LaunchAgent: {PLIST_PATH}")
+2 -2
View File
@@ -45,7 +45,7 @@ def parse_args() -> argparse.Namespace:
parser.add_argument(
"--identity-file",
default=os.getenv("XSK_IDENTITY_FILE", str(DEFAULT_IDENTITY_FILE) if DEFAULT_IDENTITY_FILE.exists() else ""),
help="SSH 私钥路径;默认使用 ~/.ssh/xsk_records_vps_ed25519(如果存在)",
help="SSH 私钥路径;默认兼容使用历史文件 ~/.ssh/xsk_records_vps_ed25519(如果存在)",
)
parser.add_argument(
"--use-sshpass",
@@ -161,7 +161,7 @@ def current_signatures(local_dir: Path) -> dict[str, tuple[int, int]]:
def watch(config: Config) -> None:
log("启动课程记录同步监听")
log("启动新时空教务管理系统数据同步监听")
signatures: dict[str, tuple[int, int]] = {}
while True:
try: