mirror of
https://github.com/openziti/desktop-edge-win.git
synced 2026-10-14 08:39:55 +00:00
stage subcommands
This commit is contained in:
@@ -14,6 +14,7 @@ require (
|
||||
github.com/netfoundry/ziti-foundation v0.9.8
|
||||
github.com/netfoundry/ziti-sdk-golang v0.11.16
|
||||
github.com/sirupsen/logrus v1.5.0
|
||||
github.com/spf13/cobra v0.0.5
|
||||
github.com/tebeka/strftime v0.1.4 // indirect
|
||||
github.com/tv42/topic v0.0.0-20130729201830-aa72cbe81b48
|
||||
golang.org/x/sys v0.0.0-20200406113430-c6e801f48ba2
|
||||
|
||||
@@ -32,6 +32,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/
|
||||
github.com/google/uuid v1.1.1/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
|
||||
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
|
||||
github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU=
|
||||
github.com/inconshreveable/mousetrap v1.0.0 h1:Z8tu5sraLXCXIcARxBp/8cbvlwVa7Z1NHg9XEKhtSvM=
|
||||
github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8=
|
||||
github.com/influxdata/influxdb1-client v0.0.0-20191209144304-8bf82d3c094d/go.mod h1:qj24IKcXYK6Iy9ceXlo3Tc+vtHo9lIhSX5JddghvEPo=
|
||||
github.com/jehiah/go-strftime v0.0.0-20171201141054-1d33003b3869 h1:IPJ3dvxmJ4uczJe5YQdrYB16oTJlGSC/OyZDqUk9xX4=
|
||||
@@ -93,9 +94,11 @@ github.com/sirupsen/logrus v1.5.0/go.mod h1:+F7Ogzej0PZc/94MaYx/nvG9jOFMD2osvC3s
|
||||
github.com/speps/go-hashids v2.0.0+incompatible/go.mod h1:P7hqPzMdnZOfyIk+xrlG1QaSMw+gCBdHKsBDnhpaZvc=
|
||||
github.com/spf13/afero v1.1.2/go.mod h1:j4pytiNVoe2o6bmDsKpLACNPDBIoEAkihy7loJ1B0CQ=
|
||||
github.com/spf13/cast v1.3.0/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE=
|
||||
github.com/spf13/cobra v0.0.5 h1:f0B+LkLX6DtmRH1isoNA9VTtNUK9K8xYd28JNNfOv/s=
|
||||
github.com/spf13/cobra v0.0.5/go.mod h1:3K3wKZymM7VvHMDS9+Akkh4K60UwM26emMESw8tLCHU=
|
||||
github.com/spf13/jwalterweatherman v1.0.0/go.mod h1:cQK4TGJAtQXfYWX+Ddv3mKDzgVb68N+wFjFa4jdeBTo=
|
||||
github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnInEg4=
|
||||
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
|
||||
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
|
||||
github.com/spf13/viper v1.3.2/go.mod h1:ZiWeW+zYFKm7srdB9IoDzzZXaJaI5eL9QjNiN/DMA2s=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/spf13/cobra"
|
||||
"os"
|
||||
"path/filepath"
|
||||
)
|
||||
var exeName, _ = os.Executable()
|
||||
var rootCmd = &cobra.Command{
|
||||
Use: filepath.Base(exeName) ,
|
||||
Short: "Runs the ziti-tunnel as a service",
|
||||
Long: `This program provides access to a ziti-based network.
|
||||
When executed without parameters it is expected that this application is running as a service`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
// Do Stuff Here
|
||||
fmt.Println("i am in command")
|
||||
},
|
||||
}
|
||||
|
||||
func Execute() {
|
||||
if err := rootCmd.Execute(); err != nil {
|
||||
fmt.Println(err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(addIdCmd)
|
||||
}
|
||||
|
||||
var addIdCmd = &cobra.Command{
|
||||
Use: "addId",
|
||||
Short: "Adds the provided jwt file to the running service",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Adds the provided jwt file to the running service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(debugCmd)
|
||||
}
|
||||
|
||||
var debugCmd = &cobra.Command{
|
||||
Use: "debug",
|
||||
Short: "Runs the program interactively instead of expecting to be run as a service. Used in debugging",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Runs the program interactively instead of expecting to be run as a service. Used in debugging")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(disableIdCmd)
|
||||
}
|
||||
|
||||
var disableIdCmd = &cobra.Command{
|
||||
Use: "disable",
|
||||
Short: "Disables any identity in the running service using the provided fingerprint",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Disables any identity in the running service using the provided fingerprint")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(enableIdCmd)
|
||||
}
|
||||
|
||||
var enableIdCmd = &cobra.Command{
|
||||
Use: "enable",
|
||||
Short: "Enables any identity in the running service using the provided fingerprint",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Enables any identity in the running service using the provided fingerprint")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(removeIdCmd)
|
||||
}
|
||||
|
||||
var removeIdCmd = &cobra.Command{
|
||||
Use: "removeId",
|
||||
Short: "Removes any identity from the running service using the provided fingerprint",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Removes any identity from the running service using the provided fingerprint")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(serviceCmd)
|
||||
}
|
||||
|
||||
var serviceCmd = &cobra.Command{
|
||||
Use: "service",
|
||||
Short: "Expects to run the program as a service",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("print or return the version here")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serviceCmd.AddCommand(installCmd)
|
||||
}
|
||||
|
||||
var installCmd = &cobra.Command{
|
||||
Use: "install",
|
||||
Short: "Installs the executable as a service.",
|
||||
Long: `When installing as a service using this function make sure not to move the executable. The path to the executing program will be used in the service`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("install this thing as a service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serviceCmd.AddCommand(removeCmd)
|
||||
}
|
||||
|
||||
var removeCmd = &cobra.Command{
|
||||
Use: "remove",
|
||||
Short: "Removes the executable as a service.",
|
||||
Long: `When removing the service make sure the path and service name have not changed`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("remove this thing as a service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serviceCmd.AddCommand(startCmd)
|
||||
}
|
||||
|
||||
var startCmd = &cobra.Command{
|
||||
Use: "start",
|
||||
Short: "Tries to start the service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Tries to start the service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serviceCmd.AddCommand(statusCmd)
|
||||
}
|
||||
|
||||
var statusCmd = &cobra.Command{
|
||||
Use: "status",
|
||||
Short: "Prints the status of the service",
|
||||
Hidden: true,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("Prints the status of the service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
serviceCmd.AddCommand(stopCmd)
|
||||
}
|
||||
|
||||
var stopCmd = &cobra.Command{
|
||||
Use: "stop",
|
||||
Short: "Tries to stop the service",
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("try to stop the service")
|
||||
},
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/spf13/cobra"
|
||||
)
|
||||
|
||||
func init() {
|
||||
rootCmd.AddCommand(versionCmd)
|
||||
}
|
||||
|
||||
var versionCmd = &cobra.Command{
|
||||
Use: "version",
|
||||
Short: "Print the version of the current executable",
|
||||
Long: ``,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
fmt.Println("print or return the version here")
|
||||
},
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
"golang.org/x/sys/windows/svc/eventlog"
|
||||
"os"
|
||||
"strings"
|
||||
"wintun-testing/ziti-tunnel/cmd"
|
||||
"wintun-testing/ziti-tunnel/globals"
|
||||
|
||||
"golang.org/x/sys/windows/svc"
|
||||
@@ -18,7 +19,16 @@ var log = globals.Logger()
|
||||
func main() {
|
||||
globals.InitLogger("debug")
|
||||
|
||||
// passing no arguments is an indicator that this is excpecting to be run 'as a service'.
|
||||
if len(os.Args) < 2 {
|
||||
// if no args supplied - expect to run as service
|
||||
os.Args = append(os.Args, "service")
|
||||
}
|
||||
cmd.Execute()
|
||||
if true {
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
// passing no arguments is an indicator that this is expecting to be run 'as a service'.
|
||||
// using arg count instead of svc.IsAnInteractiveSession() as svc.IsAnInteractiveSession()
|
||||
// seems to return false even when run in an interactive shell as via `psexec -i -s cmd.exe`
|
||||
hasArgs := len(os.Args) > 1
|
||||
|
||||
Reference in New Issue
Block a user