x
This commit is contained in:
parent
cdc9f4ab9a
commit
74c3c18a09
@ -11,8 +11,8 @@ import (
|
||||
)
|
||||
|
||||
type Yaml struct {
|
||||
Containers []Container
|
||||
Tasks []Task
|
||||
Containers []Container
|
||||
// Tasks []Task
|
||||
Qrcode string
|
||||
Master string
|
||||
Mode string
|
||||
@ -37,6 +37,7 @@ type Yaml struct {
|
||||
Pip string
|
||||
NoAdmin bool `yaml:"no_admin"`
|
||||
QbotConfigFile string `yaml:"qbot_config_file"`
|
||||
Repos []Repo
|
||||
}
|
||||
|
||||
var Balance = "balance"
|
||||
@ -103,4 +104,5 @@ func initConfig() {
|
||||
if Config.Pip == "" {
|
||||
Config.Pip = "Pip3"
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -26,4 +26,5 @@ func init() {
|
||||
go initTgBot()
|
||||
InitReplies()
|
||||
initTask()
|
||||
initRepos()
|
||||
}
|
||||
|
||||
33
models/repos.go
Normal file
33
models/repos.go
Normal 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())
|
||||
}
|
||||
@ -34,11 +34,11 @@ type Env struct {
|
||||
}
|
||||
|
||||
func initTask() {
|
||||
for i := range Config.Tasks {
|
||||
if Config.Tasks[i].Cron != "" {
|
||||
createTask(&Config.Tasks[i])
|
||||
}
|
||||
}
|
||||
// for i := range Config.Tasks {
|
||||
// if Config.Tasks[i].Cron != "" {
|
||||
// createTask(&Config.Tasks[i])
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
func createTask(task *Task) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user