This commit is contained in:
cdle 2021-08-21 17:12:13 +08:00
parent cdc9f4ab9a
commit 74c3c18a09
4 changed files with 43 additions and 7 deletions

View File

@ -11,8 +11,8 @@ import (
) )
type Yaml struct { type Yaml struct {
Containers []Container Containers []Container
Tasks []Task // Tasks []Task
Qrcode string Qrcode string
Master string Master string
Mode string Mode string
@ -37,6 +37,7 @@ type Yaml struct {
Pip string Pip string
NoAdmin bool `yaml:"no_admin"` NoAdmin bool `yaml:"no_admin"`
QbotConfigFile string `yaml:"qbot_config_file"` QbotConfigFile string `yaml:"qbot_config_file"`
Repos []Repo
} }
var Balance = "balance" var Balance = "balance"
@ -103,4 +104,5 @@ func initConfig() {
if Config.Pip == "" { if Config.Pip == "" {
Config.Pip = "Pip3" Config.Pip = "Pip3"
} }
} }

View File

@ -26,4 +26,5 @@ func init() {
go initTgBot() go initTgBot()
InitReplies() InitReplies()
initTask() initTask()
initRepos()
} }

33
models/repos.go Normal file
View File

@ -0,0 +1,33 @@
package models
import (
"fmt"
"os"
"os/exec"
"strings"
)
type Repo struct {
Git string
filename string
}
func (rp *Repo) init() {
rp.filename = strings.Replace(strings.Replace(rp.Git, "https://", "", -1), "/", "_", -1)
}
func initRepos() {
for _, repo := range Config.Repos {
repo.init()
if _, err := os.Stat(ExecPath + "/" + repo.filename); err != nil {
repo.gitClone()
}
}
}
func (rp *Repo) gitClone() {
cmd := exec.Command("git", "clone", rp.Git, rp.filename)
cmd.Path = ExecPath + "/repos"
fmt.Println(cmd.Path)
fmt.Println(cmd.Start())
}

View File

@ -34,11 +34,11 @@ type Env struct {
} }
func initTask() { func initTask() {
for i := range Config.Tasks { // for i := range Config.Tasks {
if Config.Tasks[i].Cron != "" { // if Config.Tasks[i].Cron != "" {
createTask(&Config.Tasks[i]) // createTask(&Config.Tasks[i])
} // }
} // }
} }
func createTask(task *Task) { func createTask(task *Task) {