command now gets the image as a parameter
This commit is contained in:
parent
9592e4bb63
commit
fb8849322d
13
main.go
13
main.go
@ -145,18 +145,21 @@ func currentImage(configPath string, config sunsetConfig) string {
|
||||
return absFile
|
||||
}
|
||||
|
||||
func block(config sunsetConfig, command string) {
|
||||
func block(configPath string, config sunsetConfig, command string) {
|
||||
image := currentImage(configPath, config)
|
||||
go runCommand(command, image)
|
||||
for {
|
||||
nextHr, nextMin := getNextWait(config)
|
||||
timer := time.NewTimer((time.Duration(nextHr) * time.Hour) + (time.Duration(nextMin) * time.Minute))
|
||||
<-timer.C
|
||||
log.Printf("Running command: %s\n", command)
|
||||
go runCommand(command)
|
||||
image := currentImage(configPath, config)
|
||||
go runCommand(command, image)
|
||||
}
|
||||
}
|
||||
|
||||
func runCommand(command string) {
|
||||
cmd := exec.Command("/usr/bin/env", "sh", "-c", command)
|
||||
func runCommand(command, image string) {
|
||||
cmd := exec.Command(command, image)
|
||||
err := cmd.Run()
|
||||
if err != nil {
|
||||
log.Printf("Command %s returned a non 0 code", command)
|
||||
@ -184,7 +187,7 @@ func main() {
|
||||
fmt.Println("Must provide a command.")
|
||||
os.Exit(1)
|
||||
}
|
||||
block(conf, *blockCommand)
|
||||
block(*configFile, conf, *blockCommand)
|
||||
} else {
|
||||
fmt.Printf("%s", currentImage(*configFile, conf))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user