From 55eaea79be37d188ca4d3328a0283395cc910cf8 Mon Sep 17 00:00:00 2001 From: junleea <354425203@qq.com> Date: Sat, 6 Jul 2024 19:19:00 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=9B=86=E6=88=90=E9=83=A8?= =?UTF-8?q?=E5=88=86=E6=89=A7=E8=A1=8C=E8=84=9A=E6=9C=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- handler/cid.go | 38 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 20 deletions(-) diff --git a/handler/cid.go b/handler/cid.go index 70094bb..344b9e2 100644 --- a/handler/cid.go +++ b/handler/cid.go @@ -61,16 +61,15 @@ func RunCID(c *gin.Context) { name = names[0] //脚本内容 - scriptContent := `#!/bin/bash - TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` - if [ ! -d $TARGET_DIR ]; then - git clone ` + cid.Url + ` - cd $TARGET_DIR - else - cd $TARGET_DIR - git pull - fi - ` + cid.Script + scriptContent := `TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` +if [ ! -d $TARGET_DIR ]; then + git clone ` + cid.Url + ` + cd $TARGET_DIR +else + cd $TARGET_DIR + git pull +fi +` + cid.Script //执行脚本 cmd := exec.Command("/bin/bash", "-c", scriptContent) err3 := cmd.Run() @@ -193,16 +192,15 @@ func CIDCallback(c *gin.Context) { name := strs[len(strs)-1] names := strings.Split(name, ".") name = names[0] - scriptContent := `#!/bin/bash - TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` - if [ ! -d $TARGET_DIR ]; then - git clone ` + res.Url + ` - cd $TARGET_DIR - else - cd $TARGET_DIR - git pull - fi - ` + res.Script + scriptContent := `TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` +if [ ! -d $TARGET_DIR ]; then + git clone ` + res.Url + ` + cd $TARGET_DIR +else + cd $TARGET_DIR + git pull +fi +` + res.Script //执行脚本 cmd := exec.Command("/bin/bash", "-c", scriptContent) err3 := cmd.Run()