You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

39 lines
884 B

package custom
import (
log "github.com/sirupsen/logrus"
"os"
"os/exec"
)
type Config struct {
Pre []string `yaml:"pre" json:"pre" toml:"pre"`
Post []string `yaml:"post" json:"post" toml:"post"`
}
func runScript(command string) {
log.Debugf("Run script -> %s", command)
cmd := exec.Command("sh", "-c", command)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
err := cmd.Start()
if err != nil {
log.Warningf("Script `%s` working error", command)
} else {
_ = cmd.Wait()
}
}
func RunPreScript(config *Config) {
for _, script := range config.Pre {
log.Infof("Run pre-script command -> %s", script)
runScript(script)
}
}
func RunPostScript(config *Config) {
for _, script := range config.Post {
log.Infof("Run post-script command -> %s", script)
runScript(script)
}
}