// Run daemons a line to the terminal func (d DaemonDriver) Run(args RunArgs) error { var buff bytes.Buffer tmpl, err := templates.New(d.line + "\n") if err != nil { return err } if err := tmpl.Execute(&buff, args); err != nil { return err } d.cmd = exec.Command("/bin/sh", "-c", buff.String()) d.cmd.Stdout = os.Stderr d.cmd.Stderr = os.Stderr d.cmd.Stdin = os.Stdin if err := d.cmd.Start(); err != nil { return err } go func() { d.cmd.Wait() Logger.Infof("daemon %q exited", d.line) }() return nil }
// Run writes a line to the terminal func (d WriteDriver) Run(args RunArgs) error { tmpl, err := templates.New(d.line + "\n") if err != nil { return err } return tmpl.Execute(os.Stderr, args) }
// Run notifications a line to the terminal func (d NotificationDriver) Run(args RunArgs) error { var buff bytes.Buffer tmpl, err := templates.New(d.line + "\n") if err != nil { return err } if err := tmpl.Execute(&buff, args); err != nil { return err } notification := gnotifier.Notification("ASSH", buff.String()) notification.GetConfig().Expiration = 3000 notification.GetConfig().ApplicationName = "assh" return notification.Push() }
// Run execs a line to the terminal func (d ExecDriver) Run(args RunArgs) error { var buff bytes.Buffer tmpl, err := templates.New(d.line + "\n") if err != nil { return err } if err := tmpl.Execute(&buff, args); err != nil { return err } cmd := exec.Command("/bin/sh", "-c", buff.String()) cmd.Stdout = os.Stderr cmd.Stderr = os.Stderr cmd.Stdin = os.Stdin if err := cmd.Start(); err != nil { return err } return cmd.Wait() }