goldwarden-vaultwarden-bitw.../cmd/daemonize.go

45 lines
965 B
Go
Raw Normal View History

2023-07-17 03:23:26 +02:00
package cmd
import (
"os"
"os/signal"
"github.com/awnumar/memguard"
"github.com/quexten/goldwarden/agent"
"github.com/spf13/cobra"
)
var daemonizeCmd = &cobra.Command{
Use: "daemonize",
Short: "Starts the agent as a daemon",
Long: `Starts the agent as a daemon. The agent will run in the background and will
run in the background until it is stopped.`,
Run: func(cmd *cobra.Command, args []string) {
2023-08-21 18:37:34 +02:00
websocketDisabled := runtimeConfig.WebsocketDisabled
sshDisabled := runtimeConfig.DisableSSHAgent
2023-08-21 13:52:06 +02:00
if websocketDisabled {
println("Websocket disabled")
}
if sshDisabled {
println("SSH agent disabled")
}
2023-07-17 03:23:26 +02:00
go func() {
signalChannel := make(chan os.Signal, 1)
signal.Notify(signalChannel, os.Interrupt)
<-signalChannel
memguard.SafeExit(0)
}()
2023-12-30 18:53:01 +01:00
err := agent.StartUnixAgent(runtimeConfig.GoldwardenSocketPath, runtimeConfig)
2023-07-17 03:23:26 +02:00
if err != nil {
panic(err)
}
},
}
func init() {
rootCmd.AddCommand(daemonizeCmd)
}