mirror of
https://github.com/wyx2685/V2bX.git
synced 2026-02-04 12:40:11 +00:00
add version cmd, fix bug for uninstall cmd
This commit is contained in:
17
cmd/cmd.go
17
cmd/cmd.go
@@ -1,29 +1,12 @@
|
|||||||
package cmd
|
package cmd
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
|
||||||
"github.com/spf13/cobra"
|
"github.com/spf13/cobra"
|
||||||
"log"
|
"log"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
version = "TempVersion" //use ldflags replace
|
|
||||||
codename = "V2bX"
|
|
||||||
intro = "A V2board backend based on Xray-core"
|
|
||||||
)
|
|
||||||
|
|
||||||
func showVersion() {
|
|
||||||
fmt.Printf("%s %s (%s) \n", codename, version, intro)
|
|
||||||
// Warning
|
|
||||||
fmt.Println(Warn("This version need V2board version >= 1.7.0."))
|
|
||||||
fmt.Println(Warn("This version changed config file. Please check config file before running."))
|
|
||||||
}
|
|
||||||
|
|
||||||
var command = &cobra.Command{
|
var command = &cobra.Command{
|
||||||
Use: "V2bX",
|
Use: "V2bX",
|
||||||
PreRun: func(_ *cobra.Command, _ []string) {
|
|
||||||
showVersion()
|
|
||||||
},
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func Run() {
|
func Run() {
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ func uninstallHandle(_ *cobra.Command, _ []string) {
|
|||||||
_ = os.RemoveAll("/etc/systemd/system/V2bX.service")
|
_ = os.RemoveAll("/etc/systemd/system/V2bX.service")
|
||||||
_ = os.RemoveAll("/etc/V2bX/")
|
_ = os.RemoveAll("/etc/V2bX/")
|
||||||
_ = os.RemoveAll("/usr/local/V2bX/")
|
_ = os.RemoveAll("/usr/local/V2bX/")
|
||||||
|
_ = os.RemoveAll("/bin/V2bX")
|
||||||
_, err = execCommand("systemctl daemon-reload&&systemctl reset-failed")
|
_, err = execCommand("systemctl daemon-reload&&systemctl reset-failed")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(Err("exec cmd error: ", err))
|
fmt.Println(Err("exec cmd error: ", err))
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ func init() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func serverHandle(_ *cobra.Command, _ []string) {
|
func serverHandle(_ *cobra.Command, _ []string) {
|
||||||
|
showVersion()
|
||||||
c := conf.New()
|
c := conf.New()
|
||||||
err := c.LoadFromPath(config)
|
err := c.LoadFromPath(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|||||||
31
cmd/version.go
Normal file
31
cmd/version.go
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
package cmd
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/spf13/cobra"
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
version = "TempVersion" //use ldflags replace
|
||||||
|
codename = "V2bX"
|
||||||
|
intro = "A V2board backend based on Xray-core"
|
||||||
|
)
|
||||||
|
|
||||||
|
var versionCommand = cobra.Command{
|
||||||
|
Use: "version",
|
||||||
|
Short: "Print version info",
|
||||||
|
Run: func(cmd *cobra.Command, args []string) {
|
||||||
|
showVersion()
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
command.AddCommand(&versionCommand)
|
||||||
|
}
|
||||||
|
|
||||||
|
func showVersion() {
|
||||||
|
fmt.Printf("%s %s (%s) \n", codename, version, intro)
|
||||||
|
// Warning
|
||||||
|
fmt.Println(Warn("This version need V2board version >= 1.7.0."))
|
||||||
|
fmt.Println(Warn("This version changed config file. Please check config file before running."))
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user