Compare commits
2 Commits
8989dc25ac
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c570b14537 | ||
|
|
58016c6889 |
@@ -125,15 +125,15 @@ func ExpandPath(path string) string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func main2(cli cfg, c *config.SSHrimp) {
|
func main2(cli cfg, c *config.SSHrimp) {
|
||||||
err := setupLoging(cli)
|
|
||||||
if err != nil {
|
|
||||||
log.Warnf("Error setting up logging: %v", err)
|
|
||||||
}
|
|
||||||
listener := openSocket(ExpandPath(c.Agent.Socket))
|
listener := openSocket(ExpandPath(c.Agent.Socket))
|
||||||
if listener == nil {
|
if listener == nil {
|
||||||
log.Errorln("Failed to open socket")
|
log.Errorln("Failed to open socket")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
err := setupLoging(cli)
|
||||||
|
if err != nil {
|
||||||
|
log.Warnf("Error setting up logging: %v", err)
|
||||||
|
}
|
||||||
err = launchAgent(c, listener)
|
err = launchAgent(c, listener)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panic("Failed to launch agent", err)
|
log.Panic("Failed to launch agent", err)
|
||||||
@@ -156,6 +156,9 @@ func main() {
|
|||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
sshCommand := flag.Args()
|
sshCommand := flag.Args()
|
||||||
|
if cli.Verbose {
|
||||||
|
logger.SetLevel(logrus.DebugLevel)
|
||||||
|
}
|
||||||
|
|
||||||
cfgFile := ExpandPath(cli.Config)
|
cfgFile := ExpandPath(cli.Config)
|
||||||
cfgFile, err = filepath.Abs(cfgFile)
|
cfgFile, err = filepath.Abs(cfgFile)
|
||||||
@@ -175,7 +178,7 @@ func main() {
|
|||||||
logger.Println("Launching agent")
|
logger.Println("Launching agent")
|
||||||
main2(cli, c)
|
main2(cli, c)
|
||||||
} else {
|
} else {
|
||||||
logger.Println("Attempting to start daemon")
|
logger.Debug("Attempting to start daemon")
|
||||||
var nullFile *os.File
|
var nullFile *os.File
|
||||||
nullFile, err = os.Open(os.DevNull)
|
nullFile, err = os.Open(os.DevNull)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -200,6 +203,7 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
nullFile.Close()
|
nullFile.Close()
|
||||||
|
logger.Debugf("Agent started in the background check %s for logs", getLogDir())
|
||||||
}
|
}
|
||||||
if len(sshCommand) > 1 && filepath.Base(sshCommand[0]) == "ssh" {
|
if len(sshCommand) > 1 && filepath.Base(sshCommand[0]) == "ssh" {
|
||||||
syscall.Exec(sshCommand[0], sshCommand, os.Environ())
|
syscall.Exec(sshCommand[0], sshCommand, os.Environ())
|
||||||
@@ -358,8 +362,9 @@ func launchAgent(c *config.SSHrimp, listener net.Listener) error {
|
|||||||
osSignals := make(chan os.Signal, 10)
|
osSignals := make(chan os.Signal, 10)
|
||||||
signal.Notify(osSignals, sigExit...)
|
signal.Notify(osSignals, sigExit...)
|
||||||
go func() {
|
go func() {
|
||||||
<-osSignals
|
sig := <-osSignals
|
||||||
listener.Close()
|
log.Infof("Recieved signal %v: closing", sig)
|
||||||
|
os.Exit(0)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Traceln("Starting main loop")
|
log.Traceln("Starting main loop")
|
||||||
|
|||||||
Reference in New Issue
Block a user