diff --git a/README.md b/README.md index 48dd566e..7aca1adc 100644 --- a/README.md +++ b/README.md @@ -69,6 +69,7 @@ Copyright (c) 2020 Martin Hebnes Pedersen LA5NTA * KD8DRX - Will Davidson * KE8HMG - Andrew Huebner * KI7RMJ - Rainer Grosskopf +* KM6LBU - Robert Hernandez * LA3QMA - Kai Günter Brandt * LA4TTA - Erlend Grimseid * LA5NTA - Martin Hebnes Pedersen diff --git a/internal/prehook/prehook.go b/internal/prehook/prehook.go index 39efeac4..6564d1f3 100644 --- a/internal/prehook/prehook.go +++ b/internal/prehook/prehook.go @@ -12,22 +12,14 @@ import ( "net" "os" "os/exec" - "path/filepath" "time" "github.com/la5nta/pat/internal/debug" - "github.com/la5nta/pat/internal/directories" "golang.org/x/sync/errgroup" ) var ErrConnNotWrapped = errors.New("connection not wrapped for prehook") -func init() { - // Add {config-dir}/prehooks/ to PATH - prehooksPath := filepath.Join(directories.ConfigDir(), "prehooks") - os.Setenv("PATH", fmt.Sprintf(`%s%c%s`, prehooksPath, os.PathListSeparator, os.Getenv("PATH"))) -} - type Script struct { File string Args []string diff --git a/main.go b/main.go index 0739e06c..c431cd78 100644 --- a/main.go +++ b/main.go @@ -208,6 +208,7 @@ var fOptions struct { Listen string MailboxPath string ConfigPath string + PrehooksPath string LogPath string EventLogPath string FormsPath string @@ -225,11 +226,13 @@ func optionsSet() *pflag.FlagSet { defaultMBox := filepath.Join(directories.DataDir(), "mailbox") defaultFormsPath := filepath.Join(directories.DataDir(), "Standard_Forms") defaultConfigPath := filepath.Join(directories.ConfigDir(), "config.json") + defaultPrehooksPath := filepath.Join(directories.ConfigDir(), "prehooks") defaultLogPath := filepath.Join(directories.StateDir(), strings.ToLower(buildinfo.AppName+".log")) defaultEventLogPath := filepath.Join(directories.StateDir(), "eventlog.json") set.StringVar(&fOptions.MailboxPath, "mbox", defaultMBox, "Path to mailbox directory.") set.StringVar(&fOptions.FormsPath, "forms", defaultFormsPath, "Path to forms directory.") set.StringVar(&fOptions.ConfigPath, "config", defaultConfigPath, "Path to config file.") + set.StringVar(&fOptions.PrehooksPath, "prehooks", defaultPrehooksPath, "Path to prehooks") set.StringVar(&fOptions.LogPath, "log", defaultLogPath, "Path to log file. The file is truncated on each startup.") set.StringVar(&fOptions.EventLogPath, "event-log", defaultEventLogPath, "Path to event log file.") @@ -308,6 +311,8 @@ func main() { os.Setenv("GZIP_EXPERIMENT", "1") } + os.Setenv("PATH", fmt.Sprintf(`%s%c%s`, fOptions.PrehooksPath, os.PathListSeparator, os.Getenv("PATH"))) + // Parse configuration file var err error config, err = LoadConfig(fOptions.ConfigPath, cfg.DefaultConfig)