Ejemplo n.º 1
0
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)
		}
	}()
}
Ejemplo n.º 2
0
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}
		}
	}
}
Ejemplo n.º 3
0
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)
}
Ejemplo n.º 4
0
func (self *Service) ConfigUpdated(path string) {
	logDir = util.ExpandUser(services.Config.Datalogger.Path)
}
Ejemplo n.º 5
0
// Get path to a log file
func LogPath(p string) string {
	return path.Join(util.ExpandUser("~/go/log"), p)
}