2021-06-20 23:01:44 +02:00
|
|
|
package cmd
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/spf13/cobra"
|
|
|
|
"runtime"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
installCmd = &cobra.Command{
|
|
|
|
Use: "install",
|
|
|
|
Short: "installs wiretrustee service",
|
2021-10-17 21:34:07 +02:00
|
|
|
RunE: func(cmd *cobra.Command, args []string) error {
|
2021-06-20 23:01:44 +02:00
|
|
|
|
|
|
|
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 {
|
2021-06-22 01:07:12 +02:00
|
|
|
cmd.PrintErrln(err)
|
2021-10-17 21:34:07 +02:00
|
|
|
return err
|
2021-06-20 23:01:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
err = s.Install()
|
|
|
|
if err != nil {
|
2021-06-22 01:07:12 +02:00
|
|
|
cmd.PrintErrln(err)
|
2021-10-17 21:34:07 +02:00
|
|
|
return err
|
2021-06-20 23:01:44 +02:00
|
|
|
}
|
2021-10-17 21:34:07 +02:00
|
|
|
cmd.Println("Wiretrustee service has been installed")
|
|
|
|
return nil
|
2021-06-20 23:01:44 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
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 {
|
2021-06-22 01:07:12 +02:00
|
|
|
cmd.PrintErrln(err)
|
|
|
|
return
|
2021-06-20 23:01:44 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
err = s.Uninstall()
|
|
|
|
if err != nil {
|
2021-06-22 01:07:12 +02:00
|
|
|
cmd.PrintErrln(err)
|
|
|
|
return
|
2021-06-20 23:01:44 +02:00
|
|
|
}
|
2021-10-17 21:34:07 +02:00
|
|
|
cmd.Println("Wiretrustee has been uninstalled")
|
2021-06-20 23:01:44 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
}
|