Skip to content

Commit

Permalink
z2059 - fix macosx daemon for non-standard paths (#85)
Browse files Browse the repository at this point in the history
  • Loading branch information
vnarek authored Aug 16, 2022
1 parent d1fd35b commit 30c7e5a
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## [v0.12.2] - 2022-08-16

### Fixed
- Inherit the `PATH` variable from the user on `daemon install` on `darwin` platform

## [v0.12.1] - 2022-08-09

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions src/cliAction/serviceLogs/handler_formatByTemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package serviceLogs
import (
"bytes"
"fmt"
"golang.org/x/text/cases"
"golang.org/x/text/language"
"strings"
"text/template"

"golang.org/x/text/cases"
"golang.org/x/text/language"

"github.com/zerops-io/zcli/src/i18n"
)

Expand Down
1 change: 1 addition & 0 deletions src/cmd/args.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package cmd

import (
"fmt"

"github.com/zerops-io/zcli/src/i18n"

"github.com/spf13/cobra"
Expand Down
3 changes: 2 additions & 1 deletion src/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ package cmd
import (
"context"
"fmt"
"github.com/zerops-io/zcli/src/i18n"
"os"
"os/signal"
"syscall"

"github.com/zerops-io/zcli/src/i18n"

"github.com/zerops-io/zcli/src/support"

"github.com/spf13/cobra"
Expand Down
11 changes: 10 additions & 1 deletion src/daemonInstaller/handler_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ func newDaemon(name, description string, dependencies []string) (daemon, error)
}, nil
}

const defaultPath = "/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin"

func (daemon *darwinRecord) Install() error {
if daemon.IsInstalled() {
return ErrAlreadyInstalled
Expand Down Expand Up @@ -60,6 +62,11 @@ func (daemon *darwinRecord) Install() error {
logDir := filepath.Dir(constants.LogFilePath)
daemonStorageDir := filepath.Dir(constants.DaemonStorageFilePath)

userPath, ok := os.LookupEnv("PATH")
if !ok {
userPath = defaultPath
}

templ, err := template.New("propertyList").Parse(propertyList)
if err != nil {
return err
Expand All @@ -71,11 +78,13 @@ func (daemon *darwinRecord) Install() error {
Name string
LogFile string
WorkingDir string
PathEnv string
}{
BinaryPath: path.Join(constants.DaemonInstallDir, daemon.name),
Name: daemon.name,
LogFile: constants.LogFilePath,
WorkingDir: daemonStorageDir,
PathEnv: userPath,
},
); err != nil {
return err
Expand Down Expand Up @@ -182,7 +191,7 @@ var propertyList = `<?xml version="1.0" encoding="UTF-8"?>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin</string>
<string>{{.PathEnv}}</string>
<key>HOME</key>
<string>/etc</string>
</dict>
Expand Down
5 changes: 3 additions & 2 deletions src/proto/zBusinessZeropsApiProtocol/zeropsApiProtocol.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 30c7e5a

Please sign in to comment.