refactor: simplify service installation process
This commit is contained in:
@ -40,6 +40,9 @@ func newServiceInstallCmd() *cobra.Command {
|
||||
Short: "Install mihomo as a system service",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := ensureRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -62,6 +65,9 @@ func newServiceUninstallCmd() *cobra.Command {
|
||||
Short: "Uninstall mihomo system service",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := ensureRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -83,6 +89,9 @@ func newServiceStartCmd() *cobra.Command {
|
||||
Short: "Start mihomo system service",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := ensureRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -104,6 +113,9 @@ func newServiceStopCmd() *cobra.Command {
|
||||
Short: "Stop mihomo system service",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := ensureRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
@ -125,6 +137,9 @@ func newServiceRestartCmd() *cobra.Command {
|
||||
Short: "Restart mihomo system service",
|
||||
Args: cobra.NoArgs,
|
||||
RunE: func(cmd *cobra.Command, args []string) error {
|
||||
if err := ensureRoot(); err != nil {
|
||||
return err
|
||||
}
|
||||
m, err := newManagers("", "", "")
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
Reference in New Issue
Block a user