func (self EventAction) Script(cmd string) { log.Println("Script:", cmd) // run exec non-blocking go func() { cmd = util.ExpandUser(cmd) _, err := exec.Command(cmd).Output() if err != nil { log.Printf("Exec %s: %s", cmd, err) } }() }
func setupCameras() { snapshotDir = util.ExpandUser(services.Config.Camera.Path) cameras = map[string]Camera{} for name, conf := range services.Config.Camera.Cameras { snapshot := fmt.Sprintf("%s/%s-%%s.%%s", snapshotDir, strings.TrimPrefix(name, "camera.")) switch conf.Protocol { case "foscam": cameras[name] = &Foscam{snapshot, conf} case "motion": cameras[name] = &Motion{snapshot, conf} } } }
func (self *Service) queryScript(q services.Question) string { args := strings.Split(q.Args, " ") if len(args) == 0 { return "Expected a script name argument" } progname := path.Base(args[0]) cmd := path.Join(util.ExpandUser("~/bin/gohome"), progname) log.Println("Running script:", cmd) output, err := exec.Command(cmd, args[1:]...).Output() if err != nil { return fmt.Sprintf("Command failed: %s", err) } return string(output) }
func (self *Service) ConfigUpdated(path string) { logDir = util.ExpandUser(services.Config.Datalogger.Path) }
// Get path to a log file func LogPath(p string) string { return path.Join(util.ExpandUser("~/go/log"), p) }