From 66bf57911bccc0e727de9a58ceaab996eaa22b02 Mon Sep 17 00:00:00 2001 From: klarkxy <278370456@qq.com> Date: Fri, 13 Mar 2026 15:36:13 +0800 Subject: [PATCH] feat(gitpull): execute git pull on page load and add retry button - Changed git pull execution from POST-only to always run on page load - Replaced sudo with su for better user switching in command execution - Removed form submission in favor of direct execution with retry button - Simplified UI by always showing result message and conditionally showing retry button --- web/gitpull.php | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/web/gitpull.php b/web/gitpull.php index 95d551a..211b4d7 100644 --- a/web/gitpull.php +++ b/web/gitpull.php @@ -21,13 +21,12 @@ $src_path = '/home/judge/src'; $output = []; $return_code = -1; -if ($_SERVER['REQUEST_METHOD'] === 'POST') { - $cmd = "echo " . escapeshellarg($SUDO_PASSWORD) - . " | sudo -S -u " . escapeshellarg($SUDO_USER) - . " git -C " . escapeshellarg($src_path) - . " pull 2>&1"; - exec($cmd, $output, $return_code); -} +// 打开页面或点击重试按钮时均执行更新 +$cmd = "echo " . escapeshellarg($SUDO_PASSWORD) + . " | su -c " . escapeshellarg("git -C " . $src_path . " pull") + . " " . escapeshellarg($SUDO_USER) + . " 2>&1"; +exec($cmd, $output, $return_code); $show_title = "Git Pull - " . $OJ_NAME; require("template/".$OJ_TEMPLATE."/header.php"); @@ -39,19 +38,19 @@ require("template/".$OJ_TEMPLATE."/header.php");
服务器更新 (git pull )
- -
-
-
-
- +
+
+
+
-
- +
+ + + 重试 git pull + + 返回 - +