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");