mirror of
https://github.com/netbirdio/netbird.git
synced 2024-11-29 19:43:57 +01:00
fcea3c99d4
* move setup-key to root command * up will check login and start service * update tests to reflect new UP capabilities * display client IP * removed unused argument * install service if not installed * update post-install and add pre remove script * improve log messages * handle service status failures and install service when needed * removing unused files * update documentation and description * add version command * update service lib version * using lib constant for not installed services * match version from goreleaser * fix: graceful shutdown * stop only if service is running * add logs initialization to service controller commands Co-authored-by: braginini <bangvalo@gmail.com>
71 lines
1.2 KiB
Go
71 lines
1.2 KiB
Go
package cmd
|
|
|
|
import (
|
|
"github.com/spf13/cobra"
|
|
"runtime"
|
|
)
|
|
|
|
var (
|
|
installCmd = &cobra.Command{
|
|
Use: "install",
|
|
Short: "installs wiretrustee service",
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
|
|
|
svcConfig := newSVCConfig()
|
|
|
|
svcConfig.Arguments = []string{
|
|
"service",
|
|
"run",
|
|
"--config",
|
|
configPath,
|
|
"--log-level",
|
|
logLevel,
|
|
}
|
|
|
|
if runtime.GOOS == "linux" {
|
|
// Respected only by systemd systems
|
|
svcConfig.Dependencies = []string{"After=network.target syslog.target"}
|
|
}
|
|
|
|
s, err := newSVC(&program{}, svcConfig)
|
|
if err != nil {
|
|
cmd.PrintErrln(err)
|
|
return err
|
|
}
|
|
|
|
err = s.Install()
|
|
if err != nil {
|
|
cmd.PrintErrln(err)
|
|
return err
|
|
}
|
|
cmd.Println("Wiretrustee service has been installed")
|
|
return nil
|
|
},
|
|
}
|
|
)
|
|
|
|
var (
|
|
uninstallCmd = &cobra.Command{
|
|
Use: "uninstall",
|
|
Short: "uninstalls wiretrustee service from system",
|
|
Run: func(cmd *cobra.Command, args []string) {
|
|
|
|
s, err := newSVC(&program{}, newSVCConfig())
|
|
if err != nil {
|
|
cmd.PrintErrln(err)
|
|
return
|
|
}
|
|
|
|
err = s.Uninstall()
|
|
if err != nil {
|
|
cmd.PrintErrln(err)
|
|
return
|
|
}
|
|
cmd.Println("Wiretrustee has been uninstalled")
|
|
},
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
}
|