修改集成部分执行脚本

This commit is contained in:
junleea 2024-07-06 19:19:00 +08:00
parent d4877d283d
commit 55eaea79be
1 changed files with 18 additions and 20 deletions

View File

@ -61,16 +61,15 @@ func RunCID(c *gin.Context) {
name = names[0] name = names[0]
//脚本内容 //脚本内容
scriptContent := `#!/bin/bash scriptContent := `TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + `
TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` if [ ! -d $TARGET_DIR ]; then
if [ ! -d $TARGET_DIR ]; then git clone ` + cid.Url + `
git clone ` + cid.Url + ` cd $TARGET_DIR
cd $TARGET_DIR else
else cd $TARGET_DIR
cd $TARGET_DIR git pull
git pull fi
fi ` + cid.Script
` + cid.Script
//执行脚本 //执行脚本
cmd := exec.Command("/bin/bash", "-c", scriptContent) cmd := exec.Command("/bin/bash", "-c", scriptContent)
err3 := cmd.Run() err3 := cmd.Run()
@ -193,16 +192,15 @@ func CIDCallback(c *gin.Context) {
name := strs[len(strs)-1] name := strs[len(strs)-1]
names := strings.Split(name, ".") names := strings.Split(name, ".")
name = names[0] name = names[0]
scriptContent := `#!/bin/bash scriptContent := `TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + `
TARGET_DIR = ` + proto.CID_BASE_DIR + `workspace/` + name + ` if [ ! -d $TARGET_DIR ]; then
if [ ! -d $TARGET_DIR ]; then git clone ` + res.Url + `
git clone ` + res.Url + ` cd $TARGET_DIR
cd $TARGET_DIR else
else cd $TARGET_DIR
cd $TARGET_DIR git pull
git pull fi
fi ` + res.Script
` + res.Script
//执行脚本 //执行脚本
cmd := exec.Command("/bin/bash", "-c", scriptContent) cmd := exec.Command("/bin/bash", "-c", scriptContent)
err3 := cmd.Run() err3 := cmd.Run()