hook
<?php $access_token = 'd5c7a5eb767f18a9451919f7924e599a'; $web_path = '/www/wwwroot/expressell/'; $log_path = $web_path . 'expressell_git.log'; $client_token = $_GET['access_token']; $client_ip = $_SERVER['HTTP_HOST']; $fs = fopen($log_path, 'w'); fwrite($fs, 'Request on [' . date("Y-m-d H:i:s") . '] from [' . $client_ip . ']' . PHP_EOL); if ($client_token !== $access_token) { echo "error 403"; fwrite($fs, "Invalid token [{$client_token}]" . PHP_EOL); exit(0); } fwrite($fs, '=======================================================================' . PHP_EOL); try { fwrite($fs, '=======================================================================' . PHP_EOL); system("cd " . $web_path . " && sudo -s git checkout master >> " . $log_path . " 2>&1"); system("cd " . $web_path . " && sudo -s git pull >> " . $log_path . " 2>&1"); } catch (\Exception $th) { fwrite($fs, $th->getMessage() . PHP_EOL); } $fs and fclose($fs);