no message

This commit is contained in:
hellcat 2025-04-17 19:56:29 +08:00
parent 32947a08ca
commit 762fce8c01
3 changed files with 73 additions and 7 deletions

View File

@ -11,6 +11,7 @@ class CronController
private $sUserName;
private $sProjectName;
private $sHostName;
private $sProjectPath;
private $sProjectUrl;
@ -85,8 +86,9 @@ class CronController
foreach ($aArticle as $row) {
$this->sUserName = $row["user_name"];
$this->sProjectName = $row["project_name"];
$this->sProjectPath = env("BASE_DIR")."github/".$this->sUserName."-".$this->sProjectName;
$this->sProjectUrl = env("github_url_base").":".$this->sUserName."/".$this->sProjectName.".git";
$this->sHostName = $row['host_name'];
$this->sProjectPath = env("BASE_DIR")."github/".$this->sHostName."-".$this->sProjectName;
$this->sProjectUrl = env("github_url_base").":".$this->sHostName."/".$this->sProjectName.".git";
$this->aArticle = $row;
list($sClass, $sFunc) = explode('#', $row['mod']);
@ -113,6 +115,8 @@ class CronController
$this->gitInit();
$this->sshConfigAdd();
}
// 写入内容
@ -128,6 +132,39 @@ class CronController
}
}
private function sshConfigAdd()
{
// 定义要添加的配置
$host = $this->sHostName;
$hostname = "github.com";
$user = "git";
$identityFile = env("path_ssh")."/id_rsa_".$sHostName;
// 构建配置字符串
$config = "\nHost ".$host.".com\n";
$config .= "\tHostName $hostname\n";
$config .= "\tUser $user\n";
$config .= "\tIdentityFile $identityFile\n";
// 指定 SSH 配置文件路径
$sshConfigFile = env("path_ssh")."/config";
// 检查文件是否存在,如果不存在则创建
if (!file_exists($sshConfigFile)) {
touch($sshConfigFile);
}
// 追加配置到文件
file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX);
// 设置文件权限
chmod($sshConfigFile, 0600);
echo "SSH config updated successfully.";
}
private function formatstr($str)
{
$str = substr($str, 1, -1);

View File

@ -10,8 +10,41 @@ use App\Services\TomTool\Http;
class TestsController
{
public function hook()
public function hook($sHostName = 'ssssss')
{
// 定义要添加的配置
$host = $sHostName;
$hostname = "github.com";
$user = "git";
$identityFile = env("path_ssh")."/id_rsa_".$sHostName;
// 构建配置字符串
$config = "\nHost ".$host.".com\n";
$config .= "\tHostName $hostname\n";
$config .= "\tUser $user\n";
$config .= "\tIdentityFile $identityFile\n";
// 指定 SSH 配置文件路径
$sshConfigFile = env("path_ssh")."/config";
// 检查文件是否存在,如果不存在则创建
if (!file_exists($sshConfigFile)) {
touch($sshConfigFile);
}
// 追加配置到文件
file_put_contents($sshConfigFile, $config, FILE_APPEND | LOCK_EX);
// 设置文件权限
chmod($sshConfigFile, 0600);
echo "SSH config updated successfully.";
exit;
// $t = [];
// $a = $t['zz']["cc"] += 10;
// $a = $t['zz']["cc"] += 10;

View File

@ -4,10 +4,6 @@ use App\Services\TomTool\Http;
class JichangTuijian {
public $sTitle; // 必须
public $sContent; // 必须
public $sSubTitle; // 非必须
public function A($aArticle)
{