diff --git a/app/Http/Controllers/CronController.php b/app/Http/Controllers/CronController.php index a7ce5bd..9127a94 100755 --- a/app/Http/Controllers/CronController.php +++ b/app/Http/Controllers/CronController.php @@ -161,14 +161,14 @@ class CronController // 检查文件是否存在,如果不存在则创建 if (!file_exists($sshConfigFile)) { -// touch($sshConfigFile); + touch($sshConfigFile); } // 追加配置到文件 file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX); // 设置文件权限 -// chmod($sshConfigFile, 0600); + chmod($sshConfigFile, 0600); echo "SSH config updated successfully.\n"; @@ -221,6 +221,10 @@ class CronController // 添加远程仓库 $this->runCommand("git remote add origin \"{$this->sProjectUrl}\""); + // 立即拉取覆盖一次 + $this->runCommand("git fetch origin"); + $this->runCommand("git reset --hard origin/main"); + echo "操作完成:以初始化仓库[".$this->aArticle['id']."]。\n"; }