fix: rename binary to ssm
This commit is contained in:
@ -1,4 +1,4 @@
|
||||
// Package cli wires up the ss command-line interface, mirroring cli.py's
|
||||
// Package cli wires up the ssm command-line interface, mirroring cli.py's
|
||||
// argparse-based command tree with cobra.
|
||||
package cli
|
||||
|
||||
@ -59,15 +59,15 @@ func newManagers(configFile, outputFile, subscriptionName string) (*managers, er
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Version is the ss build version, injected at build time via
|
||||
// Version is the ssm build version, injected at build time via
|
||||
// -ldflags "-X gitea.epss.net.cn/klesh/ss/internal/cli.Version=vX.Y.Z"
|
||||
// (see .drone.yml). Defaults to "dev" for local/unversioned builds.
|
||||
var Version = "dev"
|
||||
|
||||
// Execute runs the ss CLI. It is the Go equivalent of cli.py's main().
|
||||
// Execute runs the ssm CLI. It is the Go equivalent of cli.py's main().
|
||||
func Execute() {
|
||||
root := &cobra.Command{
|
||||
Use: "ss",
|
||||
Use: "ssm",
|
||||
Short: "Scientific Surfing - CLI for managing clash RSS subscriptions",
|
||||
Version: Version,
|
||||
SilenceUsage: true,
|
||||
|
||||
@ -17,7 +17,7 @@ func newPlatformManager(configDir string) (platformManager, error) {
|
||||
// macosServiceManager manages services via launchd. Direct port of
|
||||
// MacOSServiceManager in service_manager.py. Unlike the Python version
|
||||
// (which shells out to a separate macos_service_wrapper.py for DNS
|
||||
// handling), the generated plist invokes this same ss binary in
|
||||
// handling), the generated plist invokes this same ssm binary in
|
||||
// "service run-macos" mode (see wrapper_darwin.go) — no second script file
|
||||
// is needed.
|
||||
type macosServiceManager struct {
|
||||
@ -31,7 +31,7 @@ func (d *macosServiceManager) launchdPath(name string) string {
|
||||
func (d *macosServiceManager) createLaunchdPlist(cfg Config) error {
|
||||
selfPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to determine ss executable path: %w", err)
|
||||
return fmt.Errorf("failed to determine ssm executable path: %w", err)
|
||||
}
|
||||
|
||||
workingDir := filepath.Dir(cfg.ExecutablePath)
|
||||
|
||||
@ -16,7 +16,7 @@ func newPlatformManager(configDir string) (platformManager, error) {
|
||||
}
|
||||
|
||||
// windowsServiceManager manages services via sc.exe, with the service
|
||||
// binPath pointing back at this same ss executable in
|
||||
// binPath pointing back at this same ssm executable in
|
||||
// "service run-windows" mode (see wrapper_windows.go) instead of a separate
|
||||
// pywin32-based wrapper process. Direct port of WindowsServiceManager in
|
||||
// service_manager.py, minus the pywin32/JSON-config-file indirection.
|
||||
@ -85,7 +85,7 @@ func runAsAdmin(cmdArgs []string, description string) error {
|
||||
func (w *windowsServiceManager) Install(cfg Config) error {
|
||||
selfPath, err := os.Executable()
|
||||
if err != nil {
|
||||
return fmt.Errorf("failed to determine ss executable path: %w", err)
|
||||
return fmt.Errorf("failed to determine ssm executable path: %w", err)
|
||||
}
|
||||
|
||||
serviceCmd := fmt.Sprintf(`"%s" service run-windows --name "%s" --bin "%s" --args "%s"`,
|
||||
|
||||
@ -163,7 +163,7 @@ func (w *mihomoWrapper) run() {
|
||||
|
||||
// RunMacOSWrapper runs the mihomo process with DNS management, blocking
|
||||
// until it exits or a termination signal is received. Invoked by the
|
||||
// hidden `ss service run-macos <executable> <configDir> [args...]` command
|
||||
// hidden `ssm service run-macos <executable> <configDir> [args...]` command
|
||||
// that the generated launchd plist points at (see service_darwin.go),
|
||||
// replacing the standalone macos_service_wrapper.py script.
|
||||
func RunMacOSWrapper(executable, configDir string, args []string) error {
|
||||
|
||||
@ -15,10 +15,10 @@ import (
|
||||
)
|
||||
|
||||
// windowsServiceHandler implements svc.Handler, hosting the mihomo
|
||||
// subprocess directly inside the ss binary. Replaces
|
||||
// subprocess directly inside the ssm binary. Replaces
|
||||
// windows_service_wrapper.py + pywin32 + the per-service JSON config file:
|
||||
// the equivalent configuration (bin path + args) is now passed as command
|
||||
// line flags to `ss service run-windows`, and this same binary registers
|
||||
// line flags to `ssm service run-windows`, and this same binary registers
|
||||
// itself as the service via golang.org/x/sys/windows/svc.
|
||||
type windowsServiceHandler struct {
|
||||
name string
|
||||
@ -119,7 +119,7 @@ func (w *logWriter) Write(p []byte) (int, error) {
|
||||
|
||||
// RunWindowsService registers this process as the named Windows service and
|
||||
// blocks until the service control manager stops it. Invoked via the hidden
|
||||
// `ss service run-windows --name <name> --bin <binPath> --args <args>`
|
||||
// `ssm service run-windows --name <name> --bin <binPath> --args <args>`
|
||||
// command that Install() points sc.exe's binPath= at.
|
||||
func RunWindowsService(name, binPath, args string) error {
|
||||
logPath := filepath.Join(filepath.Dir(binPath), name+"_service.log")
|
||||
|
||||
Reference in New Issue
Block a user