Create the LaunchAgents directory if it does not exist (#237)
* Create the LaunchAgents directory if it does not exist Fixes: https://github.com/ooni/probe/issues/1368 * Update cmd/ooniprobe/internal/autorun/autorun_darwin.go Co-authored-by: Simone Basso <bassosimone@gmail.com> Co-authored-by: Simone Basso <bassosimone@gmail.com>
This commit is contained in:
parent
322394fe63
commit
12e1164940
|
@ -6,6 +6,7 @@ import (
|
|||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"strings"
|
||||
"text/template"
|
||||
|
@ -20,7 +21,8 @@ import (
|
|||
type managerDarwin struct{}
|
||||
|
||||
var (
|
||||
plistPath = os.ExpandEnv("$HOME/Library/LaunchAgents/org.ooni.cli.plist")
|
||||
plistDir = os.ExpandEnv("$HOME/Library/LaunchAgents/")
|
||||
plistPath = filepath.Join(plistDir, "org.ooni.cli.plist")
|
||||
domainTarget = fmt.Sprintf("gui/%d", os.Getuid())
|
||||
serviceTarget = fmt.Sprintf("%s/org.ooni.cli", domainTarget)
|
||||
)
|
||||
|
@ -107,6 +109,10 @@ func (managerDarwin) writePlist() error {
|
|||
if err := t.Execute(&out, in); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("exec: mkdir -p %s", plistDir)
|
||||
if err := os.MkdirAll(plistDir, 0755); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Infof("exec: writePlist(%s)", plistPath)
|
||||
return ioutil.WriteFile(plistPath, out.Bytes(), 0644)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user