Pull request: 3226 support service on OpenBSD

Merge in DNS/adguard-home from 3226-openbsd-svc to master

Closes #3226.

Squashed commit of the following:

commit bcf1a31a8343ae4b35c7cadeb45bc7a10863fda2
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Aug 24 17:43:31 2021 +0300

    aghos: imp code

commit 3d4060ce6b5a37cf7af05b117b8bc4a49f69b2e8
Merge: 9e9225ec b92db25e
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Aug 24 17:09:00 2021 +0300

    Merge branch 'master' into 3226-openbsd-svc

commit 9e9225ecb2af30fe46999b43c0683e4b3c946778
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Aug 24 17:02:52 2021 +0300

    home: fix lil bugs

commit 03456f9a09081c6178dca0ac9887590b5d24f333
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Tue Aug 24 16:18:48 2021 +0300

    home: imp code

commit 5cdf4fcbae78c07b663190012228003fe94bfdee
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Aug 20 23:32:15 2021 +0300

    home: imp code, docs

commit d2a95faa0a7d176cdcba304e7226ebe11c1ce341
Author: Eugene Burkov <e.burkov@adguard.com>
Date:   Fri Aug 20 14:01:53 2021 +0300

    home: sup service on openbsd
This commit is contained in:
Eugene Burkov
2021-08-24 18:00:30 +03:00
parent b92db25e6a
commit 16092e8ba9
6 changed files with 505 additions and 39 deletions

View File

@@ -13,6 +13,7 @@ import (
"strconv"
"strings"
"github.com/AdguardTeam/golibs/errors"
"github.com/AdguardTeam/golibs/log"
)
@@ -59,8 +60,11 @@ func RunCommand(command string, arguments ...string) (int, string, error) {
if len(out) > MaxCmdOutputSize {
out = out[:MaxCmdOutputSize]
}
if err != nil {
return 1, "", fmt.Errorf("exec.Command(%s) failed: %v: %s", command, err, string(out))
if errors.As(err, new(*exec.ExitError)) {
return cmd.ProcessState.ExitCode(), string(out), nil
} else if err != nil {
return 1, "", fmt.Errorf("exec.Command(%s) failed: %w: %s", command, err, string(out))
}
return cmd.ProcessState.ExitCode(), string(out), nil