mirror of
https://github.com/Control-D-Inc/ctrld.git
synced 2026-08-10 13:20:33 +02:00
cmd/cli: workaround status command with new Openwrt
New Openwrt returns a non-success code even when status command run successfully, causing wrong status returned.
This commit is contained in:
+1
-1
@@ -61,7 +61,7 @@ var (
|
|||||||
v = viper.NewWithOptions(viper.KeyDelimiter("::"))
|
v = viper.NewWithOptions(viper.KeyDelimiter("::"))
|
||||||
defaultConfigFile = "ctrld.toml"
|
defaultConfigFile = "ctrld.toml"
|
||||||
rootCertPool *x509.CertPool
|
rootCertPool *x509.CertPool
|
||||||
errSelfCheckNoAnswer = errors.New("No response from ctrld listener. You can try to re-launch with flag --skip_self_checks")
|
errSelfCheckNoAnswer = errors.New("no response from ctrld listener. You can try to re-launch with flag --skip_self_checks")
|
||||||
)
|
)
|
||||||
|
|
||||||
var basicModeFlags = []string{"listen", "primary_upstream", "secondary_upstream", "domains"}
|
var basicModeFlags = []string{"listen", "primary_upstream", "secondary_upstream", "domains"}
|
||||||
|
|||||||
@@ -10,6 +10,7 @@ import (
|
|||||||
"github.com/kardianos/service"
|
"github.com/kardianos/service"
|
||||||
|
|
||||||
"github.com/Control-D-Inc/ctrld/internal/router"
|
"github.com/Control-D-Inc/ctrld/internal/router"
|
||||||
|
"github.com/Control-D-Inc/ctrld/internal/router/openwrt"
|
||||||
)
|
)
|
||||||
|
|
||||||
// newService wraps service.New call to return service.Service
|
// newService wraps service.New call to return service.Service
|
||||||
@@ -188,6 +189,13 @@ func checkHasElevatedPrivilege() {
|
|||||||
func unixSystemVServiceStatus() (service.Status, error) {
|
func unixSystemVServiceStatus() (service.Status, error) {
|
||||||
out, err := exec.Command("/etc/init.d/ctrld", "status").CombinedOutput()
|
out, err := exec.Command("/etc/init.d/ctrld", "status").CombinedOutput()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
// Specific case for openwrt >= 24.10, it returns non-success code
|
||||||
|
// for above status command, which may not right.
|
||||||
|
if router.Name() == openwrt.Name {
|
||||||
|
if string(bytes.ToLower(bytes.TrimSpace(out))) == "inactive" {
|
||||||
|
return service.StatusStopped, nil
|
||||||
|
}
|
||||||
|
}
|
||||||
return service.StatusUnknown, nil
|
return service.StatusUnknown, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user